use of core.framework.db.DBEnumValue in project core-ng-project by neowu.
the class DatabaseClassValidator method validateEnumClass.
private void validateEnumClass(Class<?> enumClass, Field field) {
Enum<?>[] constants = (Enum<?>[]) enumClass.getEnumConstants();
Set<String> enumValues = Sets.newHashSet();
for (Enum<?> constant : constants) {
DBEnumValue enumValue = Enums.constantAnnotation(constant, DBEnumValue.class);
if (enumValue == null) {
throw Exceptions.error("db enum must have @DBEnumValue, field={}, enum={}", Fields.path(field), Enums.path(constant));
}
boolean added = enumValues.add(enumValue.value());
if (!added) {
throw Exceptions.error("db enum value must be unique, enum={}, value={}", Enums.path(constant), enumValue.value());
}
Property property = Enums.constantAnnotation(constant, Property.class);
if (property != null) {
throw Exceptions.error("db enum must not have json annotation, please separate view and entity, field={}, enum={}", Fields.path(field), Enums.path(constant));
}
}
}
Aggregations