|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.qualitytest.blueprint.configuration.DefaultBlueprintConfiguration
public final class DefaultBlueprintConfiguration
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.
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. |
|
|
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. |
|
|
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. |
|
|
with(Class<T> type,
CreationStrategy<?> creator)
Replace every attribute with the type type with a given value. |
|
|
with(Class<T> type,
T value)
Replace every attribute with the type type with a given value. |
|
|
with(CycleHandlingStrategy<T> cycleHandlingStrategy)
Handle detected cycles in the blueprinting graph using an additional strategy. |
|
|
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. |
|
|
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 |
---|
public DefaultBlueprintConfiguration()
Method Detail |
---|
public static void addDefaultArrayStrategy(List<net.sf.qualitytest.blueprint.configuration.StrategyPair> list)
list
- public static void addDefaultCollections(List<net.sf.qualitytest.blueprint.configuration.StrategyPair> list)
list
- public static void addDefaultEnumStrategy(List<net.sf.qualitytest.blueprint.configuration.StrategyPair> list)
list
- @Nullable public <T> T construct(@Nonnull Class<T> clazz)
BlueprintConfiguration
construct
in interface BlueprintConfiguration
clazz
- a class
T
Blueprint
@Nullable public CreationStrategy<?> findCreationStrategyForField(@Nonnull Field field)
BlueprintConfiguration
findCreationStrategyForField
in interface BlueprintConfiguration
field
- A field
ValueCreationStrategy
or null
@Nullable public CreationStrategy<?> findCreationStrategyForMethod(@Nonnull Method method)
BlueprintConfiguration
findCreationStrategyForMethod
in interface BlueprintConfiguration
method
- A setter method
ValueCreationStrategy
or null
@Nullable public CreationStrategy<?> findCreationStrategyForType(@Nonnull Class<?> clazz)
BlueprintConfiguration
findCreationStrategyForType
in interface BlueprintConfiguration
ValueCreationStrategy
or null
@Nullable public <T> T handleCycle(@Nonnull BlueprintSession session, @Nonnull Class<T> clazz)
BlueprintConfiguration
handleCycle
in interface BlueprintConfiguration
session
- The current BlueprintSession
clazz
- The class which caused cycle in the blueprinting graph
T
Blueprint
public boolean isWithPublicAttributes()
BlueprintConfiguration
isWithPublicAttributes
in interface BlueprintConfiguration
true
if public attributes are filled during blueprinting@Nonnull public <T> BlueprintConfiguration with(@Nonnull Class<T> type, @Nullable CreationStrategy<?> creator)
BlueprintConfiguration
type
with a given value.
with
in interface BlueprintConfiguration
type
- a Java type.creator
- Creation strategy which actually creates a new value.
@Nonnull public <T> BlueprintConfiguration with(@Nonnull Class<T> type, @Nullable T value)
BlueprintConfiguration
type
with a given value.
with
in interface BlueprintConfiguration
type
- a Java type.value
- value which should be assigned to the attribute
@Nonnull public <T> BlueprintConfiguration with(@Nonnull CycleHandlingStrategy<T> cycleHandlingStrategy)
BlueprintConfiguration
BlueprintCycleException
.
with
in interface BlueprintConfiguration
cycleHandlingStrategy
- Strategy to define how cycles for a certain type are handled
@Nonnull public <T> BlueprintConfiguration with(@Nonnull MatchingStrategy matchingStrategy)
BlueprintConfiguration
MatchingStrategy
using this configuration.
with
in interface BlueprintConfiguration
matchingStrategy
- Matching strategy to define if a given type or method should be constructed using blueprint.
@Nonnull public BlueprintConfiguration with(@Nonnull MatchingStrategy matcher, @Nonnull CreationStrategy<?> creator)
BlueprintConfiguration
with
in interface BlueprintConfiguration
matcher
- Matching strategy to define if the replaced should be applied.creator
- Creation strategy which actually creates a new value.
@Nonnull public <T> BlueprintConfiguration with(@Nonnull String name, @Nullable T value)
BlueprintConfiguration
name
with a given value.
with
in interface BlueprintConfiguration
name
- case insensitive name of an attribute.value
- value which should be assigned to the attribute
@Nonnull public BlueprintConfiguration withPublicAttributes(boolean withPublicAttributes)
BlueprintConfiguration
withPublicAttributes
in interface BlueprintConfiguration
withPublicAttributes
- if true
public attributes will be filled during blueprinting, otherwise they will be ignored.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |