1 /* 2 * #%L 3 * Nuiton Validator 4 * %% 5 * Copyright (C) 2013 - 2014 Code Lutin, Tony Chemit 6 * %% 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as 9 * published by the Free Software Foundation, either version 3 of the 10 * License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Lesser Public License for more details. 16 * 17 * You should have received a copy of the GNU General Lesser Public 18 * License along with this program. If not, see 19 * <http://www.gnu.org/licenses/lgpl-3.0.html>. 20 * #L% 21 */ 22 package org.nuiton.validator; 23 24 import java.util.Set; 25 26 /** 27 * Contract of a validator. 28 * 29 * To obtain validator, see the {@link NuitonValidatorFactory} api. 30 * 31 * @author Tony Chemit - chemit@codelutin.com 32 * @see NuitonValidatorFactory 33 * @since 2.0 34 */ 35 public interface NuitonValidator<O> { 36 37 /** 38 * Validates the given object and returns the result of validation. 39 * 40 * @param object the object to validate 41 * @return the result of validation for the given object 42 * @throws NullPointerException if object is {@code null}. 43 */ 44 NuitonValidatorResult validate(O object) throws NullPointerException; 45 46 /** 47 * Obtains the model of the validator. 48 * 49 * @return the model of the validator 50 */ 51 NuitonValidatorModel<O> getModel(); 52 53 /** 54 * Obtains the set of effective scopes for the validator : means the very 55 * scopes that the validator is dealing with. 56 * 57 * This is a subset of the model authorized scopes. 58 * 59 * @return the set of effective scopes of the validator 60 */ 61 Set<NuitonValidatorScope> getEffectiveScopes(); 62 63 /** 64 * Obtains the set of effective fields for the validator : means the very 65 * fields validated by the validator. 66 * 67 * This is a sub set of fields of the object to validate. 68 * 69 * @return the set of effective fields of the validator 70 */ 71 Set<String> getEffectiveFields(); 72 73 /** 74 * Obtains the set of effective fields for the validator for the given scope 75 * : means the very fields validated by the validator. 76 * 77 * This is a subset of effective fields of the validator. 78 * 79 * @param scope given scope to use 80 * @return the set of effective fields of the validator for the given scope 81 */ 82 Set<String> getEffectiveFields(NuitonValidatorScope scope); 83 84 }