org.nuiton.topia.it.mapping.TopiaItMappingEntityEnum Maven / Gradle / Ivy
package org.nuiton.topia.it.mapping;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import java.lang.reflect.Array;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Generated;
import org.apache.commons.lang3.ArrayUtils;
import org.nuiton.topia.it.mapping.test1.A1;
import org.nuiton.topia.it.mapping.test1.A11;
import org.nuiton.topia.it.mapping.test1.A12;
import org.nuiton.topia.it.mapping.test1.A13;
import org.nuiton.topia.it.mapping.test1.B1;
import org.nuiton.topia.it.mapping.test1.B11;
import org.nuiton.topia.it.mapping.test1.B12;
import org.nuiton.topia.it.mapping.test1.B13;
import org.nuiton.topia.it.mapping.test11.A11A;
import org.nuiton.topia.it.mapping.test11.A11B;
import org.nuiton.topia.it.mapping.test11.A11C;
import org.nuiton.topia.it.mapping.test11.A11D;
import org.nuiton.topia.it.mapping.test11.A11E;
import org.nuiton.topia.it.mapping.test11.B11A;
import org.nuiton.topia.it.mapping.test11.B11B;
import org.nuiton.topia.it.mapping.test11.B11C;
import org.nuiton.topia.it.mapping.test11.B11D;
import org.nuiton.topia.it.mapping.test12.A12A;
import org.nuiton.topia.it.mapping.test13.A13A;
import org.nuiton.topia.it.mapping.test13.B13A;
import org.nuiton.topia.it.mapping.test13.B13B;
import org.nuiton.topia.it.mapping.test13.B13C;
import org.nuiton.topia.it.mapping.test14.A14A;
import org.nuiton.topia.it.mapping.test14.A14B;
import org.nuiton.topia.it.mapping.test14.A14C;
import org.nuiton.topia.it.mapping.test14.A14D;
import org.nuiton.topia.it.mapping.test14.Assoc14A;
import org.nuiton.topia.it.mapping.test14.Assoc14B;
import org.nuiton.topia.it.mapping.test14.Assoc14C;
import org.nuiton.topia.it.mapping.test14.Assoc14D;
import org.nuiton.topia.it.mapping.test14.B14A;
import org.nuiton.topia.it.mapping.test14.B14B;
import org.nuiton.topia.it.mapping.test14.B14C;
import org.nuiton.topia.it.mapping.test14.B14D;
import org.nuiton.topia.it.mapping.test15.A15A;
import org.nuiton.topia.it.mapping.test16.A16;
import org.nuiton.topia.it.mapping.test16.B16;
import org.nuiton.topia.it.mapping.test16.C16;
import org.nuiton.topia.it.mapping.test17.A17;
import org.nuiton.topia.it.mapping.test17.B17;
import org.nuiton.topia.it.mapping.test17.BB17;
import org.nuiton.topia.it.mapping.test18.A18;
import org.nuiton.topia.it.mapping.test18.B18;
import org.nuiton.topia.it.mapping.test2.A2;
import org.nuiton.topia.it.mapping.test2.A21;
import org.nuiton.topia.it.mapping.test2.A22;
import org.nuiton.topia.it.mapping.test2.A23;
import org.nuiton.topia.it.mapping.test2.B2;
import org.nuiton.topia.it.mapping.test2.B21;
import org.nuiton.topia.it.mapping.test2.B22;
import org.nuiton.topia.it.mapping.test2.B23;
import org.nuiton.topia.it.mapping.test3.A3;
import org.nuiton.topia.it.mapping.test3.A31;
import org.nuiton.topia.it.mapping.test3.A32;
import org.nuiton.topia.it.mapping.test3.A33;
import org.nuiton.topia.it.mapping.test3.B3;
import org.nuiton.topia.it.mapping.test3.B31;
import org.nuiton.topia.it.mapping.test3.B32;
import org.nuiton.topia.it.mapping.test3.B33;
import org.nuiton.topia.it.mapping.test4.A4;
import org.nuiton.topia.it.mapping.test5.A5;
import org.nuiton.topia.it.mapping.test5.A51;
import org.nuiton.topia.it.mapping.test5.A53;
import org.nuiton.topia.it.mapping.test5.B5;
import org.nuiton.topia.it.mapping.test5.B51;
import org.nuiton.topia.it.mapping.test5.B53;
import org.nuiton.topia.it.mapping.test6.A6;
import org.nuiton.topia.it.mapping.test6.A61;
import org.nuiton.topia.it.mapping.test6.A62;
import org.nuiton.topia.it.mapping.test6.A63;
import org.nuiton.topia.it.mapping.test6.B6;
import org.nuiton.topia.it.mapping.test6.B61;
import org.nuiton.topia.it.mapping.test6.B62;
import org.nuiton.topia.it.mapping.test6.B63;
import org.nuiton.topia.it.mapping.test7.A7;
import org.nuiton.topia.it.mapping.test7.A71;
import org.nuiton.topia.it.mapping.test7.A72;
import org.nuiton.topia.it.mapping.test7.A73;
import org.nuiton.topia.it.mapping.test7.B7;
import org.nuiton.topia.it.mapping.test7.B71;
import org.nuiton.topia.it.mapping.test7.B72;
import org.nuiton.topia.it.mapping.test7.B73;
import org.nuiton.topia.it.mapping.test9.A9;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.topia.persistence.util.EntityOperator;
import org.nuiton.topia.persistence.util.EntityOperatorStore;
import org.nuiton.topia.persistence.util.TopiaEntityHelper;
@Generated(value = "org.nuiton.topia.templates.EntityEnumTransformer", date = "Thu Oct 13 17:59:14 CEST 2016")
public enum TopiaItMappingEntityEnum implements TopiaEntityEnum {
A1(A1.class, null, "a1", ArrayUtils.EMPTY_STRING_ARRAY),
A11(A11.class, null, "a11", ArrayUtils.EMPTY_STRING_ARRAY),
A12(A12.class, null, "a12", ArrayUtils.EMPTY_STRING_ARRAY),
A13(A13.class, null, "a13", ArrayUtils.EMPTY_STRING_ARRAY),
B1(B1.class, null, "b1", ArrayUtils.EMPTY_STRING_ARRAY),
B11(B11.class, null, "b11", ArrayUtils.EMPTY_STRING_ARRAY),
B12(B12.class, null, "b12", ArrayUtils.EMPTY_STRING_ARRAY),
B13(B13.class, null, "b13", ArrayUtils.EMPTY_STRING_ARRAY),
A11A(A11A.class, null, "a11a", ArrayUtils.EMPTY_STRING_ARRAY),
A11B(A11B.class, null, "a11b", ArrayUtils.EMPTY_STRING_ARRAY),
A11C(A11C.class, null, "a11c", ArrayUtils.EMPTY_STRING_ARRAY),
A11D(A11D.class, null, "a11d", ArrayUtils.EMPTY_STRING_ARRAY),
A11E(A11E.class, null, "a11e", ArrayUtils.EMPTY_STRING_ARRAY),
B11A(B11A.class, null, "b11a", ArrayUtils.EMPTY_STRING_ARRAY),
B11B(B11B.class, null, "b11b", ArrayUtils.EMPTY_STRING_ARRAY),
B11C(B11C.class, null, "b11c", ArrayUtils.EMPTY_STRING_ARRAY),
B11D(B11D.class, null, "b11d", ArrayUtils.EMPTY_STRING_ARRAY),
A12A(A12A.class, null, "a12a", new String[]{"integerField", "stringField", "dateField"}),
A13A(A13A.class, null, "a13a", new String[]{"naturalIdInteger", "naturalIdString", "naturalIdDate"}, "naturalIdInteger", "naturalIdString", "naturalIdDate"),
B13A(B13A.class, null, "b13a", ArrayUtils.EMPTY_STRING_ARRAY),
B13B(B13B.class, null, "b13b", ArrayUtils.EMPTY_STRING_ARRAY),
B13C(B13C.class, null, "b13c", ArrayUtils.EMPTY_STRING_ARRAY),
A14A(A14A.class, null, "a14a", ArrayUtils.EMPTY_STRING_ARRAY),
A14B(A14B.class, null, "a14b", ArrayUtils.EMPTY_STRING_ARRAY),
A14C(A14C.class, null, "a14c", ArrayUtils.EMPTY_STRING_ARRAY),
A14D(A14D.class, null, "a14d", ArrayUtils.EMPTY_STRING_ARRAY),
Assoc14A(Assoc14A.class, null, "assoc14a", new String[]{"roleB", "a14A"}),
Assoc14B(Assoc14B.class, null, "assoc14b", new String[]{"b14B", "roleA"}),
Assoc14C(Assoc14C.class, null, "assoc14c", new String[]{"b14C", "a14C"}),
Assoc14D(Assoc14D.class, null, "assoc14d", new String[]{"b14D", "roleA"}),
B14A(B14A.class, null, "b14a", ArrayUtils.EMPTY_STRING_ARRAY),
B14B(B14B.class, null, "b14b", ArrayUtils.EMPTY_STRING_ARRAY),
B14C(B14C.class, null, "b14c", ArrayUtils.EMPTY_STRING_ARRAY),
B14D(B14D.class, null, "b14d", ArrayUtils.EMPTY_STRING_ARRAY),
A15A(A15A.class, null, "a15a", ArrayUtils.EMPTY_STRING_ARRAY),
A16(A16.class, null, "a16", ArrayUtils.EMPTY_STRING_ARRAY),
B16(B16.class, null, "b16", ArrayUtils.EMPTY_STRING_ARRAY),
C16(C16.class, null, "c16", ArrayUtils.EMPTY_STRING_ARRAY),
A17(A17.class, "a", "a", ArrayUtils.EMPTY_STRING_ARRAY),
B17(B17.class, "b", "b", ArrayUtils.EMPTY_STRING_ARRAY),
BB17(BB17.class, "b", "bb17", ArrayUtils.EMPTY_STRING_ARRAY),
A18(A18.class, null, "a18", ArrayUtils.EMPTY_STRING_ARRAY),
B18(B18.class, null, "b18", ArrayUtils.EMPTY_STRING_ARRAY),
A2(A2.class, null, "a2", ArrayUtils.EMPTY_STRING_ARRAY),
A21(A21.class, null, "a21", ArrayUtils.EMPTY_STRING_ARRAY),
A22(A22.class, null, "a22", ArrayUtils.EMPTY_STRING_ARRAY),
A23(A23.class, null, "a23", ArrayUtils.EMPTY_STRING_ARRAY),
B2(B2.class, null, "b2", ArrayUtils.EMPTY_STRING_ARRAY),
B21(B21.class, null, "b21", ArrayUtils.EMPTY_STRING_ARRAY),
B22(B22.class, null, "b22", ArrayUtils.EMPTY_STRING_ARRAY),
B23(B23.class, null, "b23", ArrayUtils.EMPTY_STRING_ARRAY),
A3(A3.class, null, "a3", ArrayUtils.EMPTY_STRING_ARRAY),
A31(A31.class, null, "a31", ArrayUtils.EMPTY_STRING_ARRAY),
A32(A32.class, null, "a32", ArrayUtils.EMPTY_STRING_ARRAY),
A33(A33.class, null, "a33", ArrayUtils.EMPTY_STRING_ARRAY),
B3(B3.class, null, "b3", ArrayUtils.EMPTY_STRING_ARRAY),
B31(B31.class, null, "b31", ArrayUtils.EMPTY_STRING_ARRAY),
B32(B32.class, null, "b32", ArrayUtils.EMPTY_STRING_ARRAY),
B33(B33.class, null, "b33", ArrayUtils.EMPTY_STRING_ARRAY),
A4(A4.class, null, "a4", ArrayUtils.EMPTY_STRING_ARRAY),
A5(A5.class, null, "a5", ArrayUtils.EMPTY_STRING_ARRAY),
A51(A51.class, null, "a51", ArrayUtils.EMPTY_STRING_ARRAY),
A53(A53.class, null, "a53", ArrayUtils.EMPTY_STRING_ARRAY),
B5(B5.class, null, "b5", ArrayUtils.EMPTY_STRING_ARRAY),
B51(B51.class, null, "b51", ArrayUtils.EMPTY_STRING_ARRAY),
B53(B53.class, null, "b53", ArrayUtils.EMPTY_STRING_ARRAY),
A6(A6.class, null, "a6", ArrayUtils.EMPTY_STRING_ARRAY),
A61(A61.class, null, "a61", ArrayUtils.EMPTY_STRING_ARRAY),
A62(A62.class, null, "a62", ArrayUtils.EMPTY_STRING_ARRAY),
A63(A63.class, null, "a63", ArrayUtils.EMPTY_STRING_ARRAY),
B6(B6.class, null, "b6", ArrayUtils.EMPTY_STRING_ARRAY),
B61(B61.class, null, "b61", ArrayUtils.EMPTY_STRING_ARRAY),
B62(B62.class, null, "b62", ArrayUtils.EMPTY_STRING_ARRAY),
B63(B63.class, null, "b63", ArrayUtils.EMPTY_STRING_ARRAY),
A7(A7.class, null, "a7", ArrayUtils.EMPTY_STRING_ARRAY),
A71(A71.class, null, "a71", ArrayUtils.EMPTY_STRING_ARRAY),
A72(A72.class, null, "a72", ArrayUtils.EMPTY_STRING_ARRAY),
A73(A73.class, null, "a73", ArrayUtils.EMPTY_STRING_ARRAY),
B7(B7.class, null, "b7", ArrayUtils.EMPTY_STRING_ARRAY),
B71(B71.class, null, "b71", ArrayUtils.EMPTY_STRING_ARRAY),
B72(B72.class, null, "b72", ArrayUtils.EMPTY_STRING_ARRAY),
B73(B73.class, null, "b73", ArrayUtils.EMPTY_STRING_ARRAY),
A9(A9.class, null, "a9", ArrayUtils.EMPTY_STRING_ARRAY);
/**
* The contract of the entity.
*/
private final Class extends TopiaEntity> contract;
/**
* The optional name of database schema of the entity (if none was filled, will be {@code null}).
*/
private final String dbSchemaName;
/**
* The name of the database table for the entity.
*/
private final String dbTableName;
/**
* The fully qualified name of the implementation of the entity.
*/
private String implementationFQN;
/**
* The implementation class of the entity (will be lazy computed at runtime).
*/
private Class extends TopiaEntity> implementation;
/**
* The array of property involved in the natural key of the entity.
*/
private final String[] naturalIds;
/**
* The array of not null properties of the entity.
*/
private final String[] notNulls;
TopiaItMappingEntityEnum(Class extends TopiaEntity> contract, String dbSchemaName, String dbTableName, String[] notNulls, String ... naturalIds) {
this.contract = contract;
this.dbSchemaName = dbSchemaName;
this.dbTableName = dbTableName;
this.notNulls = Arrays.copyOf(notNulls, notNulls.length);
this.naturalIds = naturalIds;
implementationFQN = contract.getName() + "Impl";
}
@Override
public Class extends TopiaEntity> getContract() {
return contract;
}
@Override
public String dbSchemaName() {
return dbSchemaName;
}
@Override
public String dbTableName() {
return dbTableName;
}
@Override
public String[] getNaturalIds() {
return naturalIds;
}
@Override
public boolean isUseNaturalIds() {
return naturalIds.length > 0;
}
@Override
public String[] getNotNulls() {
return notNulls;
}
@Override
public boolean isUseNotNulls() {
return notNulls.length > 0;
}
@Override
public String getImplementationFQN() {
return implementationFQN;
}
@Override
public void setImplementationFQN(String implementationFQN) {
this.implementationFQN = implementationFQN;
implementation = null;
// reinit the operators store
EntityOperatorStore.clear();
}
@Override
public boolean accept(Class extends TopiaEntity> klass) {
TopiaItMappingEntityEnum constant = valueOf(klass);
boolean result = constant.getContract() == contract;
return result;
}
@Override
public Class extends TopiaEntity> getImplementation() {
if (implementation == null) {
try {
implementation = (Class extends TopiaEntity>) Class.forName(implementationFQN);
} catch (ClassNotFoundException e) {
throw new TopiaException("could not find class " + implementationFQN, e);
}
}
return implementation;
}
public static TopiaItMappingEntityEnum valueOf(TopiaEntity entity) {
return valueOf(entity.getClass());
}
public static TopiaItMappingEntityEnum valueOf(final Class> klass) {
if (klass.isInterface()) {
return valueOf(klass.getSimpleName());
}
Class> contractClass = TopiaEntityHelper.getContractClass(TopiaItMappingEntityEnum.values(), (Class) klass);
if (contractClass != null) {
return valueOf(contractClass.getSimpleName());
}
throw new IllegalArgumentException("no entity defined for the class " + klass + " in : " + Arrays.toString(TopiaItMappingEntityEnum.values()));
}
public static TopiaItMappingEntityEnum[] getContracts() {
TopiaItMappingEntityEnum[] result = values();
return result;
}
public static Class getContractClass(Class klass) {
TopiaItMappingEntityEnum constant = valueOf(klass);
Class result = (Class) constant.getContract();
return result;
}
public static Class extends TopiaEntity>[] getContractClasses() {
TopiaItMappingEntityEnum[] values = values();
Class extends TopiaEntity>[] result = (Class extends TopiaEntity>[]) Array.newInstance(Class.class, values.length);
for (int i = 0; i < values.length; i++) {
result[i] = values[i].getContract();
}
return result;
}
public static Class getImplementationClass(Class klass) {
TopiaItMappingEntityEnum constant = valueOf(klass);
Class result = (Class) constant.getImplementation();
return result;
}
public static Set> getImplementationClasses() {
TopiaItMappingEntityEnum[] values = values();
Set> result = new LinkedHashSet>();
for (int i = 0; i < values.length; i++) {
result.add(values[i].getImplementation());
}
return result;
}
public static String getImplementationClassesAsString() {
StringBuilder buffer = new StringBuilder();
for (Class extends TopiaEntity> aClass : getImplementationClasses()) {
buffer.append(',').append(aClass.getName());
}
String result = buffer.substring(1);
return result;
}
public static EntityOperator getOperator(Class klass) {
TopiaItMappingEntityEnum constant = valueOf(klass);
EntityOperator result = EntityOperatorStore.getOperator(constant);
return result;
}
} //TopiaItMappingEntityEnum
© 2015 - 2024 Weber Informatics LLC | Privacy Policy