org.unitils.objectvalidation.objectcreator.generator.helper
Class GeneratorHelper

java.lang.Object
  extended by org.unitils.objectvalidation.objectcreator.generator.helper.GeneratorHelper

public class GeneratorHelper
extends Object

This class generates supertypes or subtypes from a specific class.

Since:
1.1.8
Author:
Willemijn Wouters

Method Summary
static Set<Class<?>> compareSubtypesSets(Set<?> set1, Set<?> set2)
          Returns only the in common classes of set1 and set2
static List<TreeNode> createNodes(Type type)
           
protected  Object createRandomObjects(Set<Class<?>> classes)
          This method creates a random object of a random class found with WildCardTypeGenerator.getClassesOfSubtypes(sun.reflect.generics.reflectiveObjects.WildcardTypeImpl, java.util.Set) or WildCardTypeGenerator.getClassesOfSuperType(sun.reflect.generics.reflectiveObjects.WildcardTypeImpl, java.util.Set).
static TreeNode createTreenode(Field field)
           
static TreeNode createTreenode(Type type)
           
static List<TreeNode> createTreenodes(Field field)
           
static Object generateSubTypesObject(Class<?> classForType)
          Generate the exact object or a subtype from a specific class.
protected  Object generateSubTypesObjectInstance(Class<?> classForType)
           
static Set<?> getClassesOfSubtypes(Class<?> clzz, Set<?> allClasses)
          Get the subtypes of a Class
protected  Set<?> getClassesOfSubtypesInstance(Class<?> clzz, Set<?> allClasses)
           
static Set<Class<?>> getClassesOfSuperType(Class<?> clzz, Set<Class<?>> allClasses)
          Get all the supertypes from a Class
protected  Set<Class<?>> getClassesOfSuperTypeInstance(Class<?> clzz, Set<Class<?>> allClasses)
           
static GeneratorHelper getInstance()
           
static Set<Class<? extends Object>> getSetWithClassesThatOverridesASpecificMethod(Set<Class<? extends Object>> set, String methodName, Class<?>... parameterTypes)
          Goes through all the objects in a set and removes all the classes that doesn't override a specific method.
static Object pickAndCreateAnObjectFromASet(Set<Class<?>> collClasses)
          This method creates a random object from a Set of classes.
protected  Object pickAndCreateAnObjectFromASetInstance(Set<Class<?>> collClasses)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getClassesOfSuperType

public static Set<Class<?>> getClassesOfSuperType(Class<?> clzz,
                                                  Set<Class<?>> allClasses)
Get all the supertypes from a Class

Parameters:
clzz: - look for supertypes of this Class.
allClasses: - A collection where the Generator should add the found classes.
Returns:
Set

compareSubtypesSets

public static Set<Class<?>> compareSubtypesSets(Set<?> set1,
                                                Set<?> set2)
Returns only the in common classes of set1 and set2

Parameters:
set1: - an object of type Set
set2: - an object of type Set
Returns:
Set

generateSubTypesObject

public static Object generateSubTypesObject(Class<?> classForType)
Generate the exact object or a subtype from a specific class.

Parameters:
classForType: - the generator should look for a subtype of this class.
Returns:
Object

getClassesOfSubtypes

public static Set<?> getClassesOfSubtypes(Class<?> clzz,
                                          Set<?> allClasses)
Get the subtypes of a Class

Parameters:
clzz: - look for subtypes of this Class.
allClasses: - A collection where the Generator should add the found classes.
Returns:
Set

getSetWithClassesThatOverridesASpecificMethod

public static Set<Class<? extends Object>> getSetWithClassesThatOverridesASpecificMethod(Set<Class<? extends Object>> set,
                                                                                         String methodName,
                                                                                         Class<?>... parameterTypes)
Goes through all the objects in a set and removes all the classes that doesn't override a specific method.

Parameters:
set: - A set of classes.
methodName: - the method that this method should find
parameterTypes: - the parameters of the method that the classes must override
Returns:
Set

pickAndCreateAnObjectFromASet

public static Object pickAndCreateAnObjectFromASet(Set<Class<?>> collClasses)
This method creates a random object from a Set of classes.

Parameters:
collClasses: - This is a collection of classes.
Returns:
Object

getInstance

public static GeneratorHelper getInstance()

getClassesOfSuperTypeInstance

protected Set<Class<?>> getClassesOfSuperTypeInstance(Class<?> clzz,
                                                      Set<Class<?>> allClasses)

generateSubTypesObjectInstance

protected Object generateSubTypesObjectInstance(Class<?> classForType)

getClassesOfSubtypesInstance

protected Set<?> getClassesOfSubtypesInstance(Class<?> clzz,
                                              Set<?> allClasses)

pickAndCreateAnObjectFromASetInstance

protected Object pickAndCreateAnObjectFromASetInstance(Set<Class<?>> collClasses)

createRandomObjects

protected Object createRandomObjects(Set<Class<?>> classes)
This method creates a random object of a random class found with WildCardTypeGenerator.getClassesOfSubtypes(sun.reflect.generics.reflectiveObjects.WildcardTypeImpl, java.util.Set) or WildCardTypeGenerator.getClassesOfSuperType(sun.reflect.generics.reflectiveObjects.WildcardTypeImpl, java.util.Set).

Parameters:
classes: - A set with a collection of classes.
Returns:
Object

createNodes

public static List<TreeNode> createNodes(Type type)

createTreenode

public static TreeNode createTreenode(Type type)

createTreenode

public static TreeNode createTreenode(Field field)

createTreenodes

public static List<TreeNode> createTreenodes(Field field)


Copyright © 2013-2015. All Rights Reserved.