api-generator-templates/Java/Class.java.twig

62 lines
2.4 KiB
Twig

{%- set hasParent = parent is not null -%}
/**
* This code is autogenerated by Touch Instinct tools
*/
package TODO;
import com.bluelinelabs.logansquare.annotation.JsonObject;
import ru.touchin.templates.logansquare.LoganSquareJsonModel;
/**
* {{ description }}
*/
@JsonObject(serializeNullObjects = true)
public class {% include 'blocks/class/classtype.twig' with { type: type } %} extends {% include 'blocks/class/supertype.twig' with { type: type, parent: parent } %} {
{% include 'blocks/class/fields.twig' with { fields: fields } %}
public {{ type.baseTypeName }}() {
super();
}
{% if (allFieldsOrdered is not empty) %}
//TODO: if TItems instance of arrayList then new ArrayList
public {{ type.baseTypeName }}({%- include 'blocks/class/init-parameters-fields.twig' with { fields: allFieldsOrdered } -%}) {
super({%- include 'blocks/class/fields-super-initialization.twig' with { fields: superclassesFields } -%});
{%- include 'blocks/class/fields-initialization.twig' with { fields: fields, object: "this" } %}
}
{% endif %}
{%- include 'blocks/class/fields-getters-setters.twig' with { fields: fields } %}
{%- if parent is not null %}
@Override
{%- endif %}
protected void copyTo(@NonNull final {% include 'blocks/class/classtype.twig' with { type: type } %} destination) {
{%- if parent is not null %}
super.copyTo(destination);
{%- endif %}
{%- include 'blocks/class/fields-initialization.twig' with { fields: fields, object: "destination" } %}
}
@NonNull
public {% include 'blocks/class/classtype.twig' with { type: type } %} copy() {
final {% include 'blocks/class/classtype.twig' with { type: type } %} result = new {% include 'blocks/class/classtype.twig' with { type: type } %}();
this.copyTo(result);
return result;
}
public int hashCode() {
return ObjectUtils.hashCode({%- if parent is not null -%}super.hashCode(), {% endif -%}{%- include 'blocks/class/fields-super-initialization.twig' with { fields: fields } -%});
}
public boolean equals(@Nullable final Object object) {
if (this == object) {
return true;
}
if (object == null || getClass() != object.getClass()) {
return false;
}
final {% include 'blocks/class/classtype.twig' with { type: type } %} that = ({% include 'blocks/class/classtype.twig' with { type: type } %}) object;
return {% if parent is not null -%}super.equals(that)
&& {% endif -%}
{%- include 'blocks/class/fields-equals.twig' with { fields: fields } -%};
}
}