Class NamedMappingTransformer<T>

  • Type Parameters:
    T - The type of object to transform the mapping into.
    All Implemented Interfaces:
    IMappingTransformer<T>

    public class NamedMappingTransformer<T>
    extends Object
    implements IMappingTransformer<T>
    A mapping transformer that has a string representation. This class merely wraps an existing transformer. It is mostly intended for debugging, so that transformers created using lambda functions can still be displayed in a readable form.

    Example, for a transformer that produces basic string representations of mappings:

     IMappingTransformer<String> myTransformer = new NamedMappingTransformer<String>("mapping-to-string",
             (mapping) -> String.format("%s -[%s]-> %s", mapping.getSubjectId(), mapping.getPredicateId(),
                     mapping.getObjectId()));
     
    • Constructor Detail

      • NamedMappingTransformer

        public NamedMappingTransformer​(String name,
                                       IMappingTransformer<T> transformer)
        Creates a new instance.
        Parameters:
        name - A string representation of the transformer.
        transformer - The actual transformer.
    • Method Detail

      • transform

        public T transform​(Mapping mapping)
        Description copied from interface: IMappingTransformer
        Transform a mapping into something else.
        Specified by:
        transform in interface IMappingTransformer<T>
        Parameters:
        mapping - The mapping to transform.
        Returns:
        The object generated from the mapping.