Interface Transform<F,​T>

  • Type Parameters:
    F - the model to generate from
    T - the resulting model
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface Transform<F,​T>
    Transforms must have a public constructor with no parameters so that it can be instantiated dynamically.
    Since:
    2.0
    Author:
    Emil Forslund
    • Method Detail

      • transform

        Optional<T> transform​(Generator gen,
                              F model)
        Transforms a model from one type to another. A reference to the current code generator is supplied so that intermediate generation processes can be initiated to resolve dependencies. The transform can choose not to accept a particular input and therefore return empty.

        This method is not meant to be called outside the code generator. If you want to transform between different types, setup a Generator, install the Transform in the factory and call one of the on()-methods in Generator.

        Parameters:
        gen - a reference to the generator being used
        model - the model to transform
        Returns:
        the transformed model or empty if the transformation could not be done for that input
      • is

        default boolean is​(Class<? extends Transform<?,​?>> transformer)
        Returns true if this transform is or contains the specified transformer. This is used internally by the code generator to avoid circular paths.
        Parameters:
        transformer - the type of the transformer to check
        Returns:
        true if this transform is or contains the input