Coverage Report - org.org.usurper.handlers.basic.AbstractPropertyTypeHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractPropertyTypeHandler
76 %
13/17
100 %
2/2
0
 
 1  
 /*
 2  
  ORG Usurper is a random value object generator library 
 3  
  Copyright (C) 2007  Pierre-Antoine GrĂ©goire
 4  
  
 5  
  This library is free software; you can redistribute it and/or
 6  
  modify it under the terms of the GNU Lesser General Public
 7  
  License as published by the Free Software Foundation; either
 8  
  version 2.1 of the License, or (at your option) any later version.
 9  
  
 10  
  This library is distributed in the hope that it will be useful,
 11  
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
  Lesser General Public License for more details.
 14  
  
 15  
  You should have received a copy of the GNU Lesser General Public
 16  
  License along with this library; if not, write to the Free Software
 17  
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 18  
  */
 19  
 
 20  
 package org.org.usurper.handlers.basic;
 21  
 
 22  
 import java.util.Arrays;
 23  
 import java.util.Collections;
 24  
 import java.util.HashSet;
 25  
 import java.util.Set;
 26  
 
 27  
 import org.org.usurper.handlers.IHandler;
 28  
 import org.org.usurper.model.PropertyTypeDefinition;
 29  
 
 30  
 /**
 31  
  * This is the class to extend in order to implement a handler for a specific type.
 32  
  * 
 33  
  * @author pagregoire
 34  
  */
 35  
 public abstract class AbstractPropertyTypeHandler implements IHandler {
 36  
 
 37  
     /** The handled types. */
 38  
     private Set<PropertyTypeDefinition> handledTypes;
 39  
 
 40  
     @SuppressWarnings("unused")
 41  0
     private AbstractPropertyTypeHandler() {
 42  0
     }
 43  
 
 44  
     /**
 45  
      * Instantiates a new abstract property type handler.
 46  
      * Takes a series of PropertyTypeDefinition objects as parameter.
 47  
      * @param handledTypes
 48  
      *            the handled types
 49  
      */
 50  3
     public AbstractPropertyTypeHandler(PropertyTypeDefinition... properTypeDefinitions) {
 51  3
         this.handledTypes = Collections.unmodifiableSet(new HashSet<PropertyTypeDefinition>(Arrays.asList(properTypeDefinitions)));
 52  3
     }
 53  
 
 54  
     /**
 55  
      * Instantiates a new abstract property type handler.
 56  
      * Takes a series of Class objects as parameter.
 57  
      * @param handledTypes
 58  
      *            the handled types
 59  
      */
 60  9
     public AbstractPropertyTypeHandler(Class<?>... propertyTypeDefinitionClasses) {
 61  9
         Set<PropertyTypeDefinition> handledTypes = new HashSet<PropertyTypeDefinition>();
 62  34
         for (Class<?> propertyTypeDefinitionClass : propertyTypeDefinitionClasses) {
 63  25
             handledTypes.add(new PropertyTypeDefinition(propertyTypeDefinitionClass));
 64  
         }
 65  9
         this.handledTypes = Collections.unmodifiableSet(handledTypes);
 66  9
     }
 67  
 
 68  
     /**
 69  
      * Instantiates a new abstract property type handler.
 70  
      * Takes a Set of PropertyTypeDefinition objects as parameter.
 71  
      * @param handledTypes
 72  
      *            the handled types
 73  
      */
 74  18
     public AbstractPropertyTypeHandler(Set<PropertyTypeDefinition> handledTypes) {
 75  18
         this.handledTypes = handledTypes;
 76  18
     }
 77  
 
 78  
     /**
 79  
      * Gets the handled types.
 80  
      * 
 81  
      * @return Returns the handledType.
 82  
      */
 83  
     public Set<PropertyTypeDefinition> getHandledTypes() {
 84  4942
         return handledTypes;
 85  
     }
 86  
 
 87  
     /**
 88  
      * Sets the handled types.
 89  
      * 
 90  
      * @param handledTypes
 91  
      *            the handled types
 92  
      */
 93  
     public void setHandledTypes(Set<PropertyTypeDefinition> handledTypes) {
 94  0
         this.handledTypes = handledTypes;
 95  0
     }
 96  
 
 97  
 }