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

fluent.api.generator.templates.validation.check.jtwig Maven / Gradle / Ivy

There is a newer version: 2.18
Show newest version
{% set productType = defined(var) ? var.type : type %}
{% set packageName = (packageName == "") ? (defined(var) ? var.packageName : type.packageName) : packageName %}
{% set classSuffix = "Check" %}
{% set className = (className == "") ? concat(productType.simpleName, classSuffix) : className %}
{% set factoryMethod = (factoryMethod == "") ? concat(productType.simpleName, "With") : factoryMethod %}
{% set classParameters = empty(productType.parameterVariables) ? "" : concat("<", join(productType.parameterVariables, ", "), ">") %}
package {{ packageName }};
import javax.annotation.Generated;
import fluent.api.End;
import fluent.validation.Check;
import fluent.validation.CheckDsl;
import {{productType}};
import static fluent.validation.Checks.equalTo;


@Generated("Generated code using {{ templatePath }}")
public final class {{ className }}{% if not empty(productType.parameterVariables) %}<{% for t in productType.parameterVariables %}{% if loop.first %}{% else %}, {% endif %}{{ t.declaration }}{% endfor %}>{% endif %}
        extends CheckDsl<{{ className }}{{ classParameters }} , {{ productType.simpleName }}> {

    protected {{ className }}(Check check) {
        super(check, {{ className }}::new);
    }

    protected {{ className }}() {
        super({{ className }}::new);
    }

    public static {% if not empty(productType.parameterVariables) %}<{% for t in productType.parameterVariables %}{% if loop.first %}{% else %}, {% endif %}{{ t.declaration }}{% endfor %}>{% endif %} {{ className }}{{ classParameters }} {{ factoryMethod }}() {
        return new {{ className }}{% if not empty(productType.parameterVariables) %}<>{% endif %}();
    }
{% for getter in productType.methods %}{% if getter.name.matches(getterPattern) and getter.name != "getClass" and getter.parameters.size == 0 %}
{% set propertyName = getter.toProperty(getterPattern, getterNameGroup) %}
    public {{ className }}{{ classParameters }} {{ propertyName }}(Check value) {
        return withField("{{ propertyName }}", {{ productType.simpleName }}::{{ getter }}).matching(value);
    }

    public {{ className }}{{ classParameters }} {{ propertyName }}({{ getter.type }} value) {
        return {{ propertyName }}(equalTo(value));
    }
{% endif %}{% endfor %}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy