annotationType) {
- return AnnotationUtil.findAnnotationsRecursive(clazz, annotationType);
- }
-
- /**
- * Find all {@link Annotation}s of {@code annotationType} on the supplied {@link AnnotatedElement}.
- *
- * Meta-annotations will be searched if the annotation is not directly present on the supplied element.
- *
- * Warning: this method operates generically on annotated elements. In other words, this method
- * does not execute specialized search algorithms for classes or methods. It only traverses through Annotations!
- */
- public static Set findAnnotations(AnnotatedElement annotatedElement, Class annotationType) {
- return AnnotationUtil.findAnnotations(annotatedElement, annotationType);
- }
-
+
}
diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java
index fbab35764..aa4902a9b 100644
--- a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java
+++ b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationClass.java
@@ -11,6 +11,7 @@ import io.ebean.annotation.ReadAudit;
import io.ebean.annotation.UpdateMode;
import io.ebean.annotation.View;
import io.ebean.config.TableName;
+import io.ebean.util.AnnotationUtil;
import io.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
import io.ebeaninternal.server.deploy.IndexDefinition;
import io.ebeaninternal.server.deploy.InheritInfo;
@@ -67,7 +68,7 @@ public class AnnotationClass extends AnnotationParser {
public void parseAttributeOverride() {
Class> cls = descriptor.getBeanType();
- AttributeOverride override = AnnotationBase.findAnnotationRecursive(cls, AttributeOverride.class);
+ AttributeOverride override = AnnotationUtil.findAnnotationRecursive(cls, AttributeOverride.class);
if (override != null) {
String propertyName = override.name();
Column column = override.column();
@@ -109,14 +110,14 @@ public class AnnotationClass extends AnnotationParser {
private void read(Class> cls) {
// maybe doc store only so check for this before @Entity
- DocStore docStore = AnnotationBase.findAnnotationRecursive(cls, DocStore.class);
+ DocStore docStore = AnnotationUtil.findAnnotationRecursive(cls, DocStore.class);
if (docStore != null) {
descriptor.readDocStore(docStore);
descriptor.setEntityType(EntityType.DOC);
descriptor.setName(cls.getSimpleName());
}
- Entity entity = AnnotationBase.findAnnotationRecursive(cls, Entity.class);
+ Entity entity = AnnotationUtil.findAnnotationRecursive(cls, Entity.class);
if (entity != null) {
descriptor.setEntityType(EntityType.ORM);
if (entity.name().isEmpty()) {
@@ -126,27 +127,27 @@ public class AnnotationClass extends AnnotationParser {
}
}
- Embeddable embeddable = AnnotationBase.findAnnotationRecursive(cls, Embeddable.class);
+ Embeddable embeddable = AnnotationUtil.findAnnotationRecursive(cls, Embeddable.class);
if (embeddable != null) {
descriptor.setEntityType(EntityType.EMBEDDED);
descriptor.setName("Embeddable:" + cls.getSimpleName());
}
- Set indices = AnnotationBase.findAnnotationsRecursive(cls, Index.class);
+ Set indices = AnnotationUtil.findAnnotationsRecursive(cls, Index.class);
for (Index index : indices) {
descriptor.addIndex(new IndexDefinition(index.columnNames(), index.name(), index.unique()));
}
- UniqueConstraint uc = AnnotationBase.findAnnotationRecursive(cls, UniqueConstraint.class);
+ UniqueConstraint uc = AnnotationUtil.findAnnotationRecursive(cls, UniqueConstraint.class);
if (uc != null) {
descriptor.addIndex(new IndexDefinition(uc.columnNames()));
}
- View view = AnnotationBase.findAnnotationRecursive(cls, View.class);
+ View view = AnnotationUtil.findAnnotationRecursive(cls, View.class);
if (view != null) {
descriptor.setView(view.name(), view.dependentTables());
}
- Table table = AnnotationBase.findAnnotationRecursive(cls, Table.class);
+ Table table = AnnotationUtil.findAnnotationRecursive(cls, Table.class);
if (table != null) {
UniqueConstraint[] uniqueConstraints = table.uniqueConstraints();
for (UniqueConstraint c : uniqueConstraints) {
@@ -154,42 +155,42 @@ public class AnnotationClass extends AnnotationParser {
}
}
- Draftable draftable = AnnotationBase.findAnnotationRecursive(cls, Draftable.class);
+ Draftable draftable = AnnotationUtil.findAnnotationRecursive(cls, Draftable.class);
if (draftable != null) {
descriptor.setDraftable();
}
- DraftableElement draftableElement = AnnotationBase.findAnnotationRecursive(cls, DraftableElement.class);
+ DraftableElement draftableElement = AnnotationUtil.findAnnotationRecursive(cls, DraftableElement.class);
if (draftableElement != null) {
descriptor.setDraftableElement();
}
- ReadAudit readAudit = AnnotationBase.findAnnotationRecursive(cls, ReadAudit.class);
+ ReadAudit readAudit = AnnotationUtil.findAnnotationRecursive(cls, ReadAudit.class);
if (readAudit != null) {
descriptor.setReadAuditing();
}
- History history = AnnotationBase.findAnnotationRecursive(cls, History.class);
+ History history = AnnotationUtil.findAnnotationRecursive(cls, History.class);
if (history != null) {
descriptor.setHistorySupport();
}
- DbComment comment = AnnotationBase.findAnnotationRecursive(cls, DbComment.class);
+ DbComment comment = AnnotationUtil.findAnnotationRecursive(cls, DbComment.class);
if (comment != null) {
descriptor.setDbComment(comment.value());
}
- UpdateMode updateMode = AnnotationBase.findAnnotationRecursive(cls, UpdateMode.class);
+ UpdateMode updateMode = AnnotationUtil.findAnnotationRecursive(cls, UpdateMode.class);
if (updateMode != null) {
descriptor.setUpdateChangesOnly(updateMode.updateChangesOnly());
}
- Cache cache = AnnotationBase.findAnnotationRecursive(cls, Cache.class);
+ Cache cache = AnnotationUtil.findAnnotationRecursive(cls, Cache.class);
if (cache != null && !disableL2Cache) {
descriptor.setCache(cache);
}
- Set namedQueries = AnnotationBase.findAnnotationsRecursive(cls, NamedQuery.class);
+ Set namedQueries = AnnotationUtil.findAnnotationsRecursive(cls, NamedQuery.class);
for (NamedQuery namedQuery : namedQueries) {
descriptor.addNamedQuery(namedQuery.name(), namedQuery.query());
}
diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationSql.java b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationSql.java
index aa0205632..d488e933c 100644
--- a/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationSql.java
+++ b/src/main/java/io/ebeaninternal/server/deploy/parse/AnnotationSql.java
@@ -1,6 +1,7 @@
package io.ebeaninternal.server.deploy.parse;
import io.ebean.annotation.Sql;
+import io.ebean.util.AnnotationUtil;
import io.ebeaninternal.server.deploy.BeanDescriptor;
/**
@@ -15,7 +16,7 @@ public class AnnotationSql extends AnnotationParser {
@Override
public void parse() {
Class> cls = descriptor.getBeanType();
- Sql sql = AnnotationBase.findAnnotationRecursive(cls, Sql.class);
+ Sql sql = AnnotationUtil.findAnnotationRecursive(cls, Sql.class);
if (sql != null) {
descriptor.setEntityType(BeanDescriptor.EntityType.SQL);
}
diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java
index c91864434..e1a96c042 100644
--- a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java
+++ b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployCreateProperties.java
@@ -5,6 +5,7 @@ import io.ebean.annotation.DbHstore;
import io.ebean.annotation.DbJson;
import io.ebean.annotation.DbJsonB;
import io.ebean.annotation.UnmappedJson;
+import io.ebean.util.AnnotationUtil;
import io.ebeaninternal.server.deploy.DetermineManyType;
import io.ebeaninternal.server.deploy.ManyType;
import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
@@ -221,7 +222,7 @@ public class DeployCreateProperties {
Class> propertyType = field.getType();
- ManyToOne manyToOne = AnnotationBase.findAnnotation(field, ManyToOne.class);
+ ManyToOne manyToOne = AnnotationUtil.findAnnotation(field, ManyToOne.class);
if (manyToOne != null) {
Class> tt = manyToOne.targetEntity();
if (!tt.equals(void.class)) {
@@ -238,7 +239,7 @@ public class DeployCreateProperties {
// List, Set or Map based object
Class> targetType = determineTargetType(field);
if (targetType == null) {
- Transient transAnnotation = AnnotationBase.findAnnotation(field, Transient.class);
+ Transient transAnnotation = AnnotationUtil.findAnnotation(field, Transient.class);
if (transAnnotation != null) {
// not supporting this field (generic type used)
return null;
@@ -274,16 +275,16 @@ public class DeployCreateProperties {
* Return true if the field has one of the special mappings.
*/
private boolean isSpecialScalarType(Field field) {
- return (AnnotationBase.findAnnotation(field, DbJson.class) != null)
- || (AnnotationBase.findAnnotation(field, DbJsonB.class) != null)
- || (AnnotationBase.findAnnotation(field, DbArray.class) != null)
- || (AnnotationBase.findAnnotation(field, DbHstore.class) != null)
- || (AnnotationBase.findAnnotation(field, UnmappedJson.class) != null);
+ return (AnnotationUtil.findAnnotation(field, DbJson.class) != null)
+ || (AnnotationUtil.findAnnotation(field, DbJsonB.class) != null)
+ || (AnnotationUtil.findAnnotation(field, DbArray.class) != null)
+ || (AnnotationUtil.findAnnotation(field, DbHstore.class) != null)
+ || (AnnotationUtil.findAnnotation(field, UnmappedJson.class) != null);
}
private boolean isTransientField(Field field) {
- Transient t = AnnotationBase.findAnnotation(field, Transient.class);
+ Transient t = AnnotationUtil.findAnnotation(field, Transient.class);
return (t != null);
}
diff --git a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployInherit.java b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployInherit.java
index 30fab9aca..f7fe0d56c 100644
--- a/src/main/java/io/ebeaninternal/server/deploy/parse/DeployInherit.java
+++ b/src/main/java/io/ebeaninternal/server/deploy/parse/DeployInherit.java
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.deploy.parse;
+import io.ebean.util.AnnotationUtil;
import io.ebeaninternal.server.core.bootup.BootupClasses;
import io.ebeaninternal.server.deploy.InheritInfo;
import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
@@ -109,11 +110,11 @@ public class DeployInherit {
info.setParent(parent);
}
- Inheritance ia = AnnotationBase.findAnnotationRecursive(cls, Inheritance.class);
+ Inheritance ia = AnnotationUtil.findAnnotationRecursive(cls, Inheritance.class);
if (ia != null) {
ia.strategy();
}
- DiscriminatorColumn da = AnnotationBase.findAnnotationRecursive(cls, DiscriminatorColumn.class);
+ DiscriminatorColumn da = AnnotationUtil.findAnnotationRecursive(cls, DiscriminatorColumn.class);
if (da != null) {
// lowercase the discriminator column for RawSql and JSON
info.setColumnName(da.name().toLowerCase());
@@ -122,7 +123,7 @@ public class DeployInherit {
info.setColumnDefn(da.columnDefinition());
}
- DiscriminatorValue dv = AnnotationBase.findAnnotationRecursive(cls, DiscriminatorValue.class);
+ DiscriminatorValue dv = AnnotationUtil.findAnnotation(cls, DiscriminatorValue.class); // do not search recursive
if (dv != null) {
info.setDiscriminatorValue(dv.value());
}
@@ -144,7 +145,7 @@ public class DeployInherit {
if (cls.equals(Object.class)) {
return false;
}
- Annotation a = AnnotationBase.findAnnotationRecursive(cls, Inheritance.class);
+ Annotation a = AnnotationUtil.findAnnotationRecursive(cls, Inheritance.class);
if (a != null) {
return true;
}
diff --git a/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java b/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java
index e99b9eefd..bbb81b501 100644
--- a/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java
+++ b/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java
@@ -10,10 +10,10 @@ import io.ebean.config.ScalarTypeConverter;
import io.ebean.config.ServerConfig;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.config.dbplatform.DbPlatformType;
+import io.ebean.util.AnnotationUtil;
import io.ebeaninternal.dbmigration.DbOffline;
import io.ebeaninternal.api.ExtraTypeFactory;
import io.ebeaninternal.server.core.bootup.BootupClasses;
-import io.ebeaninternal.server.deploy.parse.AnnotationBase;
import io.ebeanservice.docstore.api.mapping.DocPropertyType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -544,7 +544,7 @@ public final class DefaultTypeManager implements TypeManager {
Field[] fields = enumType.getDeclaredFields();
for (Field field : fields) {
- EnumValue enumValue = AnnotationBase.findAnnotation(field, EnumValue.class);
+ EnumValue enumValue = AnnotationUtil.findAnnotation(field, EnumValue.class);
if (enumValue != null) {
nameValueMap.put(field.getName(), enumValue.value());
if (integerType && !isIntegerType(enumValue.value())) {
@@ -575,7 +575,7 @@ public final class DefaultTypeManager implements TypeManager {
Method[] methods = enumType.getMethods();
for (Method method : methods) {
- DbEnumValue dbValue = AnnotationBase.findAnnotation(method, DbEnumValue.class);
+ DbEnumValue dbValue = AnnotationUtil.findAnnotation(method, DbEnumValue.class);
if (dbValue != null) {
boolean integerValues = DbEnumType.INTEGER == dbValue.storage();
return createEnumScalarTypeDbValue(enumType, method, integerValues);
diff --git a/src/test/java/org/tests/basic/TestAnnotationBase.java b/src/test/java/org/tests/basic/TestAnnotationBase.java
index 985a70715..e40c36cd9 100644
--- a/src/test/java/org/tests/basic/TestAnnotationBase.java
+++ b/src/test/java/org/tests/basic/TestAnnotationBase.java
@@ -2,10 +2,10 @@ package org.tests.basic;
import io.ebean.BaseTestCase;
import io.ebean.annotation.Where;
+import io.ebean.util.AnnotationUtil;
import io.ebean.annotation.Platform;
import io.ebeaninternal.server.deploy.BeanDescriptor;
import io.ebeaninternal.server.deploy.BeanProperty;
-import io.ebeaninternal.server.deploy.parse.AnnotationBase;
import org.tests.model.basic.ValidationGroupSomething;
import org.junit.Test;
@@ -150,41 +150,41 @@ public class TestAnnotationBase extends BaseTestCase {
Field fld = TestAnnotationBaseEntity.class.getDeclaredField("direct");
String s;
- s = AnnotationBase.findAnnotation(fld, Where.class, Platform.MYSQL).clause();
+ s = AnnotationUtil.findAnnotation(fld, Where.class, Platform.MYSQL).clause();
assertEquals("SELECT 'mysql' from 1", s);
- s = AnnotationBase.findAnnotation(fld, Where.class, Platform.H2).clause();
+ s = AnnotationUtil.findAnnotation(fld, Where.class, Platform.H2).clause();
assertEquals("SELECT 'h2' from 1", s);
- s = AnnotationBase.findAnnotation(fld, Where.class, Platform.POSTGRES).clause();
+ s = AnnotationUtil.findAnnotation(fld, Where.class, Platform.POSTGRES).clause();
assertEquals("SELECT 'other' from 1", s);
// meta
fld = TestAnnotationBaseEntity.class.getDeclaredField("meta");
- s = AnnotationBase.findAnnotation(fld, Where.class, Platform.MYSQL).clause();
+ s = AnnotationUtil.findAnnotation(fld, Where.class, Platform.MYSQL).clause();
assertEquals("SELECT 'mysql' from 1", s);
- s = AnnotationBase.findAnnotation(fld, Where.class, Platform.H2).clause();
+ s = AnnotationUtil.findAnnotation(fld, Where.class, Platform.H2).clause();
assertEquals("SELECT 'h2' from 1", s);
- s = AnnotationBase.findAnnotation(fld, Where.class, Platform.POSTGRES).clause();
+ s = AnnotationUtil.findAnnotation(fld, Where.class, Platform.POSTGRES).clause();
assertEquals("SELECT 'other' from 1", s);
// mixed
fld = TestAnnotationBaseEntity.class.getDeclaredField("mixed");
- s = AnnotationBase.findAnnotation(fld, Where.class, Platform.MYSQL).clause();
+ s = AnnotationUtil.findAnnotation(fld, Where.class, Platform.MYSQL).clause();
assertEquals("SELECT 'mysql' from 1", s);
- s = AnnotationBase.findAnnotation(fld, Where.class, Platform.H2).clause();
+ s = AnnotationUtil.findAnnotation(fld, Where.class, Platform.H2).clause();
assertEquals("SELECT 'h2' from 1", s);
- s = AnnotationBase.findAnnotation(fld, Where.class, Platform.POSTGRES).clause();
+ s = AnnotationUtil.findAnnotation(fld, Where.class, Platform.POSTGRES).clause();
assertEquals("SELECT 'other' from 1", s);
- s = AnnotationBase.findAnnotation(fld, Where.class, Platform.ORACLE).clause();
+ s = AnnotationUtil.findAnnotation(fld, Where.class, Platform.ORACLE).clause();
assertEquals("SELECT 'oracle' from 1", s);
}