All Downloads are FREE. Search and download functionalities are using the official Maven repository.

way-auto-functional.ToFunction.mustache Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
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}});
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy