org.org.usurper
Class UsurperGenerator<T>

java.lang.Object
  extended by org.org.usurper.UsurperGenerator<T>

public class UsurperGenerator<T>
extends java.lang.Object

This class defines a UsurperGenerator generator

Author:
pagregoire

Constructor Summary
UsurperGenerator(java.lang.Class<? extends T> usurpatedClass)
          This constructor creates an UsurperGenerator for the given Bean class.
UsurperGenerator(java.lang.Class<? extends T> usurpatedClass, IUsurperGeneratorSetup usurperGeneratorSetup)
          This constructor creates an UsurperGenerator for the given Bean class.
UsurperGenerator(java.lang.Class<? extends T> usurpatedClass, OnMissingHandlers onMissingHandlers)
          Deprecated. prefer the use of the UsurperGeneratorSetup if you need to override the default behaviour
 
Method Summary
 T generateUsurper()
          This method generates an usurper object of the type specified as Generic for the UsurperGenerator instance.
 java.util.List<T> generateUsurperList(int number)
          Utility method that generates a list of usurpers of the type specified as Generic for the UsurperGenerator instance.
 java.util.Set<T> generateUsurperSet(int number)
          Utility method that generates a list of usurpers of the type specified as Generic for the UsurperGenerator instance.
 java.util.Map<ITargetDefinition,IHandler> getAllHandlers()
          Deprecated. prefer the use of the UsurperGeneratorSetup
 AbstractPropertyTypeHandler getPropertyTypeHandler(java.lang.Class<?> handledType)
          Deprecated. prefer the use of the UsurperGeneratorSetup
 ImmutableUsurperGeneratorSetup getSetup()
          This methods returns the current setup object
 AbstractSpecificPropertyHandler getSpecificPropertyHandler(java.lang.Class<?> usurpatedClass, java.lang.String handledProperty)
          Deprecated. prefer the use of the UsurperGeneratorSetup
 boolean hasPropertyTypeHandler(java.lang.Class<?> type)
          Deprecated. prefer the use of the UsurperGeneratorSetup
 boolean hasSpecificPropertyHandler(java.lang.Class<?> usurpatedClass, java.lang.String handledProperty)
          Deprecated. prefer the use of the UsurperGeneratorSetup
 void onMissingHandlers(OnMissingHandlers onMissingHandlers)
          Deprecated. prefer the use of the UsurperGeneratorSetup
 void registerPropertyTypeHandler(AbstractPropertyTypeHandler typeHandler)
          Deprecated. prefer the use of the UsurperGeneratorSetup
 void registerPropertyTypeHandlers(java.util.Set<AbstractPropertyTypeHandler> typeHandlers)
          Deprecated. prefer the use of the UsurperGeneratorSetup
 void registerSpecificPropertyHandler(AbstractSpecificPropertyHandler propertyHandler)
          Deprecated. prefer the use of the UsurperGeneratorSetup
 void replaceSetup(IUsurperGeneratorSetup usurperGeneratorSetup)
          This methods allows the replacement of the setup object.
 void setAllHandlers(java.util.Map<ITargetDefinition,IHandler> handlers)
          Deprecated. prefer the use of the UsurperGeneratorSetup
 void useConstructor(java.lang.Class<?>... constructorParameterTypes)
           
 void usePropertyWritingMechanism(PropertyWritingMechanism propertyWritingMechanism)
          Deprecated. prefer the use of the UsurperGeneratorSetup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UsurperGenerator

public UsurperGenerator(java.lang.Class<? extends T> usurpatedClass)
This constructor creates an UsurperGenerator for the given Bean class.
It creates a default UsurperGeneratorSetup.

Parameters:
usurpatedClass - the generated class
See Also:
UsurperGeneratorSetup

UsurperGenerator

public UsurperGenerator(java.lang.Class<? extends T> usurpatedClass,
                        OnMissingHandlers onMissingHandlers)
Deprecated. prefer the use of the UsurperGeneratorSetup if you need to override the default behaviour

This constructor is the same as the one-argument one, except that you can specify whether you want to ignore undefined handlers.
new UsurperGenerator<T>(Class<T> valueObjectClass, UsurperGenerator.SKIP_MISSING_HANDLERS)
or
new UsurperGenerator<T>(Class<T> valueObjectClass, UsurperGenerator.FAIL_ON_MISSING_HANDLERS)

Parameters:
valueObjectClass -
onMissingHandlers -

UsurperGenerator

public UsurperGenerator(java.lang.Class<? extends T> usurpatedClass,
                        IUsurperGeneratorSetup usurperGeneratorSetup)
This constructor creates an UsurperGenerator for the given Bean class.
It takes a specific UsurperGeneratorSetup as a parameter.

Parameters:
usurpatedClass - the generated class
See Also:
UsurperGeneratorSetup
Method Detail

generateUsurper

public T generateUsurper()
This method generates an usurper object of the type specified as Generic for the UsurperGenerator instance.

Returns:
an usurper object

generateUsurperList

public java.util.List<T> generateUsurperList(int number)
Utility method that generates a list of usurpers of the type specified as Generic for the UsurperGenerator instance.

Parameters:
number - the quantity of usurpers to be generated
Returns:
a List of usurpers.

