-
- Type Parameters:
F- the model to generate fromT- 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 Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleanis(Class<? extends Transform<?,?>> transformer)Returns true if this transform is or contains the specified transformer.Optional<T>transform(Generator gen, F model)Transforms a model from one type to another.
-
-
-
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 returnempty.This method is not meant to be called outside the code generator. If you want to transform between different types, setup a
Generator, install theTransformin the factory and call one of theon()-methods inGenerator.- Parameters:
gen- a reference to the generator being usedmodel- 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
-
-