
templates.java.ingredient-data.liquid Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of recipe-generator Show documentation
Show all versions of recipe-generator Show documentation
Generates ingredients and implementation hooks for the Recipe framework
{%- if ingredient.keyed -%}
{%- assign superclass = 'KeyedIngredientSnapshot' -%}
{%- else -%}
{%- assign superclass = 'IngredientSnapshot' -%}
{%- endif -%}
{%- if options.javaPackage != "" -%}
package {{options.javaPackage}};
{% endif %}
{%- assign dataClassName = ingredient.name | append: 'Data' -%}
import ca.derekcormier.recipe.{{superclass}};
public class {{dataClassName}} extends {{superclass}} {
public {{dataClassName}}() {
super("{{ingredient.name}}");
}
{%- for required in ingredient.required %}
public {{required.type | javatype:true}} {% if required.type != 'boolean' %}get{% else %}is{% endif %}{{required.name | capitalize}}() {
return getProperty("{{required.name}}");
}
public void set{{required.name | capitalize}}({{required.type | javatype}} {{required.name}}) {
setProperty("{{required.name}}", {{required.name}});
}
{%- endfor %}
{%- for optional in ingredient.optionals %}
public boolean has{{optional.name | capitalize}}() {
return hasProperty("{{optional.name}}");
}
{%- if optional.compound != true %}
public {{optional.type | javatype:true}}{% if optional.repeatable == true %}[]{% endif %} {% if optional.type != 'boolean' and optional.type != 'flag' %}get{% else %}is{% endif %}{{optional.name | capitalize}}() {
return getProperty({{optional.type | javatype:true}}{% if optional.repeatable == true %}[]{% endif %}.class, "{{optional.name}}");
}
public void set{{optional.name | capitalize}}({{optional.type | javatype:true}}{% if optional.repeatable == true %}[]{% endif %} {{optional.name}}) {
setProperty("{{optional.name}}", {{optional.name}});
}
{%- else -%}
public {{optional.name | capitalize}}Params{% if optional.repeatable == true %}[]{% endif %} get{{optional.name | capitalize}}() {
return getProperty({{optional.name | capitalize}}Params{% if optional.repeatable == true %}[]{% endif %}.class, "{{optional.name}}");
}
public void set{{optional.name | capitalize}}({{optional.name | capitalize}}Params{% if optional.repeatable == true %}[]{% endif %} {{optional.name}}) {
setProperty("{{optional.name}}", {{optional.name}});
}
{% endif %}
{%- endfor %}
{%- for optional in ingredient.optionals %}
{%- if optional.compound %}
public static class {{optional.name | capitalize}}Params {
{%- for param in optional.params %}
public {{param.type | javatype:true}} {{param.name}};
{%- endfor %}
}{%- endif %}
{%- endfor %}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy