Class 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.
    • Constructor Detail

      • Registration

        public Registration​(Class<S> source,
                            Class<T> target)
    • Method Detail

      • getSourceType

        public Class<S> getSourceType()
      • getTargetType

        public Class<T> getTargetType()
      • 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 interface ExecutableRule<S,​T>
        Parameters:
        instance - The object instance to check the transformation for
        target - 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 interface ExecutableRule<S,​T>
        Parameters:
        source - The source object to transform.
        registry - The registry to use for resolving possible transformations of child elements.