Class Registration<S,T>
- java.lang.Object
-
- org.palladiosimulator.textual.tpcm.generator.Registration<S,T>
-
public class Registration<S,T> extends Object
A registration denotes a registered transformation of an object of type A to an object of type B. This registration also contains all the necessary instructions for when a transformation should happen (what is called a "predicate" here), how the target is created as well as all what transformation steps need to happen.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addPropertyMapping(ChildPropertyMapping<S,T> mapping)
Adds a transformation for a child property of the source object.T
applyTo(S source, GeneratorTransformationRegistry registry)
Applies the complete transformation of the source to the configured target type.T
create(S source)
Creates the target object from the source object using the configured factory.boolean
doesMap(Object instance)
Tests whether this registration can be used to transform the given source object.boolean
doesMap(Object instance, Class<?> target)
Tests whether this registration can be used to transform the given source object into the given target type.Class<S>
getSourceType()
Class<T>
getTargetType()
boolean
hasFactory()
boolean
hasPredicate()
Checks whether the registration has a predicate.Consumer<T>
setCallback(Consumer<T> callback)
Function<S,T>
setFactory(Function<S,T> factory)
Predicate<S>
setPredicate(Predicate<S> pred)
-
-
-
Method Detail
-
doesMap
public boolean doesMap(Object instance)
Tests whether this registration can be used to transform the given source object.- Parameters:
instance
- The object instance to check the mapping for
-
doesMap
public boolean doesMap(Object instance, Class<?> target)
Tests whether this registration can be used to transform the given source object into the given target type. If the target type is null, this behaves the same as doesMap(Object).- Parameters:
instance
- The object instance to check the transformation fortarget
- The desired resulting type of the transformation- See Also:
doesMap(Object)
-
hasPredicate
public boolean hasPredicate()
Checks whether the registration has a predicate.
-
hasFactory
public boolean hasFactory()
-
create
public T create(S source)
Creates the target object from the source object using the configured factory.- See Also:
setFactory(Function)
-
addPropertyMapping
public boolean addPropertyMapping(ChildPropertyMapping<S,T> mapping)
Adds a transformation for a child property of the source object.
-
applyTo
public T applyTo(S source, GeneratorTransformationRegistry registry)
Applies the complete transformation of the source to the configured target type.- Parameters:
source
- The source object to transform.registry
- The registry to use for resolving possible transformations of child elements.- Returns:
- The transformed target object.
-
-