org.unitils.objectvalidation.objectcreator.generator
Class ParameterizedTypeGenerator

java.lang.Object
  extended by org.unitils.objectvalidation.objectcreator.generator.ParameterizedTypeGenerator
All Implemented Interfaces:
Generator

public class ParameterizedTypeGenerator
extends Object
implements Generator

Create objects of type ParameterizedType.

Since:
1.1.8
Author:
Willemijn Wouters
See Also:
ParameterizedType

Constructor Summary
ParameterizedTypeGenerator(ObjectCreator objectCreator)
           
 
Method Summary
 Object createParameterizedType(ParameterizedType type, List<Object> input, List<Class<?>> inputClasses)
          This method generates an object of type ParameterizedType.
 Object generateObject(Class<?> clazz, List<Object> input, List<Class<?>> inputClasses, List<TreeNode> genericSubTypes)
           
protected  boolean isCollection(ObjectCreatorTypeWrapper typeWrapper)
          This method checks if the type is a collection or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterizedTypeGenerator

public ParameterizedTypeGenerator(ObjectCreator objectCreator)
Method Detail

generateObject

public Object generateObject(Class<?> clazz,
                             List<Object> input,
                             List<Class<?>> inputClasses,
                             List<TreeNode> genericSubTypes)
                      throws Exception
Specified by:
generateObject in interface Generator
Parameters:
clazz - The class of the object to generate
input - the parameters to give to the constructor
inputClasses - the types of the constructor parameters
genericSubTypes - if clazz has generic parameters here they should be entered
Returns:
Object a randomly generated object or null if it was impossible to generate
Throws:
Exception - if illegal calls to object constructors.
See Also:
Generator.generateObject(java.lang.Class, java.util.List, java.util.List, java.util.List)

createParameterizedType

public Object createParameterizedType(ParameterizedType type,
                                      List<Object> input,
                                      List<Class<?>> inputClasses)
                               throws Exception
This method generates an object of type ParameterizedType.

Parameters:
type - : the ParameterizedType
input - : a list with input objects for the CollectionGenerator
inputClasses - : a list of input classes for the CollectionGenerator.
Returns:
Object
Throws:
Exception

isCollection

protected boolean isCollection(ObjectCreatorTypeWrapper typeWrapper)
This method checks if the type is a collection or not.

Parameters:
typeWrapper - : an ObjectCreatorTypeWrapper.
Returns:
boolean


Copyright © 2013-2015. All Rights Reserved.