net.sf.qualitytest.blueprint
Interface BlueprintConfiguration

All Known Implementing Classes:
DefaultBlueprintConfiguration, RandomBlueprintConfiguration

public interface BlueprintConfiguration

Defines a blueprint configuration

Author:
André Rouél

Method Summary
<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.
 

Method Detail

construct

@Nullable
<T> T construct(@Nonnull
                         Class<T> clazz)
Construct a Java-Object using a class as a blueprint.

Type Parameters:
T -
Parameters:
clazz - a class
Returns:
a blue printed instance of T
See Also:
Blueprint

findCreationStrategyForField

@Nullable
CreationStrategy<?> findCreationStrategyForField(@Nonnull
                                                          Field field)
Find a creation strategy that matches on the given field.

Parameters:
field - A field
Returns:
a ValueCreationStrategy or null

findCreationStrategyForMethod

@Nullable
CreationStrategy<?> findCreationStrategyForMethod(@Nonnull
                                                           Method method)
Find a creation strategy that matches on the given method.

Parameters:
method - A setter method
Returns:
a ValueCreationStrategy or null

findCreationStrategyForType

@Nullable
CreationStrategy<?> findCreationStrategyForType(@Nonnull
                                                         Class<?> clazz)
Find a creation strategy that matches on a given type.

Parameters:
class - A class
Returns:
a ValueCreationStrategy or null

handleCycle

@Nullable
<T> T handleCycle(@Nonnull
                           BlueprintSession session,
                           @Nonnull
                           Class<T> clazz)
Handle the situation that a BlueprintCycle was detected for a particular class.

Type Parameters:
T -
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

boolean isWithPublicAttributes()
Retrieve if public attributes are filled during blueprinting.

Returns:
true if public attributes are filled during blueprinting

with

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

Parameters:
type - a Java type.
creator - Creation strategy which actually creates a new value.
Returns:
the changed blueprint configuration.

with

@Nonnull
<T> BlueprintConfiguration with(@Nonnull
                                        Class<T> type,
                                        @Nullable
                                        T value)
Replace every attribute with the type type with a given value.

Parameters:
type - a Java type.
value - value which should be assigned to the attribute
Returns:
the changed blueprint configuration.

with

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

Parameters:
cycleHandlingStrategy - Strategy to define how cycles for a certain type are handled
Returns:
the changed blueprint configuration

with

@Nonnull
<T> BlueprintConfiguration with(@Nonnull
                                        MatchingStrategy matchingStrategy)
Blueprint everything matching a given MatchingStrategy using this configuration.

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

with

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

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
<T> BlueprintConfiguration with(@Nonnull
                                        String name,
                                        @Nullable
                                        T value)
Replace every attribute with the name name with a given value.

Parameters:
name - case insensitive name of an attribute.
value - value which should be assigned to the attribute
Returns:
the changed blueprint configuration.

withPublicAttributes

@Nonnull
BlueprintConfiguration withPublicAttributes(boolean withPublicAttributes)
Configure whether public attributes should be filled with values during blueprinting.

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.