net.sf.qualitytest.blueprint.configuration
Class DefaultBlueprintConfiguration

java.lang.Object
  extended by net.sf.qualitytest.blueprint.configuration.DefaultBlueprintConfiguration
All Implemented Interfaces:
BlueprintConfiguration

public final class DefaultBlueprintConfiguration
extends Object

Default BlueprintConfiguration which assigns all primitive types and their corresponding object types which a default value, which is usually 0. Additionally, support for the interfaces java.util.List, java.util.Set and java.util.list is added. If these interface are encountered, empty lists, lists and sets are created.

Author:
Dominik Seichter

Constructor Summary
DefaultBlueprintConfiguration()
           
 
Method Summary
static void addDefaultArrayStrategy(List<net.sf.qualitytest.blueprint.configuration.StrategyPair> list)
          Add the default array handling to a list.
static void addDefaultCollections(List<net.sf.qualitytest.blueprint.configuration.StrategyPair> list)
          Add the default implementations for collection interfaces to a list.
static void addDefaultEnumStrategy(List<net.sf.qualitytest.blueprint.configuration.StrategyPair> list)
          Add the default enum handling to a list.
<T> T
construct(Class<T> clazz)
          Construct a Java-Object using a class as a blueprint.
 CreationStrategy<?> findCreationStrategyForField(Field field)
          Find a creation strategy that matches on the given field.
 CreationStrategy<?> findCreationStrategyForMethod(Method method)
          Find a creation strategy that matches on the given method.
 CreationStrategy<?> findCreationStrategyForType(Class<?> clazz)
          Find a creation strategy that matches on a given type.
<T> T
handleCycle(BlueprintSession session, Class<T> clazz)
          Handle the situation that a BlueprintCycle was detected for a particular class.
 boolean isWithPublicAttributes()
          Retrieve if public attributes are filled during blueprinting.
<T> BlueprintConfiguration
with(Class<T> type, CreationStrategy<?> creator)
          Replace every attribute with the type type with a given value.
<T> BlueprintConfiguration
with(Class<T> type, T value)
          Replace every attribute with the type type with a given value.
<T> BlueprintConfiguration
with(CycleHandlingStrategy<T> cycleHandlingStrategy)
          Handle detected cycles in the blueprinting graph using an additional strategy.
<T> BlueprintConfiguration
with(MatchingStrategy matchingStrategy)
          Blueprint everything matching a given MatchingStrategy using this configuration.
 BlueprintConfiguration with(MatchingStrategy matcher, CreationStrategy<?> creator)
          Replace every attribute which matches a given strategy with a given value.
<T> BlueprintConfiguration
with(String name, T value)
          Replace every attribute with the name name with a given value.
 BlueprintConfiguration withPublicAttributes(boolean withPublicAttributes)
          Configure whether public attributes should be filled with values during blueprinting.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultBlueprintConfiguration

public DefaultBlueprintConfiguration()
Method Detail

addDefaultArrayStrategy

public static void addDefaultArrayStrategy(List<net.sf.qualitytest.blueprint.configuration.StrategyPair> list)
Add the default array handling to a list.

Parameters:
list -

addDefaultCollections

public static void addDefaultCollections(List<net.sf.qualitytest.blueprint.configuration.StrategyPair> list)
Add the default implementations for collection interfaces to a list.

Parameters:
list -

addDefaultEnumStrategy

public static void addDefaultEnumStrategy(List<net.sf.qualitytest.blueprint.configuration.StrategyPair> list)
Add the default enum handling to a list.

Parameters:
list -

construct

@Nullable
public <T> T construct(@Nonnull
                                Class<T> clazz)
Description copied from interface: BlueprintConfiguration
Construct a Java-Object using a class as a blueprint.

Specified by:
construct in interface BlueprintConfiguration
Parameters:
clazz - a class
Returns:
a blue printed instance of T
See Also:
Blueprint

findCreationStrategyForField

@Nullable
public CreationStrategy<?> findCreationStrategyForField(@Nonnull
                                                                 Field field)
Description copied from interface: BlueprintConfiguration
Find a creation strategy that matches on the given field.

Specified by:
findCreationStrategyForField in interface BlueprintConfiguration
Parameters:
field - A field
Returns:
a ValueCreationStrategy or null

findCreationStrategyForMethod

@Nullable
public CreationStrategy<?> findCreationStrategyForMethod(@Nonnull
                                                                  Method method)
Description copied from interface: BlueprintConfiguration
Find a creation strategy that matches on the given method.

