Coverage Report - org.org.usurper.handlers.defaults.DatePropertyTypeHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
DatePropertyTypeHandler
100 %
7/7
N/A
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.defaults;
 21  
 
 22  
 import java.util.Date;
 23  
 import java.util.HashSet;
 24  
 import java.util.Set;
 25  
 
 26  
 import org.org.usurper.handlers.basic.AbstractPropertyTypeHandler;
 27  
 import org.org.usurper.model.HandledBeanProperty;
 28  
 import org.org.usurper.model.HandledConstructorArg;
 29  
 import org.org.usurper.model.PropertyTypeDefinition;
 30  
 import org.org.usurper.utils.RandomUtils;
 31  
 
 32  
 /**
 33  
  * This handler returns a random java.util.Date value.<br>
 34  
  * It handles the Date type.
 35  
  * @author pagregoire
 36  
  */
 37  
 public class DatePropertyTypeHandler extends AbstractPropertyTypeHandler {
 38  
     
 39  
     private static Set<PropertyTypeDefinition> handledTypes;
 40  
     static {
 41  1
         handledTypes = new HashSet<PropertyTypeDefinition>();
 42  1
         handledTypes.add(new PropertyTypeDefinition(Date.class));
 43  1
     }
 44  
 
 45  
     /**
 46  
      * Instantiates a new date property type handler.
 47  
      */
 48  
     public DatePropertyTypeHandler() {
 49  1
         super(handledTypes);
 50  1
     }
 51  
 
 52  
     /**
 53  
      * @see org.org.zepag.vogenerator.handlers.AbstractPropertyTypeHandler#handle()
 54  
      */
 55  
     public Object handle(HandledBeanProperty handledBeanProperty) {
 56  478
         return RandomUtils.nextDate();
 57  
     }
 58  
 
 59  
     /**
 60  
      * @see org.org.zepag.vogenerator.handlers.AbstractPropertyTypeHandler#handle()
 61  
      */
 62  
     public Object handle(HandledConstructorArg handledConstructorArg) {
 63  2
         return RandomUtils.nextDate();
 64  
     }
 65  
 }