/* * This code is autogenerated by Touch Instinct tools */ package {{ packageName }}.api; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.util.ObjectsCompat; {%- if (storageAttributes is not null) %} import androidx.room.Delete; import androidx.room.Entity; import androidx.room.Insert; import androidx.room.OnConflictStrategy; import androidx.room.Query; import androidx.room.Transaction; import androidx.room.TypeConverter; import androidx.room.TypeConverters; import androidx.room.PrimaryKey; import androidx.room.Ignore; import io.reactivex.Flowable; import io.reactivex.Single; {%- endif %} import com.bluelinelabs.logansquare.LoganSquare; import com.bluelinelabs.logansquare.annotation.JsonField; import com.bluelinelabs.logansquare.annotation.JsonObject; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.math.BigDecimal; import java.util.List; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.HashMap; import org.joda.time.DateTime; import ru.touchin.templates.ApiModel; import ru.touchin.templates.logansquare.LoganSquareJsonModel; {%- if (description is not empty) %} /** * {{ description }} */ {%- endif %} {%- if (storageAttributes is not null) %} {%- set attributeWas = false %} @Entity( {%- if (storageAttributes.tableName is not null) -%} {%- set attributeWas = true -%} tableName = "{{ storageAttributes.tableName }}" {%- endif -%} {%- if attributeWas and storageAttributes.primaryKeys is not empty -%}, {% endif %} {%- if (storageAttributes.primaryKeys is not empty) -%} {%- set attributeWas = true -%} primaryKeys = { {%- for key in storageAttributes.primaryKeys -%} "{{- key -}}" {%- if not (loop.last) %}, {% endif -%} {%- endfor -%} } {%- endif -%} ) {%- set haveConverters = false -%} {%- for field in fields -%} {%- if (field.type.type.baseTypeName == "Array") or (field.type.type.baseTypeName == "Map") or (field.type.type.baseTypeName != "Bool" and field.type.type.baseTypeName != "Int" and field.type.type.baseTypeName != "Long" and field.type.type.baseTypeName != "Double" and field.type.type.baseTypeName != "String" and field.type.storable != true) %} {%- set haveConverters = true -%} {%- endif -%} {%- endfor -%} {%- if haveConverters %} @TypeConverters({{ type.baseTypeName }}.class) {%- endif -%} {%- endif %} @JsonObject(serializeNullObjects = {{ default(serializeNulls, false) }}) 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-converters.twig' -%} {% 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 {%- if (storageAttributes is not null) %} @Ignore {%- endif %} 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 } %} //TODO: add check for collection if TypeParameter //TODO: do not validate enums as ApiModel @Override public void validate() throws ValidationException { super.validate(); {%- include 'blocks/class/fields-validate.twig' with { fields: fields } %} } 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; } {%- if (fields is not empty) %} public int hashCode() { return ObjectsCompat.hash({%- 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 } -%}; } private void writeObject(@NonNull final ObjectOutputStream outputStream) throws IOException { {%- include 'blocks/class/fields-write-object.twig' with { fields: fields } %} } @SuppressWarnings("unchecked") private void readObject(@NonNull final ObjectInputStream inputStream) throws IOException, ClassNotFoundException { {%- include 'blocks/class/fields-read-object.twig' with { fields: fields } %} } {%- endif %} {%- include 'blocks/class/dao.twig' %} }