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