
org.nuiton.validator.AbstractNuitonScopeValidator Maven / Gradle / Ivy
The newest version!
package org.nuiton.validator;
/*-
* #%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 java.util.Set;
/**
* Created on 26/01/2024.
*
* @author Tony Chemit - [email protected]
* @since 2.0.0
*/
public abstract class AbstractNuitonScopeValidator implements NuitonScopeValidator {
/**
* the type of bean to validate
*/
protected final Class type;
/**
* the validation named context (can be null)
*/
private final String context;
/**
* the list of field names detected for this validator
*/
private final Set fieldNames;
protected AbstractNuitonScopeValidator(Class type, String context, Set fieldNames) {
this.type = type;
this.context = context;
this.fieldNames = fieldNames;
}
@Override
public Class getType() {
return type;
}
@Override
public String getContext() {
return context;
}
@Override
public Set getFieldNames() {
return fieldNames;
}
@Override
public boolean containsField(String fieldName) {
return fieldNames.contains(fieldName);
}
@Override
public String toString() {
return String.format("%s", super.toString(), type, context);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy