Coverage Report - org.jtheque.core.utils.ui.constraints.Constraint
 
Classes in this File Line Coverage Branch Coverage Complexity
Constraint
N/A
N/A
1
 
 1  
 package org.jtheque.core.utils.ui.constraints;
 2  
 
 3  
 import org.jtheque.core.managers.error.JThequeError;
 4  
 
 5  
 import java.util.Collection;
 6  
 
 7  
 /*
 8  
  * This file is part of JTheque.
 9  
  *
 10  
  * JTheque is free software: you can redistribute it and/or modify
 11  
  * it under the terms of the GNU General Public License as published by
 12  
  * the Free Software Foundation, either version 3 of the License.
 13  
  *
 14  
  * JTheque is distributed in the hope that it will be useful,
 15  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 17  
  * GNU General Public License for more details.
 18  
  *
 19  
  * You should have received a copy of the GNU General Public License
 20  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 21  
  */
 22  
 
 23  
 /**
 24  
  * A constraint on an entity property.
 25  
  *
 26  
  * @author Baptiste Wicht
 27  
  */
 28  
 public interface Constraint {
 29  
     /**
 30  
      * Return the max length of the value.
 31  
      *
 32  
      * @return The max length of the value.
 33  
      */
 34  
     int maxLength();
 35  
 
 36  
     /**
 37  
      * Indicate if the value must be numerical or not.
 38  
      *
 39  
      * @return true if teh value must be numerical else false.
 40  
      */
 41  
     boolean mustBeNumerical();
 42  
 
 43  
     /**
 44  
      * Indicate if the value can be null or not.
 45  
      *
 46  
      * @return true if the value can be null else false.
 47  
      */
 48  
     boolean canBeNullOrEmpty();
 49  
 
 50  
     /**
 51  
      * Indicate if we must control length or not.
 52  
      *
 53  
      * @return true if we must control length else false.
 54  
      */
 55  
     boolean mustControlLength();
 56  
 
 57  
     /**
 58  
      * Validate the field.
 59  
      *
 60  
      * @param field  The field to validate.
 61  
      * @param errors The errors list.
 62  
      */
 63  
     void validate(Object field, Collection<JThequeError> errors);
 64  
 }