Coverage Report - org.apache.commons.contract.constraints.BooleanConstraints
 
Classes in this File Line Coverage Branch Coverage Complexity
BooleanConstraints
0%
0/10
0%
0/2
2.667
 
 1  
 package org.apache.commons.contract.constraints;
 2  
 
 3  
 import org.apache.commons.contract.Context;
 4  
 import org.apache.commons.i18n.bundles.ErrorBundle;
 5  
 import org.apache.commons.i18n.bundles.TextBundle;
 6  
 
 7  0
 public class BooleanConstraints implements Constraints {
 8  0
         public final static String TRUE = Boolean.toString(true);
 9  0
     public final static String FALSE = Boolean.toString(false);
 10  
 
 11  
     public Object cast(Object value, Context context) throws CastException {
 12  0
         if ( value instanceof Boolean) {
 13  0
             return value;
 14  
         } 
 15  
         try {
 16  0
             return Boolean.valueOf(StringConstraints.UNCONSTRAINED.cast(value, null).toString());
 17  0
         } catch ( CastException exception ) {
 18  0
             throw new CastException(new ErrorBundle("uncastableBooleanValue", new Object[] { value }));
 19  
         }
 20  
     }
 21  
     
 22  
     public void validate(Object value, Context context) throws ValidationException {
 23  0
     }
 24  
     
 25  
     public TextBundle verboseConstraints() {
 26  0
         return new TextBundle("unconstrainedBoolean");
 27  
     }
 28  
 }