way-auto-functional.IsPredicate.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 Predicate<{{{fromClass.rawName}}}> {
{{#method}}
{{#parametersIsEmpty}}
private static final Predicate<{{{fromClass.rawName}}}> INSTANCE = new {{fromClass.simpleName}}{{method.toClassName}}();
private static final Predicate<{{{fromClass.rawName}}}> NOT = new Not{{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 Predicate<{{{fromClass.rawName}}}> 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}}
}
public static Predicate<{{{fromClass.rawName}}}> not({{#method.parameters}}{{{parameter.declaration}}}{{^last}}, {{/last}}{{/method.parameters}}) {
{{#method}}
{{#parametersIsEmpty}}
return NOT;
{{/parametersIsEmpty}}
{{^parametersIsEmpty}}
return new Not{{fromClass.name}}{{toClassName}}({{#parameters}}{{parameter.name}}{{^last}}, {{/last}}{{/parameters}});
{{/parametersIsEmpty}}
{{/method}}
}
@Override
public boolean apply({{{fromClass.rawName}}} input) {
return input.{{method.name}}({{#method.parameters}}{{parameter.name}}{{^last}}, {{/last}}{{/method.parameters}});
}
}
@javax.annotation.Generated("br.com.objectos.way.auto.functional.AutoFunctionalProcessor")
final class Not{{fromClass.simpleName}}{{method.toClassName}} implements Predicate<{{{fromClass.rawName}}}> {
{{#method.parameters}}
{{#parameter}}
private final {{{declaration}}};
{{/parameter}}
{{#last}}
{{/last}}
{{/method.parameters}}
Not{{fromClass.simpleName}}{{method.toClassName}}({{#method.parameters}}{{{parameter.declaration}}}{{^last}}, {{/last}}{{/method.parameters}}) {
{{#method.parameters}}
this.{{parameter.name}} = {{parameter.name}};
{{/method.parameters}}
}
@Override
public boolean apply({{{fromClass.rawName}}} input) {
return !input.{{method.name}}({{#method.parameters}}{{parameter.name}}{{^last}}, {{/last}}{{/method.parameters}});
}
}