way-auto-functional.ToFunction.mustache Maven / Gradle / Ivy
package {{fromClass.package.name}};
{{#imports}}
import {{qualifiedName}};
{{/imports}}
@javax.annotation.Generated("br.com.objectos.way.auto.functional.AutoFunctionalProcessor")
public final class {{fromClass.simpleName}}{{method.toClassName}} implements Function<{{{fromClass.rawName}}}, {{{toClass.name}}}> {
{{#method}}
{{#parametersIsEmpty}}
private static final Function<{{{fromClass.rawName}}}, {{{toClass.name}}}> INSTANCE = new {{fromClass.simpleName}}{{method.toClassName}}();
{{/parametersIsEmpty}}
{{/method}}
{{#method.parameters}}
{{#parameter}}
private final {{{declaration}}};
{{/parameter}}
{{#last}}
{{/last}}
{{/method.parameters}}
private {{fromClass.simpleName}}{{method.toClassName}}({{#method.parameters}}{{{parameter.declaration}}}{{^last}}, {{/last}}{{/method.parameters}}) {
{{#method.parameters}}
this.{{parameter.name}} = {{parameter.name}};
{{/method.parameters}}
}
public static Function<{{{fromClass.rawName}}}, {{{toClass.name}}}> get({{#method.parameters}}{{{parameter.declaration}}}{{^last}}, {{/last}}{{/method.parameters}}) {
{{#method}}
{{#parametersIsEmpty}}
return INSTANCE;
{{/parametersIsEmpty}}
{{^parametersIsEmpty}}
return new {{fromClass.name}}{{toClassName}}({{#parameters}}{{parameter.name}}{{^last}}, {{/last}}{{/parameters}});
{{/parametersIsEmpty}}
{{/method}}
}
@Override
public {{{toClass.name}}} apply({{{fromClass.rawName}}} input) {
return input.{{method.name}}({{#method.parameters}}{{parameter.name}}{{^last}}, {{/last}}{{/method.parameters}});
}
}