All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nuiton.validator.bean.BeanValidatorEvent Maven / Gradle / Ivy

The newest version!
package org.nuiton.validator.bean;
/*
 * #%L
 * Validation :: API
 * %%
 * Copyright (C) 2021 - 2024 Ultreia.io
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

import org.nuiton.validator.NuitonValidatorScope;

import java.util.EventObject;

/**
 * Event to be fired when some messages changed on a given field / scope of a bean.
 *
 * @author Tony Chemit - [email protected]
 * @since 2.5.2
 */
public class BeanValidatorEvent extends EventObject {
    private static final long serialVersionUID = 1L;

    /**
     * the field impacted by the validator
     */
    protected String field;

    /**
     * the scope impacted by the event
     */
    protected NuitonValidatorScope scope;

    protected String[] messagesToAdd;

    protected String[] messagesToDelete;

    public BeanValidatorEvent(BeanValidator source,
                              String field,
                              NuitonValidatorScope scope,
                              String[] messagesToAdd,
                              String[] messagesToDelete) {
        super(source);
        this.field = field;
        this.scope = scope;
        this.messagesToAdd = messagesToAdd;
        this.messagesToDelete = messagesToDelete;
    }

    public V getBean() {
        return getSource().getBean();
    }

    @SuppressWarnings("unchecked")
    @Override
    public BeanValidator getSource() {
        return (BeanValidator) super.getSource();
    }

    public String[] getMessagesToAdd() {
        return messagesToAdd;
    }

    public String[] getMessagesToDelete() {
        return messagesToDelete;
    }

    public NuitonValidatorScope getScope() {
        return scope;
    }

    public String getField() {
        return field;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy