Class Registration<S,T>
- java.lang.Object
-
- org.palladiosimulator.textual.commons.generator.rules.impl.Registration<S,T>
-
- All Implemented Interfaces:
ExecutableRule<S,T>
public class Registration<S,T> extends Object implements ExecutableRule<S,T>
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.boolean
appliesTo(Object instance, Class<?> target)
Tests whether this registration can be used to transform the given source object into the given target type.void
applyTo(S source, T target, GeneratorTransformationRegistry registry)
Applies the complete transformation of the source to the configured target type.<U,V>
booleanconflictsWith(ExecutableRule<U,V> conflictCandidate)
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.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
-
appliesTo
public boolean appliesTo(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).- Specified by:
appliesTo
in interfaceExecutableRule<S,T>
- 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 void applyTo(S source, T target, GeneratorTransformationRegistry registry)
Applies the complete transformation of the source to the configured target type.- Specified by:
applyTo
in interfaceExecutableRule<S,T>
- Parameters:
source
- The source object to transform.registry
- The registry to use for resolving possible transformations of child elements.
-
conflictsWith
public <U,V> boolean conflictsWith(ExecutableRule<U,V> conflictCandidate)
- Specified by:
conflictsWith
in interfaceExecutableRule<S,T>
-
-