Specified by:
findCreationStrategyForMethod in interface BlueprintConfiguration
Parameters:
method - A setter method
Returns:
a ValueCreationStrategy or null

findCreationStrategyForType

@Nullable
public CreationStrategy<?> findCreationStrategyForType(@Nonnull
                                                                Class<?> clazz)
Description copied from interface: BlueprintConfiguration
Find a creation strategy that matches on a given type.

Specified by:
findCreationStrategyForType in interface BlueprintConfiguration
Returns:
a ValueCreationStrategy or null

handleCycle

@Nullable
public <T> T handleCycle(@Nonnull
                                  BlueprintSession session,
                                  @Nonnull
                                  Class<T> clazz)
Description copied from interface: BlueprintConfiguration
Handle the situation that a BlueprintCycle was detected for a particular class.

Specified by:
handleCycle in interface BlueprintConfiguration
Parameters:
session - The current BlueprintSession
clazz - The class which caused cycle in the blueprinting graph
Returns:
a blue printed instance of T
See Also:
Blueprint

isWithPublicAttributes

public boolean isWithPublicAttributes()
Description copied from interface: BlueprintConfiguration
Retrieve if public attributes are filled during blueprinting.

Specified by:
isWithPublicAttributes in interface BlueprintConfiguration
Returns:
true if public attributes are filled during blueprinting

with

@Nonnull
public <T> BlueprintConfiguration with(@Nonnull
                                               Class<T> type,
                                               @Nullable
                                               CreationStrategy<?> creator)
Description copied from interface: BlueprintConfiguration
Replace every attribute with the type type with a given value.

Specified by:
with in interface BlueprintConfiguration
Parameters:
type - a Java type.
creator - Creation strategy which actually creates a new value.
Returns:
the changed blueprint configuration.

with

@Nonnull
public <T> BlueprintConfiguration with(@Nonnull
                                               Class<T> type,
                                               @Nullable
                                               T value)
Description copied from interface: BlueprintConfiguration
Replace every attribute with the type type with a given value.

Specified by:
with in interface BlueprintConfiguration
Parameters:
type - a Java type.
value - value which should be assigned to the attribute
Returns:
the changed blueprint configuration.

with

@Nonnull
public <T> BlueprintConfiguration with(@Nonnull
                                               CycleHandlingStrategy<T> cycleHandlingStrategy)
Description copied from interface: BlueprintConfiguration
Handle detected cycles in the blueprinting graph using an additional strategy. The default is to throw a BlueprintCycleException.

Specified by:
with in interface BlueprintConfiguration
Parameters:
cycleHandlingStrategy - Strategy to define how cycles for a certain type are handled
Returns:
the changed blueprint configuration

with

@Nonnull
public <T> BlueprintConfiguration with(@Nonnull
                                               MatchingStrategy matchingStrategy)
Description copied from interface: BlueprintConfiguration
Blueprint everything matching a given MatchingStrategy using this configuration.

Specified by:
with in interface BlueprintConfiguration
Parameters:
matchingStrategy - Matching strategy to define if a given type or method should be constructed using blueprint.
Returns:
the changed blueprint configuration

with

@Nonnull
public BlueprintConfiguration with(@Nonnull
                                           MatchingStrategy matcher,
                                           @Nonnull
                                           CreationStrategy<?> creator)
Description copied from interface: BlueprintConfiguration
Replace every attribute which matches a given strategy with a given value.

Specified by:
with in interface BlueprintConfiguration
Parameters:
matcher - Matching strategy to define if the replaced should be applied.
creator - Creation strategy which actually creates a new value.
Returns:
the changed blueprint configuration.

with

@Nonnull
public <T> BlueprintConfiguration with(@Nonnull
                                               String name,
                                               @Nullable
                                               T value)
Description copied from interface: BlueprintConfiguration
Replace every attribute with the name name with a given value.

Specified by:
with in interface BlueprintConfiguration
Parameters:
name - case insensitive name of an attribute.
value - value which should be assigned to the attribute
Returns:
the changed blueprint configuration.

withPublicAttributes

@Nonnull
public BlueprintConfiguration withPublicAttributes(boolean withPublicAttributes)
Description copied from interface: BlueprintConfiguration
Configure whether public attributes should be filled with values during blueprinting.

Specified by:
withPublicAttributes in interface BlueprintConfiguration
Parameters:
withPublicAttributes - if true public attributes will be filled during blueprinting, otherwise they will be ignored.
Returns:
the changed blueprint configuration.


Copyright © 2012-2013. All Rights Reserved.