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