package io.trygvis.persistence; import io.trygvis.container.compiler.model.TypeRef; import java.util.ArrayList; import java.util.List; public class EntityMirror implements Comparable { public final GeneratorConfiguration generatorConfiguration; public final List fields = new ArrayList<>(); public final List idFields = new ArrayList<>(); public final TypeRef type; public final String tableName; public final TypeRef rowType; public final TypeRef daoType; public final TypeRef utilsType; public TypeRef idType; public EntityMirror(GeneratorConfiguration generatorConfiguration, TypeRef type, String tableName) { this.generatorConfiguration = generatorConfiguration; this.type = type; this.tableName = tableName; this.rowType = new TypeRef(type.plainName + "Row"); this.daoType = new TypeRef(type.plainName + "Dao").args(type.args); this.utilsType = new TypeRef(type.plainName + "Dao.Utils").args(type.args); } public void add(FieldMirror... fields) { for (FieldMirror field : fields) { this.fields.add(field); if (field.id) { this.idFields.add(field); } } } public void setIdType(TypeRef idType) { this.idType = idType; } public FieldMirror getIdField() { return idFields.get(0); } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof EntityMirror)) return false; EntityMirror that = (EntityMirror) o; return type.equals(that.type); } @Override public int hashCode() { return type.hashCode(); } @Override public int compareTo(@SuppressWarnings("NullableProblems") EntityMirror o) { return type.compareTo(o.type); } }