generateUsurperSet

public java.util.Set<T> generateUsurperSet(int number)
Utility method that generates a list of usurpers of the type specified as Generic for the UsurperGenerator instance.

Parameters:
number - the quantity of usurpers to be generated
Returns:
a List of usurpers.

replaceSetup

public void replaceSetup(IUsurperGeneratorSetup usurperGeneratorSetup)
This methods allows the replacement of the setup object.

Parameters:
usurperGeneratorSetup -

getSetup

public ImmutableUsurperGeneratorSetup getSetup()
This methods returns the current setup object

Returns:
an immutable setup object

onMissingHandlers

public void onMissingHandlers(OnMissingHandlers onMissingHandlers)
Deprecated. prefer the use of the UsurperGeneratorSetup

Setter for the flag specifying if the undefined handlers must be ignored or trigger a failure.

Parameters:
onMissingHandlers - The value to set.
See Also:
OnMissingHandlers, UsurperGeneratorSetup

registerPropertyTypeHandler

public void registerPropertyTypeHandler(AbstractPropertyTypeHandler typeHandler)
Deprecated. prefer the use of the UsurperGeneratorSetup

This method allows the user to register a Handler for Properties of determinated java types.
Only one handler can be registered for a given java type at a time.
Registering a handler when one is already registered for a given type overrides the preceding one.

Parameters:
typeHandler - the handler to register (AbstractPropertyTypeHandler)
See Also:
UsurperGeneratorSetup

registerPropertyTypeHandlers

public void registerPropertyTypeHandlers(java.util.Set<AbstractPropertyTypeHandler> typeHandlers)
Deprecated. prefer the use of the UsurperGeneratorSetup

This method allows the user to register many Handlers for Properties of determinated java types.
Only one handler can be registered for a given java type at a time.
Registering a handler when one is already registered for a given type overrides the preceding one.

Parameters:
typeHandlers - the handler to register (Set<AbstractPropertyTypeHandler>)
See Also:
UsurperGeneratorSetup

hasPropertyTypeHandler

public boolean hasPropertyTypeHandler(java.lang.Class<?> type)
Deprecated. prefer the use of the UsurperGeneratorSetup

This method tests if a handler is registered for a given Java Type.

Parameters:
type - the java class of the type to test
Returns:
true if one is registered, false otherwise
See Also:
UsurperGeneratorSetup

getPropertyTypeHandler

public AbstractPropertyTypeHandler getPropertyTypeHandler(java.lang.Class<?> handledType)
Deprecated. prefer the use of the UsurperGeneratorSetup

This method retrieves the Handler for Properties of a given java type.

Parameters:
handledType - the java type
Returns:
the registered handler or null if none is defined.
See Also:
UsurperGeneratorSetup

registerSpecificPropertyHandler

public void registerSpecificPropertyHandler(AbstractSpecificPropertyHandler propertyHandler)
Deprecated. prefer the use of the UsurperGeneratorSetup

This method allows the user to register a Handler for a given property.
Only one handler can be registered for a given property at a time.
Registering a handler when one is already registered for a given property overrides the preceding one.

Parameters:
propertyHandler - the handler to register (AbstractSpecificPropertyHandler)
See Also:
UsurperGeneratorSetup

hasSpecificPropertyHandler

public boolean hasSpecificPropertyHandler(java.lang.Class<?> usurpatedClass,
                                          java.lang.String handledProperty)
Deprecated. prefer the use of the UsurperGeneratorSetup

This method tests if a handler is registered for a given Property of a given Class.

Parameters:
usurpatedClass -
handledProperty -
Returns:
true if one is registered, false otherwise
See Also:
UsurperGeneratorSetup

getSpecificPropertyHandler

public AbstractSpecificPropertyHandler getSpecificPropertyHandler(java.lang.Class<?> usurpatedClass,
                                                                  java.lang.String handledProperty)
Deprecated. prefer the use of the UsurperGeneratorSetup

This method retrieves the Handler for a given Property of a given Class.

Parameters:
usurpatedClass -
handledProperty -
Returns:
the registered property handler or null if none is defined.
See Also:
UsurperGeneratorSetup

getAllHandlers

public java.util.Map<ITargetDefinition,IHandler> getAllHandlers()
Deprecated. prefer the use of the UsurperGeneratorSetup

This methods return all the handlers.

Returns:
See Also:
UsurperGeneratorSetup

setAllHandlers

public void setAllHandlers(java.util.Map<ITargetDefinition,IHandler> handlers)
Deprecated. prefer the use of the UsurperGeneratorSetup

This methods sets handlers. The Map must contains pairs of : Otherwise, it will throw a ClassCastException.

Parameters:
handlers -
See Also:
UsurperGeneratorSetup

usePropertyWritingMechanism

public void usePropertyWritingMechanism(PropertyWritingMechanism propertyWritingMechanism)
Deprecated. prefer the use of the UsurperGeneratorSetup

Parameters:
propertyWritingMechanism -
See Also:
UsurperGeneratorSetup

useConstructor

public void useConstructor(java.lang.Class<?>... constructorParameterTypes)
Parameters:
constructorParameterTypes -


Copyright © 2008. All Rights Reserved.