use 'value' for class value in Clazz annotation instead of 'clazz'

This commit is contained in:
wea_ondara
2022-08-14 16:44:32 +02:00
parent c6264b8e3e
commit d532d92c0f
58 changed files with 182 additions and 187 deletions

View File

@@ -18,7 +18,7 @@ class EntityInitializer {
if (clazzAnnotation == null) {
throw new ModelException("DbSet " + ctxfield.getName() + " is missing the " + Clazz.class.getSimpleName() + " annotation");
}
var dbsetClazz = (Class<? extends SerializableObject>) clazzAnnotation.clazz();
var dbSetClazz = (Class<? extends SerializableObject>) clazzAnnotation.value();
initEntity(mb, dbsetClazz, ctxfield.getName());
}
}
@@ -39,7 +39,7 @@ class EntityInitializer {
if (clazzAnnotation.length == 0) {
throw new ModelException("Field " + f.getClass().getSimpleName() + "::" + f.getName() + " is missing the " + Clazz.class.getSimpleName() + " annotation");
}
var fClazz = clazzAnnotation[0].clazz();
var fClazz = clazzAnnotation[0].value();
var foundCollection = entity.getFields().stream()
.filter(e -> Collection.class.isAssignableFrom(e.getType())
&& e.isModelField()

View File

@@ -31,10 +31,10 @@ class ForeignKeyInitializer {
if (clazzAnnotation == null) {
throw new ModelException("Collection " + entity.getType().getSimpleName() + "." + f.getName() + " is missing the " + Clazz.class.getSimpleName() + " annotation");
}
var otherEntity = mb.getEntity((Class<? extends SerializableObject>) clazzAnnotation.clazz());
var otherEntity = mb.getEntity((Class<? extends SerializableObject>) clazzAnnotation.value());
if (otherEntity == null) {
EntityInitializer.initEntity(mb, (Class<? extends SerializableObject>) clazzAnnotation.clazz(), f.getName());
otherEntity = mb.getEntity((Class<? extends SerializableObject>) clazzAnnotation.clazz());
EntityInitializer.initEntity(mb, (Class<? extends SerializableObject>) clazzAnnotation.value(), f.getName());
otherEntity = mb.getEntity((Class<? extends SerializableObject>) clazzAnnotation.value());
PrimaryKeyInitializer.initPrimaryKeys(mb, otherEntity);
}
var primary = entity.getPrimaryKey();
@@ -49,7 +49,7 @@ class ForeignKeyInitializer {
var otherEntityListField = otherEntityF.getFields().stream()
.filter(oef -> Collection.class.isAssignableFrom(oef.getType())
&& oef.getField().getAnnotationsByType(Clazz.class).length > 0
&& oef.getField().getAnnotationsByType(Clazz.class)[0].clazz() == entity.getType()).findFirst();
&& oef.getField().getAnnotationsByType(Clazz.class)[0].value() == entity.getType()).findFirst();
if (otherEntityListField.isPresent()) {
throw new ModelException("N to N relations need to explicitly defined via a mapping model ("
+ otherEntityF.getType().getSimpleName() + "::" + otherEntityListField.get().getType().getName() + " and "
@@ -103,7 +103,7 @@ class ForeignKeyInitializer {
var entityListField = entity.getFields().stream()
.filter(oef -> Collection.class.isAssignableFrom(oef.getType())
&& oef.getField().getAnnotationsByType(Clazz.class).length > 0
&& oef.getField().getAnnotationsByType(Clazz.class)[0].clazz() == otherEntityF.getType()).toList();
&& oef.getField().getAnnotationsByType(Clazz.class)[0].value() == otherEntityF.getType()).toList();
// if (entityListField.size() == 1) {
// return new FieldSearchResult(entityListField.get(0), true);
// }

View File

@@ -10,5 +10,5 @@ import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Clazz {
Class<?> clazz();
Class<?> value();
}