Class GeneratorTransformationRegistryImpl
- java.lang.Object
-
- org.palladiosimulator.textual.commons.generator.registry.impl.GeneratorTransformationRegistryImpl
-
- All Implemented Interfaces:
GeneratorRuleRegistrationFacade
,GeneratorTransformationRegistry
public class GeneratorTransformationRegistryImpl extends Object implements GeneratorTransformationRegistry, GeneratorRuleRegistrationFacade
-
-
Constructor Summary
Constructors Constructor Description GeneratorTransformationRegistryImpl(MultiModelGeneratorFragmentCollector providerCollector)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <S,T>
voidconfigure(Class<S> source, Class<T> target, Consumer<GeneratorRuleBuilder<S,T>> mapping)
Defines a new transformation from source to target.Object
map(Object source)
Executes a transformation on the given object.<S,T>
Tmap(S source, Class<T> target)
Executes a transformation on the given object.void
withContext(Runnable runnable)
Creates a context in which one can run multiple transformations.void
withContext(Collection<ProvidedMapping> provided, Runnable runnable)
Creates a context in which one can run multiple transformations.
-
-
-
Constructor Detail
-
GeneratorTransformationRegistryImpl
@Inject public GeneratorTransformationRegistryImpl(MultiModelGeneratorFragmentCollector providerCollector)
-
-
Method Detail
-
map
public Object map(Object source)
Description copied from interface:GeneratorTransformationRegistry
Executes a transformation on the given object. This will use the first matching transformation that was configured using configure().- Specified by:
map
in interfaceGeneratorTransformationRegistry
- Parameters:
source
- The object to transform- Returns:
- The result of the transformation
-
withContext
public void withContext(Runnable runnable)
Description copied from interface:GeneratorTransformationRegistry
Creates a context in which one can run multiple transformations. Inside this context, transformed objects will be cached and reused. Once a context is over, this cache will be emptied, thus resulting in new objects being created.- Specified by:
withContext
in interfaceGeneratorTransformationRegistry
- Parameters:
runnable
- Callback for running the transformations
-
withContext
public void withContext(Collection<ProvidedMapping> provided, Runnable runnable)
Description copied from interface:GeneratorTransformationRegistry
Creates a context in which one can run multiple transformations. Inside this context, transformed objects will be cached and reused. Once a context is over, this cache will be emptied, thus resulting in new objects being created. Additionally, this allows for providing a set of already finished transformations that will be inserted into the cache. This can be used to inject predefined references to objects for given objects. Similarly, these will also be cleared once the context is over.- Specified by:
withContext
in interfaceGeneratorTransformationRegistry
- Parameters:
provided
- Predefined set of transformations that should be inserted into the contextrunnable
- Callback for running the transformations
-
configure
public <S,T> void configure(Class<S> source, Class<T> target, Consumer<GeneratorRuleBuilder<S,T>> mapping)
Description copied from interface:GeneratorRuleRegistrationFacade
Defines a new transformation from source to target.- Specified by:
configure
in interfaceGeneratorRuleRegistrationFacade
- Parameters:
source
- The source typetarget
- The target typemapping
- A callback that configures this transformation.- See Also:
how to configure the registration
-
map
public <S,T> T map(S source, Class<T> target)
Description copied from interface:GeneratorTransformationRegistry
Executes a transformation on the given object. This, in comparison to map(S), makes sure that the type of the target is the provided type. This is necessary if there are two transformations configured for the same source but with different targets.- Specified by:
map
in interfaceGeneratorTransformationRegistry
- Parameters:
source
- The object to transformtarget
- The specific type of the target- Returns:
- The result of the transformation
-
-