All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.unitils.objectvalidation.ObjectCreator Maven / Gradle / Ivy

There is a newer version: 1.1.9
Show newest version
package org.unitils.objectvalidation;

import java.lang.reflect.Type;
import java.util.List;

import org.unitils.objectvalidation.objectcreator.generator.Generator;
import org.unitils.objectvalidation.utils.TreeNode;


/**
 * The responsability of {@link ObjectCreator} is to create object of the type provided.
 *
 * The default ones are :
 * 
    *
  1. {@link org.unitils.objectvalidation.objectcreator.generator.EnumGenerator} : That will generate a random enumeration.
  2. * *
  3. {@link org.unitils.objectvalidation.objectcreator.generator.PrimitiveGenerator} : That will handle all those field types : * *
      *
    • int, {@link Integer}, boolean, {@link Boolean}, float, {@link Float}, double, {@link Double}, * {@link java.math.BigDecimal}, long, {@link Long}, short, {@link Short}, byte, {@link Byte}
    • *
    • char, {@link Character}, {@link String}
    • *
    • {@link java.util.Date}, {@link java.sql.Date}, {@link java.sql.Timestamp}, {@link java.util.Calendar}
    • *
    • Subtype of {@link Exception}
    • *
    *
  4. *
  5. {@link org.unitils.objectvalidation.objectcreator.generator.CollectionGenerator} : *
      *
    • It will handle the classes assignables from : {@link java.util.Map}, {@link java.util.Set}, {@link java.util.List} and the arrays
    • *
    • It will go down the tree even if types like this : HashMap<String, HashMap<String, List<String>>>
    • *
    • It will generate for each of those field a random number of items between 1 and 10.
    • *
    *
  6. *
  7. {@link org.unitils.objectvalidation.objectcreator.generator.BuilderGenerator} : *
      *
    • It will check if the class specifies a "build" method and will fill in the Builder object fields by reflection.
    • *
    * *
  8. *
  9. * * {@link org.unitils.objectvalidation.objectcreator.generator.LastResortGenerator} : *
      *
    • * It will generate the class through reflection, using all the fields collected by the {@link org.unitils.objectvalidation.utils.TreeNodeCreator}. *
    • *
    *
  10. *
* @author Matthieu Mestrez * @since Oct 18, 2013 */ public interface ObjectCreator { Object createRandomObject(Type bean); Object createRandomObject(TreeNode bean); void addGenerators(Generator... generator); List getGenerators(); T getGeneratorOfType(Class generatorType); Generator getGenerator(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy