From a3c5779767ee5e5ba5d5fc428111a547e7949377 Mon Sep 17 00:00:00 2001 From: MarcGuiot Date: Sat, 28 Sep 2024 14:35:26 +0200 Subject: [PATCH] rename annotation --- .../core/metamodel/Annotations.java | 3 + .../core/metamodel/GlobTypeBuilder.java | 6 +- .../metamodel/annotations/AllAnnotations.java | 24 ++-- .../metamodel/annotations/AutoIncrement.java | 24 ++-- .../AutoIncrementAnnotationType.java | 22 ---- .../metamodel/annotations/AutoIncrement_.java | 14 ++ .../{CommentType.java => Comment.java} | 4 +- .../core/metamodel/annotations/Comment_.java | 2 +- .../annotations/ContainmentLink.java | 23 +++- .../ContainmentLinkAnnotationType.java | 23 ---- .../{IsLink.java => ContainmentLink_.java} | 5 +- .../annotations/DefaultBigDecimal.java | 31 +++-- .../DefaultBigDecimalAnnotationType.java | 31 ----- ...nnotation.java => DefaultBigDecimal_.java} | 4 +- .../metamodel/annotations/DefaultBoolean.java | 28 ++-- .../DefaultBooleanAnnotationType.java | 28 ---- .../annotations/DefaultBoolean_.java | 15 +++ .../metamodel/annotations/DefaultDouble.java | 27 ++-- .../DefaultDoubleAnnotationType.java | 28 ---- .../metamodel/annotations/DefaultDouble_.java | 16 +++ .../annotations/DefaultFieldValue.java | 4 - .../metamodel/annotations/DefaultInteger.java | 28 ++-- .../DefaultIntegerAnnotationType.java | 27 ---- .../annotations/DefaultInteger_.java | 15 +++ .../metamodel/annotations/DefaultLong.java | 28 ++-- .../DefaultLongAnnotationType.java | 27 ---- .../metamodel/annotations/DefaultLong_.java | 15 +++ .../metamodel/annotations/DefaultString.java | 28 ++-- .../DefaultStringAnnotationType.java | 27 ---- .../metamodel/annotations/DefaultString_.java | 15 +++ .../annotations/DoublePrecision.java | 28 ++-- .../DoublePrecisionAnnotationType.java | 27 ---- .../annotations/DoublePrecision_.java | 15 +++ .../metamodel/annotations/EnumAnnotation.java | 44 +++++-- .../annotations/EnumAnnotationType.java | 43 ------ .../annotations/EnumAnnotation_.java | 15 +++ ...NameAnnotationType.java => FieldName.java} | 8 +- .../{Encrypted.java => FieldName_.java} | 7 +- ...derType.java => FunctionalFieldOrder.java} | 8 +- ...tation.java => FunctionalFieldOrder_.java} | 4 +- ...tationType.java => IgnoredAnnotation.java} | 4 +- .../core/metamodel/annotations/IsDate.java | 2 +- .../metamodel/annotations/IsDateTime.java | 2 +- ...{TypedIsDateTime.java => IsDateTime_.java} | 2 +- .../{TypedIsDate.java => IsDate_.java} | 2 +- .../{IsTargetType.java => IsTarget.java} | 4 +- .../{IsTargetType_.java => IsTarget_.java} | 4 +- .../annotations/KeyAnnotationType.java | 64 --------- .../core/metamodel/annotations/KeyField.java | 66 ++++++++-- .../core/metamodel/annotations/KeyField_.java | 16 +++ .../metamodel/annotations/LinkModelName.java | 27 ++-- .../LinkModelNameAnnotationType.java | 28 ---- .../metamodel/annotations/LinkModelName_.java | 17 +++ .../core/metamodel/annotations/MaxSize.java | 115 ++++++++++++++-- .../metamodel/annotations/MaxSizeType.java | 116 ---------------- .../core/metamodel/annotations/MaxSize_.java | 24 ++++ .../metamodel/annotations/MultiLineText.java | 33 +++-- .../annotations/MultiLineTextType.java | 34 ----- .../metamodel/annotations/MultiLineText_.java | 19 +++ .../{NameAnnotation.java => Name.java} | 4 +- ...{NameAnnotationType.java => NameType.java} | 10 +- .../metamodel/annotations/NamingField.java | 28 ++-- .../NamingFieldAnnotationType.java | 28 ---- .../metamodel/annotations/NamingField_.java | 16 +++ ...iqueIndexType.java => NotUniqueIndex.java} | 4 +- .../core/metamodel/annotations/Required.java | 28 ++-- .../annotations/RequiredAnnotationType.java | 27 ---- .../core/metamodel/annotations/Required_.java | 15 +++ .../metamodel/fields/impl/AbstractField.java | 4 +- .../metamodel/impl/DefaultAnnotations.java | 52 +++++--- .../metamodel/impl/DefaultFieldFactory.java | 20 +-- .../core/metamodel/impl/DefaultGlobType.java | 41 +++--- .../impl/DefaultGlobTypeBuilder.java | 124 ++++++++++-------- .../impl/DefaultValuesFieldVisitor.java | 12 +- .../metamodel/impl/GlobTypeLoaderImpl.java | 37 +++--- .../links/impl/DefaultDirectLink.java | 4 +- .../links/impl/DefaultDirectSingleLink.java | 4 +- .../impl/DefaultMutableGlobLinkModel.java | 43 +++--- .../links/impl/UnInitializedLink.java | 6 +- .../metamodel/type/GlobArrayFieldType.java | 4 +- .../core/metamodel/type/GlobFieldType.java | 4 +- .../type/GlobUnionArrayFieldType.java | 4 +- .../metamodel/type/GlobUnionFieldType.java | 4 +- .../core/metamodel/type/StringFieldType.java | 4 +- .../core/metamodel/utils/GlobTypeUtils.java | 10 +- .../metamodel/utils/MutableAnnotations.java | 5 +- .../org/globsframework/core/model/Key.java | 14 +- .../java/org/globsframework/core/Sample.java | 14 +- .../core/metamodel/DummyObject.java | 8 +- .../core/metamodel/DummyObject2.java | 8 +- .../core/metamodel/DummyObjectIndex.java | 8 +- .../DummyObjectWithCompositeKey.java | 10 +- .../DummyObjectWithDefaultValues.java | 16 +-- .../core/metamodel/DummyObjectWithInner.java | 4 +- .../metamodel/DummyObjectWithLinkFieldId.java | 8 +- .../core/metamodel/DummyObjectWithLinks.java | 8 +- .../DummyObjectWithMaxSizeString.java | 12 +- .../DummyObjectWithMultiLineText.java | 8 +- .../DummyObjectWithQuadrupleKey.java | 14 +- .../DummyObjectWithRequiredFields.java | 10 +- .../DummyObjectWithRequiredLink.java | 8 +- .../metamodel/DummyObjectWithStringKey.java | 4 +- .../metamodel/DummyObjectWithTripleKey.java | 12 +- .../core/metamodel/GlobTypeBuilderTest.java | 8 +- .../core/metamodel/GlobTypeLoaderTest.java | 48 +++---- .../core/metamodel/GlobTypeTest.java | 4 +- ...{MaxSizeTypeTest.java => MaxSizeTest.java} | 18 +-- .../metamodel/utils/DefaultGlobModelTest.java | 22 ++-- .../metamodel/utils/DefaultGlobTypeTest.java | 16 +-- .../metamodel/utils/GlobTypeUtilsTest.java | 4 +- .../model/delta/InDepthChangeSetTest.java | 8 +- .../core/model/impl/CompositeKeyTest.java | 8 +- .../model/utils/ChangeSetSequencerTest.java | 24 ++-- .../specific/HashMapGlobKeyContainerTest.java | 14 +- .../core/xml/XmlGlobWriter.java | 4 +- .../core/xml/tests/XmlGlobParserTest.java | 8 +- 116 files changed, 1133 insertions(+), 1111 deletions(-) delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/AutoIncrementAnnotationType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/AutoIncrement_.java rename src/main/java/org/globsframework/core/metamodel/annotations/{CommentType.java => Comment.java} (93%) delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/ContainmentLinkAnnotationType.java rename src/main/java/org/globsframework/core/metamodel/annotations/{IsLink.java => ContainmentLink_.java} (67%) delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DefaultBigDecimalAnnotationType.java rename src/main/java/org/globsframework/core/metamodel/annotations/{FieldNameAnnotation.java => DefaultBigDecimal_.java} (79%) delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DefaultBooleanAnnotationType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DefaultBoolean_.java delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DefaultDoubleAnnotationType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DefaultDouble_.java delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DefaultFieldValue.java delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DefaultIntegerAnnotationType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DefaultInteger_.java delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DefaultLongAnnotationType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DefaultLong_.java delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DefaultStringAnnotationType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DefaultString_.java delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DoublePrecisionAnnotationType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/DoublePrecision_.java delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/EnumAnnotationType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/EnumAnnotation_.java rename src/main/java/org/globsframework/core/metamodel/annotations/{FieldNameAnnotationType.java => FieldName.java} (86%) rename src/main/java/org/globsframework/core/metamodel/annotations/{Encrypted.java => FieldName_.java} (65%) rename src/main/java/org/globsframework/core/metamodel/annotations/{FunctionalFieldOrderType.java => FunctionalFieldOrder.java} (66%) rename src/main/java/org/globsframework/core/metamodel/annotations/{FunctionalFieldOrderAnnotation.java => FunctionalFieldOrder_.java} (78%) rename src/main/java/org/globsframework/core/metamodel/annotations/{IgnoredAnnotationType.java => IgnoredAnnotation.java} (80%) rename src/main/java/org/globsframework/core/metamodel/annotations/{TypedIsDateTime.java => IsDateTime_.java} (91%) rename src/main/java/org/globsframework/core/metamodel/annotations/{TypedIsDate.java => IsDate_.java} (92%) rename src/main/java/org/globsframework/core/metamodel/annotations/{IsTargetType.java => IsTarget.java} (83%) rename src/main/java/org/globsframework/core/metamodel/annotations/{IsTargetType_.java => IsTarget_.java} (81%) delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/KeyAnnotationType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/KeyField_.java delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/LinkModelNameAnnotationType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/LinkModelName_.java delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/MaxSizeType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/MaxSize_.java mode change 100755 => 100644 src/main/java/org/globsframework/core/metamodel/annotations/MultiLineText.java delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/MultiLineTextType.java create mode 100755 src/main/java/org/globsframework/core/metamodel/annotations/MultiLineText_.java rename src/main/java/org/globsframework/core/metamodel/annotations/{NameAnnotation.java => Name.java} (81%) rename src/main/java/org/globsframework/core/metamodel/annotations/{NameAnnotationType.java => NameType.java} (80%) delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/NamingFieldAnnotationType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/NamingField_.java rename src/main/java/org/globsframework/core/metamodel/annotations/{NotUniqueIndexType.java => NotUniqueIndex.java} (75%) delete mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/RequiredAnnotationType.java create mode 100644 src/main/java/org/globsframework/core/metamodel/annotations/Required_.java rename src/test/java/org/globsframework/core/metamodel/annotations/{MaxSizeTypeTest.java => MaxSizeTest.java} (83%) diff --git a/src/main/java/org/globsframework/core/metamodel/Annotations.java b/src/main/java/org/globsframework/core/metamodel/Annotations.java index 17d1934..3110a6f 100644 --- a/src/main/java/org/globsframework/core/metamodel/Annotations.java +++ b/src/main/java/org/globsframework/core/metamodel/Annotations.java @@ -6,6 +6,7 @@ import org.globsframework.core.model.Key; import org.globsframework.core.utils.Ref; +import java.util.Collection; import java.util.Optional; import java.util.stream.Stream; @@ -18,6 +19,8 @@ public interface Annotations { boolean hasAnnotation(Key key); + Collection getAnnotations(); + Glob getAnnotation(Key key); Glob findAnnotation(Key key); diff --git a/src/main/java/org/globsframework/core/metamodel/GlobTypeBuilder.java b/src/main/java/org/globsframework/core/metamodel/GlobTypeBuilder.java index e03ca76..34ac9ad 100644 --- a/src/main/java/org/globsframework/core/metamodel/GlobTypeBuilder.java +++ b/src/main/java/org/globsframework/core/metamodel/GlobTypeBuilder.java @@ -1,6 +1,6 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.KeyAnnotationType; +import org.globsframework.core.metamodel.annotations.KeyField; import org.globsframework.core.metamodel.fields.*; import org.globsframework.core.metamodel.type.DataType; import org.globsframework.core.model.Glob; @@ -12,6 +12,8 @@ public interface GlobTypeBuilder { GlobTypeBuilder addAnnotation(Glob annotation); + GlobTypeBuilder addAnnotations(Collection annotation); + GlobTypeBuilder addStringField(String fieldName, Collection annotations); GlobTypeBuilder addStringArrayField(String fieldName, Collection globAnnotations); @@ -229,7 +231,7 @@ default GlobArrayUnionField declareGlobUnionArrayField(String fieldName, List INSTANCE) + .load(); + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/AutoIncrementAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/AutoIncrementAnnotationType.java deleted file mode 100644 index ed8c44f..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/AutoIncrementAnnotationType.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -public class AutoIncrementAnnotationType { - public static GlobType TYPE; - - @InitUniqueKey - public static Key KEY; - - @InitUniqueGlob - public static Glob INSTANCE; - - static { - GlobTypeLoaderFactory.create(AutoIncrementAnnotationType.class, "AutoIncrement") - .register(GlobCreateFromAnnotation.class, annotation -> INSTANCE) - .load(); - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/AutoIncrement_.java b/src/main/java/org/globsframework/core/metamodel/annotations/AutoIncrement_.java new file mode 100644 index 0000000..835a235 --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/AutoIncrement_.java @@ -0,0 +1,14 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +public @interface AutoIncrement_ { + GlobType TYPE = AutoIncrement.TYPE; +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/CommentType.java b/src/main/java/org/globsframework/core/metamodel/annotations/Comment.java similarity index 93% rename from src/main/java/org/globsframework/core/metamodel/annotations/CommentType.java rename to src/main/java/org/globsframework/core/metamodel/annotations/Comment.java index 14df2b6..2bce266 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/CommentType.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/Comment.java @@ -7,7 +7,7 @@ import org.globsframework.core.model.Glob; import org.globsframework.core.model.Key; -public class CommentType { +public class Comment { public static GlobType TYPE; public static StringField VALUE; @@ -20,7 +20,7 @@ public static Glob create(Comment_ comment) { } static { - GlobTypeLoader loader = GlobTypeLoaderFactory.create(CommentType.class, "Comment"); + GlobTypeLoader loader = GlobTypeLoaderFactory.create(Comment.class, "Comment"); loader.register(GlobCreateFromAnnotation.class, annotation -> create((Comment_) annotation)); loader.load(); } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/Comment_.java b/src/main/java/org/globsframework/core/metamodel/annotations/Comment_.java index 448fd99..d2d1f64 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/Comment_.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/Comment_.java @@ -11,5 +11,5 @@ public @interface Comment_ { String value(); - GlobType TYPE = CommentType.TYPE; + GlobType TYPE = Comment.TYPE; } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/ContainmentLink.java b/src/main/java/org/globsframework/core/metamodel/annotations/ContainmentLink.java index f452eff..c5eb9fc 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/ContainmentLink.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/ContainmentLink.java @@ -1,14 +1,23 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoader; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; +public class ContainmentLink { + public static GlobType TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; + @InitUniqueKey + public static Key UNIQUE_KEY; -@Retention(RUNTIME) -@java.lang.annotation.Target({ElementType.FIELD}) -public @interface ContainmentLink { - GlobType TYPE = ContainmentLinkAnnotationType.DESC; + @InitUniqueGlob + public static Glob UNIQUE_GLOB; + + static { + GlobTypeLoader loader = GlobTypeLoaderFactory.create(ContainmentLink.class, "ContainmentLink"); + loader.register(GlobCreateFromAnnotation.class, annotation -> UNIQUE_GLOB) + .load(); + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/ContainmentLinkAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/ContainmentLinkAnnotationType.java deleted file mode 100644 index cb77570..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/ContainmentLinkAnnotationType.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoader; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -public class ContainmentLinkAnnotationType { - public static GlobType DESC; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - @InitUniqueGlob - public static Glob UNIQUE_GLOB; - - static { - GlobTypeLoader loader = GlobTypeLoaderFactory.create(ContainmentLinkAnnotationType.class); - loader.register(GlobCreateFromAnnotation.class, annotation -> UNIQUE_GLOB) - .load(); - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/IsLink.java b/src/main/java/org/globsframework/core/metamodel/annotations/ContainmentLink_.java similarity index 67% rename from src/main/java/org/globsframework/core/metamodel/annotations/IsLink.java rename to src/main/java/org/globsframework/core/metamodel/annotations/ContainmentLink_.java index 6e683c6..4d7b0fd 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/IsLink.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/ContainmentLink_.java @@ -1,5 +1,7 @@ package org.globsframework.core.metamodel.annotations; +import org.globsframework.core.metamodel.GlobType; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -7,5 +9,6 @@ @Retention(RUNTIME) @java.lang.annotation.Target({ElementType.FIELD}) -public @interface IsLink { +public @interface ContainmentLink_ { + GlobType TYPE = ContainmentLink.TYPE; } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBigDecimal.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBigDecimal.java index 57301fc..aad79ee 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBigDecimal.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBigDecimal.java @@ -1,15 +1,30 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoader; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.metamodel.fields.BigDecimalField; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; +import java.math.BigDecimal; -@Retention(RetentionPolicy.RUNTIME) -@java.lang.annotation.Target({ElementType.FIELD}) -public @interface DefaultBigDecimal { - String value(); +public class DefaultBigDecimal { - GlobType TYPE = DefaultBigDecimalAnnotationType.DESC; + public static GlobType DESC; + + public static BigDecimalField VALUE; + + @InitUniqueKey + public static Key UNIQUE_KEY; + + public static Glob create(String defaultBigDecimal) { + return DESC.instantiate().set(VALUE, new BigDecimal(defaultBigDecimal)); + } + + static { + GlobTypeLoader loader = GlobTypeLoaderFactory.create(DefaultBigDecimal.class, "DefaultBigDecimal"); + loader.register(GlobCreateFromAnnotation.class, annotation -> create(((DefaultBigDecimal_) annotation).value())) + .load(); + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBigDecimalAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBigDecimalAnnotationType.java deleted file mode 100644 index 8067325..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBigDecimalAnnotationType.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoader; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.fields.BigDecimalField; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -import java.math.BigDecimal; - -public class DefaultBigDecimalAnnotationType { - - public static GlobType DESC; - - @DefaultFieldValue - public static BigDecimalField DEFAULT_VALUE; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - public static Glob create(String defaultBigDecimal) { - return DESC.instantiate().set(DEFAULT_VALUE, new BigDecimal(defaultBigDecimal)); - } - - static { - GlobTypeLoader loader = GlobTypeLoaderFactory.create(DefaultBigDecimalAnnotationType.class); - loader.register(GlobCreateFromAnnotation.class, annotation -> create(((DefaultBigDecimal) annotation).value())) - .load(); - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/FieldNameAnnotation.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBigDecimal_.java similarity index 79% rename from src/main/java/org/globsframework/core/metamodel/annotations/FieldNameAnnotation.java rename to src/main/java/org/globsframework/core/metamodel/annotations/DefaultBigDecimal_.java index ce074b5..3296b24 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/FieldNameAnnotation.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBigDecimal_.java @@ -8,8 +8,8 @@ @Retention(RetentionPolicy.RUNTIME) @java.lang.annotation.Target({ElementType.FIELD}) -public @interface FieldNameAnnotation { +public @interface DefaultBigDecimal_ { String value(); - GlobType TYPE = FieldNameAnnotationType.TYPE; + GlobType TYPE = DefaultBigDecimal.DESC; } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBoolean.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBoolean.java index 7711e1b..838c21b 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBoolean.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBoolean.java @@ -1,15 +1,27 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoader; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.metamodel.fields.BooleanField; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; +public class DefaultBoolean { + public static GlobType TYPE; -@Retention(RetentionPolicy.RUNTIME) -@java.lang.annotation.Target({ElementType.FIELD}) -public @interface DefaultBoolean { - boolean value(); + public static BooleanField VALUE; - GlobType TYPE = DefaultBooleanAnnotationType.TYPE; + @InitUniqueKey + public static Key UNIQUE_KEY; + + public static Glob create(DefaultBoolean_ defaultDouble) { + return TYPE.instantiate().set(VALUE, defaultDouble.value()); + } + + static { + GlobTypeLoader loader = GlobTypeLoaderFactory.create(DefaultBoolean.class, "DefaultBoolean"); + loader.register(GlobCreateFromAnnotation.class, annotation -> create((DefaultBoolean_) annotation)) + .load(); + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBooleanAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBooleanAnnotationType.java deleted file mode 100644 index 1f2c61c..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBooleanAnnotationType.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoader; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.fields.BooleanField; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -public class DefaultBooleanAnnotationType { - public static GlobType TYPE; - - @DefaultFieldValue - public static BooleanField DEFAULT_VALUE; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - public static Glob create(DefaultBoolean defaultDouble) { - return TYPE.instantiate().set(DEFAULT_VALUE, defaultDouble.value()); - } - - static { - GlobTypeLoader loader = GlobTypeLoaderFactory.create(DefaultBooleanAnnotationType.class); - loader.register(GlobCreateFromAnnotation.class, annotation -> create((DefaultBoolean) annotation)) - .load(); - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBoolean_.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBoolean_.java new file mode 100644 index 0000000..6b487f2 --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultBoolean_.java @@ -0,0 +1,15 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@java.lang.annotation.Target({ElementType.FIELD}) +public @interface DefaultBoolean_ { + boolean value(); + + GlobType TYPE = DefaultBoolean.TYPE; +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultDouble.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultDouble.java index 2e5c191..1f09223 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultDouble.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultDouble.java @@ -1,16 +1,27 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoader; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.metamodel.fields.DoubleField; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; +public class DefaultDouble { + public static GlobType TYPE; -@Retention(RetentionPolicy.RUNTIME) -@java.lang.annotation.Target({ElementType.FIELD}) + public static DoubleField VALUE; -public @interface DefaultDouble { - double value(); + @InitUniqueKey + public static Key UNIQUE_KEY; - GlobType TYPE = DefaultDoubleAnnotationType.DESC; + public static Glob create(double defaultDouble) { + return TYPE.instantiate().set(VALUE, defaultDouble); + } + + static { + GlobTypeLoader loader = GlobTypeLoaderFactory.create(DefaultDouble.class, "DefaultDouble"); + loader.register(GlobCreateFromAnnotation.class, annotation -> create(((DefaultDouble_) annotation).value())) + .load(); + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultDoubleAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultDoubleAnnotationType.java deleted file mode 100644 index fdd4256..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultDoubleAnnotationType.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoader; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.fields.DoubleField; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -public class DefaultDoubleAnnotationType { - public static GlobType DESC; - - @DefaultFieldValue - public static DoubleField DEFAULT_VALUE; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - public static Glob create(double defaultDouble) { - return DESC.instantiate().set(DEFAULT_VALUE, defaultDouble); - } - - static { - GlobTypeLoader loader = GlobTypeLoaderFactory.create(DefaultDoubleAnnotationType.class); - loader.register(GlobCreateFromAnnotation.class, annotation -> create(((DefaultDouble) annotation).value())) - .load(); - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultDouble_.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultDouble_.java new file mode 100644 index 0000000..290000d --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultDouble_.java @@ -0,0 +1,16 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@java.lang.annotation.Target({ElementType.FIELD}) + +public @interface DefaultDouble_ { + double value(); + + GlobType TYPE = DefaultDouble.TYPE; +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultFieldValue.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultFieldValue.java deleted file mode 100644 index 2541b4f..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultFieldValue.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -public @interface DefaultFieldValue { -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultInteger.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultInteger.java index 879e0e5..137c29d 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultInteger.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultInteger.java @@ -1,15 +1,27 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.metamodel.fields.IntegerField; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; +public class DefaultInteger { + public static GlobType TYPE; -@Retention(RetentionPolicy.RUNTIME) -@java.lang.annotation.Target({ElementType.FIELD}) -public @interface DefaultInteger { - int value(); + public static IntegerField VALUE; + + @InitUniqueKey + public static Key UNIQUE_KEY; + + public static Glob create(DefaultInteger_ defaultDouble) { + return TYPE.instantiate().set(VALUE, defaultDouble.value()); + } + + static { + GlobTypeLoaderFactory.create(DefaultInteger.class, "DefaultInteger") + .register(GlobCreateFromAnnotation.class, annotation -> create((DefaultInteger_) annotation)) + .load(); + } - GlobType GLOB_TYPE = DefaultIntegerAnnotationType.DESC; } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultIntegerAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultIntegerAnnotationType.java deleted file mode 100644 index f56791e..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultIntegerAnnotationType.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.fields.IntegerField; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -public class DefaultIntegerAnnotationType { - public static GlobType DESC; - - public static IntegerField DEFAULT_VALUE; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - public static Glob create(DefaultInteger defaultDouble) { - return DESC.instantiate().set(DEFAULT_VALUE, defaultDouble.value()); - } - - static { - GlobTypeLoaderFactory.create(DefaultIntegerAnnotationType.class, "defaultIntegerValue") - .register(GlobCreateFromAnnotation.class, annotation -> create((DefaultInteger) annotation)) - .load(); - } - -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultInteger_.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultInteger_.java new file mode 100644 index 0000000..4a61e4e --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultInteger_.java @@ -0,0 +1,15 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@java.lang.annotation.Target({ElementType.FIELD}) +public @interface DefaultInteger_ { + int value(); + + GlobType GLOB_TYPE = DefaultInteger.TYPE; +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultLong.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultLong.java index 6be427a..6623008 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultLong.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultLong.java @@ -1,15 +1,27 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoader; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.metamodel.fields.LongField; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; +public class DefaultLong { + public static GlobType TYPE; -@Retention(RetentionPolicy.RUNTIME) -@java.lang.annotation.Target({ElementType.FIELD}) -public @interface DefaultLong { - long value(); + public static LongField VALUE; - GlobType TYPE = DefaultLongAnnotationType.DESC; + @InitUniqueKey + public static Key UNIQUE_KEY; + + public static Glob create(DefaultLong_ defaultLong) { + return TYPE.instantiate().set(VALUE, defaultLong.value()); + } + + static { + GlobTypeLoader loader = GlobTypeLoaderFactory.create(DefaultLong.class, "DefaultLong"); + loader.register(GlobCreateFromAnnotation.class, annotation -> create((DefaultLong_) annotation)) + .load(); + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultLongAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultLongAnnotationType.java deleted file mode 100644 index c444fe5..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultLongAnnotationType.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoader; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.fields.LongField; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -public class DefaultLongAnnotationType { - public static GlobType DESC; - - public static LongField DEFAULT_VALUE; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - public static Glob create(DefaultLong defaultLong) { - return DESC.instantiate().set(DEFAULT_VALUE, defaultLong.value()); - } - - static { - GlobTypeLoader loader = GlobTypeLoaderFactory.create(DefaultLongAnnotationType.class); - loader.register(GlobCreateFromAnnotation.class, annotation -> create((DefaultLong) annotation)) - .load(); - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultLong_.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultLong_.java new file mode 100644 index 0000000..73d1d87 --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultLong_.java @@ -0,0 +1,15 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@java.lang.annotation.Target({ElementType.FIELD}) +public @interface DefaultLong_ { + long value(); + + GlobType TYPE = DefaultLong.TYPE; +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultString.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultString.java index 4cadecd..bc32f32 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultString.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultString.java @@ -1,15 +1,27 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoader; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.metamodel.fields.StringField; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; +public class DefaultString { + public static GlobType TYPE; -@Retention(RetentionPolicy.RUNTIME) -@java.lang.annotation.Target({ElementType.FIELD}) -public @interface DefaultString { - String value(); + public static StringField VALUE; - GlobType TYPE = DefaultStringAnnotationType.DESC; + @InitUniqueKey + public static Key UNIQUE_KEY; + + public static Glob create(DefaultString_ defaultString) { + return TYPE.instantiate().set(VALUE, defaultString.value()); + } + + static { + GlobTypeLoader loader = GlobTypeLoaderFactory.create(DefaultString.class, "DefaultString"); + loader.register(GlobCreateFromAnnotation.class, annotation -> create((DefaultString_) annotation)); + loader.load(); + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultStringAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultStringAnnotationType.java deleted file mode 100644 index f0c7f8a..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultStringAnnotationType.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoader; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.fields.StringField; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -public class DefaultStringAnnotationType { - public static GlobType DESC; - - public static StringField DEFAULT_VALUE; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - public static Glob create(DefaultString defaultString) { - return DESC.instantiate().set(DEFAULT_VALUE, defaultString.value()); - } - - static { - GlobTypeLoader loader = GlobTypeLoaderFactory.create(DefaultStringAnnotationType.class); - loader.register(GlobCreateFromAnnotation.class, annotation -> create((DefaultString) annotation)); - loader.load(); - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DefaultString_.java b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultString_.java new file mode 100644 index 0000000..76ca09e --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DefaultString_.java @@ -0,0 +1,15 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@java.lang.annotation.Target({ElementType.FIELD}) +public @interface DefaultString_ { + String value(); + + GlobType TYPE = DefaultString.TYPE; +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DoublePrecision.java b/src/main/java/org/globsframework/core/metamodel/annotations/DoublePrecision.java index 6006559..d4c6b6d 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DoublePrecision.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DoublePrecision.java @@ -1,15 +1,27 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoader; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.metamodel.fields.IntegerField; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; +public class DoublePrecision { + public static GlobType TYPE; -@Retention(RetentionPolicy.RUNTIME) -@java.lang.annotation.Target({ElementType.FIELD}) -public @interface DoublePrecision { - int value(); + public static IntegerField PRECISION; - GlobType TYPE = DoublePrecisionAnnotationType.DESC; + @InitUniqueKey + public static Key UNIQUE_KEY; + + public static Glob create(DoublePrecision_ precision) { + return TYPE.instantiate().set(PRECISION, precision.value()); + } + + static { + GlobTypeLoader loader = GlobTypeLoaderFactory.create(DoublePrecision.class, "DoublePrecision"); + loader.register(GlobCreateFromAnnotation.class, annotation -> create((DoublePrecision_) annotation)); + loader.load(); + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DoublePrecisionAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/DoublePrecisionAnnotationType.java deleted file mode 100644 index 262fe3d..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/DoublePrecisionAnnotationType.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoader; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.fields.IntegerField; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -public class DoublePrecisionAnnotationType { - public static GlobType DESC; - - public static IntegerField PRECISION; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - public static Glob create(DoublePrecision precision) { - return DESC.instantiate().set(PRECISION, precision.value()); - } - - static { - GlobTypeLoader loader = GlobTypeLoaderFactory.create(DoublePrecisionAnnotationType.class); - loader.register(GlobCreateFromAnnotation.class, annotation -> create((DoublePrecision) annotation)); - loader.load(); - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/DoublePrecision_.java b/src/main/java/org/globsframework/core/metamodel/annotations/DoublePrecision_.java new file mode 100644 index 0000000..4b68a51 --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/DoublePrecision_.java @@ -0,0 +1,15 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@java.lang.annotation.Target({ElementType.FIELD}) +public @interface DoublePrecision_ { + int value(); + + GlobType TYPE = DoublePrecision.TYPE; +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/EnumAnnotation.java b/src/main/java/org/globsframework/core/metamodel/annotations/EnumAnnotation.java index f9b5c13..f358027 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/EnumAnnotation.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/EnumAnnotation.java @@ -1,15 +1,43 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.metamodel.fields.Field; +import org.globsframework.core.metamodel.fields.StringArrayField; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; +import org.globsframework.core.model.MutableGlob; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; +import java.util.Optional; -@Retention(RetentionPolicy.RUNTIME) -@java.lang.annotation.Target({ElementType.FIELD}) -public @interface EnumAnnotation { - String[] value(); +public class EnumAnnotation { + public static GlobType TYPE; - GlobType TYPE = EnumAnnotationType.TYPE; + public static StringArrayField NAME; + + @InitUniqueKey + public static Key UNIQUE_KEY; + + static { + GlobTypeLoaderFactory.create(EnumAnnotation.class, "EnumAnnotation") + .register(GlobCreateFromAnnotation.class, annotation -> TYPE.instantiate() + .set(NAME, ((EnumAnnotation_) annotation).value())) + .load(); + } + + public static Glob create(EnumAnnotation_ nameAnnotation) { + return create(nameAnnotation.value()); + } + + public static MutableGlob create(String[] value) { + return TYPE.instantiate().set(NAME, value); + } + + public static Optional listEnums(Field field) { + Glob annotation = field.findAnnotation(UNIQUE_KEY); + if (annotation != null) { + return Optional.of(annotation.get(NAME)); + } + return Optional.empty(); + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/EnumAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/EnumAnnotationType.java deleted file mode 100644 index 4a1d63f..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/EnumAnnotationType.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.fields.Field; -import org.globsframework.core.metamodel.fields.StringArrayField; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; -import org.globsframework.core.model.MutableGlob; - -import java.util.Optional; - -public class EnumAnnotationType { - public static GlobType TYPE; - - public static StringArrayField NAME; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - static { - GlobTypeLoaderFactory.create(EnumAnnotationType.class) - .register(GlobCreateFromAnnotation.class, annotation -> TYPE.instantiate() - .set(NAME, ((EnumAnnotation) annotation).value())) - .load(); - } - - public static Glob create(EnumAnnotation nameAnnotation) { - return create(nameAnnotation.value()); - } - - public static MutableGlob create(String[] value) { - return TYPE.instantiate().set(NAME, value); - } - - public static Optional listEnums(Field field) { - Glob annotation = field.findAnnotation(UNIQUE_KEY); - if (annotation != null) { - return Optional.of(annotation.get(NAME)); - } - return Optional.empty(); - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/EnumAnnotation_.java b/src/main/java/org/globsframework/core/metamodel/annotations/EnumAnnotation_.java new file mode 100644 index 0000000..2df699e --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/EnumAnnotation_.java @@ -0,0 +1,15 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +@java.lang.annotation.Target({ElementType.FIELD}) +public @interface EnumAnnotation_ { + String[] value(); + + GlobType TYPE = EnumAnnotation.TYPE; +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/FieldNameAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/FieldName.java similarity index 86% rename from src/main/java/org/globsframework/core/metamodel/annotations/FieldNameAnnotationType.java rename to src/main/java/org/globsframework/core/metamodel/annotations/FieldName.java index 2b56cc6..f61170e 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/FieldNameAnnotationType.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/FieldName.java @@ -12,14 +12,14 @@ import java.util.LinkedHashMap; -public class FieldNameAnnotationType { +public class FieldName { public static final GlobType TYPE; public static final StringField NAME; public static final Key UNIQUE_KEY; - public static Glob create(FieldNameAnnotation nameAnnotation) { + public static Glob create(FieldName_ nameAnnotation) { return create(nameAnnotation.value()); } @@ -28,14 +28,14 @@ public static MutableGlob create(String value) { } static { - DefaultGlobType globType = new DefaultGlobType("fieldNameAnnotation"); + DefaultGlobType globType = new DefaultGlobType("FieldName"); DefaultFieldFactory factory = new DefaultFieldFactory(globType); TYPE = globType; NAME = factory.addString("name", false, 0, 0, null, new LinkedHashMap<>()); globType.completeInit(); UNIQUE_KEY = KeyBuilder.newEmptyKey(TYPE); NAME.addAnnotation(create("name")); - globType.register(GlobCreateFromAnnotation.class, annotation -> create((FieldNameAnnotation) annotation)); + globType.register(GlobCreateFromAnnotation.class, annotation -> create((FieldName_) annotation)); } public static String getName(Field field) { diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/Encrypted.java b/src/main/java/org/globsframework/core/metamodel/annotations/FieldName_.java similarity index 65% rename from src/main/java/org/globsframework/core/metamodel/annotations/Encrypted.java rename to src/main/java/org/globsframework/core/metamodel/annotations/FieldName_.java index 62e9b0e..0100e09 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/Encrypted.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/FieldName_.java @@ -1,10 +1,15 @@ package org.globsframework.core.metamodel.annotations; +import org.globsframework.core.metamodel.GlobType; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) @java.lang.annotation.Target({ElementType.FIELD}) -public @interface Encrypted { +public @interface FieldName_ { + String value(); + + GlobType TYPE = FieldName.TYPE; } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/FunctionalFieldOrderType.java b/src/main/java/org/globsframework/core/metamodel/annotations/FunctionalFieldOrder.java similarity index 66% rename from src/main/java/org/globsframework/core/metamodel/annotations/FunctionalFieldOrderType.java rename to src/main/java/org/globsframework/core/metamodel/annotations/FunctionalFieldOrder.java index cba6f68..b963812 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/FunctionalFieldOrderType.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/FunctionalFieldOrder.java @@ -6,7 +6,7 @@ import org.globsframework.core.metamodel.fields.StringField; import org.globsframework.core.model.Key; -public class FunctionalFieldOrderType { +public class FunctionalFieldOrder { public static GlobType TYPE; public static StringField NAME; @@ -17,10 +17,10 @@ public class FunctionalFieldOrderType { public static Key KEY; static { - GlobTypeLoaderFactory.create(FunctionalFieldOrderType.class, "FunctionalFieldOrder") + GlobTypeLoaderFactory.create(FunctionalFieldOrder.class, "FunctionalFieldOrder") .register(GlobCreateFromAnnotation.class, annotation -> TYPE.instantiate() - .set(ORDER, ((FunctionalFieldOrderAnnotation) annotation).value()) - .set(NAME, ((FunctionalFieldOrderAnnotation) annotation).name())) + .set(ORDER, ((FunctionalFieldOrder_) annotation).value()) + .set(NAME, ((FunctionalFieldOrder_) annotation).name())) .load(); } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/FunctionalFieldOrderAnnotation.java b/src/main/java/org/globsframework/core/metamodel/annotations/FunctionalFieldOrder_.java similarity index 78% rename from src/main/java/org/globsframework/core/metamodel/annotations/FunctionalFieldOrderAnnotation.java rename to src/main/java/org/globsframework/core/metamodel/annotations/FunctionalFieldOrder_.java index 462dcaa..8999e1d 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/FunctionalFieldOrderAnnotation.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/FunctionalFieldOrder_.java @@ -8,10 +8,10 @@ @Retention(RetentionPolicy.RUNTIME) @java.lang.annotation.Target({ElementType.FIELD}) -public @interface FunctionalFieldOrderAnnotation { +public @interface FunctionalFieldOrder_ { int value(); String name() default ""; - GlobType TYPE = FunctionalFieldOrderType.TYPE; + GlobType TYPE = FunctionalFieldOrder.TYPE; } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/IgnoredAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/IgnoredAnnotation.java similarity index 80% rename from src/main/java/org/globsframework/core/metamodel/annotations/IgnoredAnnotationType.java rename to src/main/java/org/globsframework/core/metamodel/annotations/IgnoredAnnotation.java index 283dc86..9e911fd 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/IgnoredAnnotationType.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/IgnoredAnnotation.java @@ -5,7 +5,7 @@ import org.globsframework.core.model.Glob; import org.globsframework.core.model.Key; -public class IgnoredAnnotationType { +public class IgnoredAnnotation { public static GlobType TYPE; @InitUniqueKey @@ -15,7 +15,7 @@ public class IgnoredAnnotationType { public static Glob INSTANCE; static { - GlobTypeLoaderFactory.create(IgnoredAnnotationType.class, "IgnoredAnnotationType") + GlobTypeLoaderFactory.create(IgnoredAnnotation.class, "IgnoredAnnotation") .register(GlobCreateFromAnnotation.class, annotation -> INSTANCE) .load(); } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/IsDate.java b/src/main/java/org/globsframework/core/metamodel/annotations/IsDate.java index c603920..59bee33 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/IsDate.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/IsDate.java @@ -17,7 +17,7 @@ public class IsDate { public static Glob UNIQUE; static { - GlobTypeLoaderFactory.create(IsDate.class) + GlobTypeLoaderFactory.create(IsDate.class, "IsDate") .register(GlobCreateFromAnnotation.class, annotation -> UNIQUE) .load(); } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/IsDateTime.java b/src/main/java/org/globsframework/core/metamodel/annotations/IsDateTime.java index 530f63c..43c9ee6 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/IsDateTime.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/IsDateTime.java @@ -17,7 +17,7 @@ public class IsDateTime { public static Glob UNIQUE; static { - GlobTypeLoaderFactory.create(IsDateTime.class) + GlobTypeLoaderFactory.create(IsDateTime.class, "IsDateTime") .register(GlobCreateFromAnnotation.class, annotation -> UNIQUE) .load(); } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/TypedIsDateTime.java b/src/main/java/org/globsframework/core/metamodel/annotations/IsDateTime_.java similarity index 91% rename from src/main/java/org/globsframework/core/metamodel/annotations/TypedIsDateTime.java rename to src/main/java/org/globsframework/core/metamodel/annotations/IsDateTime_.java index 17c6735..339d682 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/TypedIsDateTime.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/IsDateTime_.java @@ -10,6 +10,6 @@ @Retention(RUNTIME) @Target({ElementType.FIELD}) -public @interface TypedIsDateTime { +public @interface IsDateTime_ { GlobType TYPE = IsDateTime.TYPE; } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/TypedIsDate.java b/src/main/java/org/globsframework/core/metamodel/annotations/IsDate_.java similarity index 92% rename from src/main/java/org/globsframework/core/metamodel/annotations/TypedIsDate.java rename to src/main/java/org/globsframework/core/metamodel/annotations/IsDate_.java index 9183413..38f7b5a 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/TypedIsDate.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/IsDate_.java @@ -10,7 +10,7 @@ @Retention(RUNTIME) @Target({ElementType.FIELD}) -public @interface TypedIsDate { +public @interface IsDate_ { GlobType TYPE = IsDate.TYPE; } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/IsTargetType.java b/src/main/java/org/globsframework/core/metamodel/annotations/IsTarget.java similarity index 83% rename from src/main/java/org/globsframework/core/metamodel/annotations/IsTargetType.java rename to src/main/java/org/globsframework/core/metamodel/annotations/IsTarget.java index 6ebd95a..5e4e53b 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/IsTargetType.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/IsTarget.java @@ -5,7 +5,7 @@ import org.globsframework.core.model.Glob; import org.globsframework.core.model.Key; -public class IsTargetType { +public class IsTarget { public static GlobType TYPE; @InitUniqueKey @@ -15,7 +15,7 @@ public class IsTargetType { public static Glob INSTANCE; static { - GlobTypeLoaderFactory.create(IsTargetType.class, "IsTargetType") + GlobTypeLoaderFactory.create(IsTarget.class, "IsTarget") .register(GlobCreateFromAnnotation.class, annotation -> INSTANCE) .load(); } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/IsTargetType_.java b/src/main/java/org/globsframework/core/metamodel/annotations/IsTarget_.java similarity index 81% rename from src/main/java/org/globsframework/core/metamodel/annotations/IsTargetType_.java rename to src/main/java/org/globsframework/core/metamodel/annotations/IsTarget_.java index 1c2d1b0..faa0b7b 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/IsTargetType_.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/IsTarget_.java @@ -9,7 +9,7 @@ @Retention(RUNTIME) @java.lang.annotation.Target({ElementType.FIELD}) -public @interface IsTargetType_ { +public @interface IsTarget_ { - GlobType TYPE = IsTargetType.TYPE; + GlobType TYPE = IsTarget.TYPE; } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/KeyAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/KeyAnnotationType.java deleted file mode 100644 index c09d338..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/KeyAnnotationType.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.fields.IntegerField; -import org.globsframework.core.metamodel.impl.DefaultFieldFactory; -import org.globsframework.core.metamodel.impl.DefaultGlobType; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; -import org.globsframework.core.model.KeyBuilder; - -import java.util.LinkedHashMap; - -public class KeyAnnotationType { - public static GlobType TYPE; - - public static IntegerField INDEX; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - public static Glob UNINITIALIZED; - - public static Glob ZERO; - - public static Glob ONE; - - public static Glob TWO; - - public static Glob THREE; - - public static Glob FOUR; - - public static Glob create(int indexOfKeyField) { - switch (indexOfKeyField) { - case 0: - return ZERO; - case 1: - return ONE; - case 2: - return TWO; - case 3: - return THREE; - case 4: - return FOUR; - default: - return TYPE.instantiate().set(INDEX, indexOfKeyField); - } - } - - static { - DefaultGlobType globType = new DefaultGlobType("KeyAnnotation"); - DefaultFieldFactory factory = new DefaultFieldFactory(globType); - TYPE = globType; - INDEX = factory.addInteger("index", false, 0, 0, null, new LinkedHashMap<>()); - UNIQUE_KEY = KeyBuilder.newEmptyKey(TYPE); - globType.completeInit(); - UNINITIALIZED = globType.instantiate().set(INDEX, -1); - ZERO = globType.instantiate().set(INDEX, 0); - ONE = globType.instantiate().set(INDEX, 1); - TWO = globType.instantiate().set(INDEX, 2); - THREE = globType.instantiate().set(INDEX, 3); - FOUR = globType.instantiate().set(INDEX, 4); - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/KeyField.java b/src/main/java/org/globsframework/core/metamodel/annotations/KeyField.java index 1a3c468..0730209 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/KeyField.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/KeyField.java @@ -1,16 +1,64 @@ package org.globsframework.core.metamodel.annotations; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; +import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.fields.IntegerField; +import org.globsframework.core.metamodel.impl.DefaultFieldFactory; +import org.globsframework.core.metamodel.impl.DefaultGlobType; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; +import org.globsframework.core.model.KeyBuilder; -import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.util.LinkedHashMap; -@Retention(RUNTIME) -@Target({ElementType.FIELD}) -@NoType -public @interface KeyField { +public class KeyField { + public static GlobType TYPE; - int value() default -1; + public static IntegerField INDEX; + @InitUniqueKey + public static Key UNIQUE_KEY; + + public static Glob UNINITIALIZED; + + public static Glob ZERO; + + public static Glob ONE; + + public static Glob TWO; + + public static Glob THREE; + + public static Glob FOUR; + + public static Glob create(int indexOfKeyField) { + switch (indexOfKeyField) { + case 0: + return ZERO; + case 1: + return ONE; + case 2: + return TWO; + case 3: + return THREE; + case 4: + return FOUR; + default: + return TYPE.instantiate().set(INDEX, indexOfKeyField); + } + } + + static { + DefaultGlobType globType = new DefaultGlobType("KeyField"); + DefaultFieldFactory factory = new DefaultFieldFactory(globType); + TYPE = globType; + INDEX = factory.addInteger("index", false, 0, 0, null, null); + UNIQUE_KEY = KeyBuilder.newEmptyKey(TYPE); + globType.completeInit(); + UNINITIALIZED = globType.instantiate().set(INDEX, -1); + ZERO = globType.instantiate().set(INDEX, 0); + ONE = globType.instantiate().set(INDEX, 1); + TWO = globType.instantiate().set(INDEX, 2); + THREE = globType.instantiate().set(INDEX, 3); + FOUR = globType.instantiate().set(INDEX, 4); + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/KeyField_.java b/src/main/java/org/globsframework/core/metamodel/annotations/KeyField_.java new file mode 100644 index 0000000..ade828e --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/KeyField_.java @@ -0,0 +1,16 @@ +package org.globsframework.core.metamodel.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Retention(RUNTIME) +@Target({ElementType.FIELD}) +@NoType +public @interface KeyField_ { + + int value() default -1; + +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/LinkModelName.java b/src/main/java/org/globsframework/core/metamodel/annotations/LinkModelName.java index 907bb3f..d676aaa 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/LinkModelName.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/LinkModelName.java @@ -1,17 +1,28 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.metamodel.fields.StringField; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; +import java.lang.annotation.Annotation; -import static java.lang.annotation.RetentionPolicy.RUNTIME; +public class LinkModelName { + public static GlobType TYPE; -@Retention(RUNTIME) -@java.lang.annotation.Target({ElementType.FIELD}) + public static StringField NAME; -public @interface LinkModelName { - String value(); + @InitUniqueKey + public static Key UNIQUE_KEY; - GlobType TYPE = LinkModelNameAnnotationType.TYPE; + static { + GlobTypeLoaderFactory.create(LinkModelName.class, "LinkModelName") + .register(GlobCreateFromAnnotation.class, LinkModelName::create) + .load(); + } + + private static Glob create(Annotation annotation) { + return TYPE.instantiate().set(NAME, ((LinkModelName_) annotation).value()); + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/LinkModelNameAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/LinkModelNameAnnotationType.java deleted file mode 100644 index d439f4a..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/LinkModelNameAnnotationType.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.fields.StringField; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -import java.lang.annotation.Annotation; - -public class LinkModelNameAnnotationType { - public static GlobType TYPE; - - public static StringField NAME; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - static { - GlobTypeLoaderFactory.create(LinkModelNameAnnotationType.class) - .register(GlobCreateFromAnnotation.class, LinkModelNameAnnotationType::create) - .load(); - } - - private static Glob create(Annotation annotation) { - return TYPE.instantiate().set(NAME, ((LinkModelName) annotation).value()); - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/LinkModelName_.java b/src/main/java/org/globsframework/core/metamodel/annotations/LinkModelName_.java new file mode 100644 index 0000000..d2d2f95 --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/LinkModelName_.java @@ -0,0 +1,17 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Retention(RUNTIME) +@java.lang.annotation.Target({ElementType.FIELD}) + +public @interface LinkModelName_ { + String value(); + + GlobType TYPE = LinkModelName.TYPE; +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/MaxSize.java b/src/main/java/org/globsframework/core/metamodel/annotations/MaxSize.java index 67b4cfe..e64311f 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/MaxSize.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/MaxSize.java @@ -1,24 +1,115 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoader; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.metamodel.fields.*; +import org.globsframework.core.model.FieldValuesAccessor; +import org.globsframework.core.model.Glob; import org.globsframework.core.model.Key; +import org.globsframework.core.model.MutableGlob; +import org.globsframework.core.utils.Strings; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.nio.charset.Charset; -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD}) -public @interface MaxSize { - int value(); +public class MaxSize { + static public GlobType TYPE; - boolean allow_truncate() default false; + static public IntegerField VALUE; - String charSet() default "UTF-8"; + static public BooleanField ALLOW_TRUNCATE; - GlobType GLOB_TYPE = MaxSizeType.TYPE; + static public StringField CHARSET; - Key KEY = MaxSizeType.KEY; + @InitUniqueKey + static public Key KEY; + static { + GlobTypeLoader loader = GlobTypeLoaderFactory.create(MaxSize.class, "MaxSize"); + loader.register(GlobCreateFromAnnotation.class, annotation -> create((MaxSize_) annotation)) + .load(); + } + + static public String cut(Field field, FieldValuesAccessor value) { + return value.getOpt(field.asStringField()) + .map(s -> cut(field, s)) + .orElse(null); + } + + static public String cut(Field field, String value) { + Glob annotation = field.findAnnotation(KEY); + if (annotation != null && Strings.isNotEmpty(value) && annotation.get(VALUE) > 0) { + Charset charsetName = Charset.forName(annotation.get(CHARSET)); + if (value.getBytes(charsetName).length > annotation.get(VALUE)) { + if (annotation.get(ALLOW_TRUNCATE, false)) { + String substring = value.substring(0, Math.min(value.length(), annotation.get(VALUE))); + while (substring.getBytes(charsetName).length > annotation.get(VALUE)) { + substring = substring.substring(0, substring.length() - 1); + } + return substring; + } else { + throw new StringToLongException(field.getFullName() + " => " + value); + } + } else { + return value; + } + } + return value; + } + + static public boolean checkSize(Field field, String value) { + Glob annotation = field.findAnnotation(KEY); + if (annotation != null && Strings.isNotEmpty(value)) { + if (value.length() > annotation.get(VALUE)) { + return false; + } + } + return true; + } + + public static Glob create(MaxSize_ size) { + return TYPE.instantiate().set(VALUE, size.value()) + .set(ALLOW_TRUNCATE, size.allow_truncate()) + .set(CHARSET, size.charSet()); + } + + public static MutableGlob deepInPlaceTruncate(MutableGlob glob) { + if (glob != null) { + GlobType type = glob.getType(); + for (Field field : type.getFields()) { + if (field instanceof StringField) { + StringField stringField = field.asStringField(); + glob.set(stringField, cut(field, glob.get(stringField))); + } else if (field instanceof StringArrayField) { + String[] strings = glob.get((StringArrayField) field); + if (strings != null) { + for (int i = 0; i < strings.length; i++) { + strings[i] = cut(field, strings[i]); + } + } + } else if (field instanceof GlobField) { + deepInPlaceTruncate((MutableGlob) glob.get((GlobField) field)); + } else if (field instanceof GlobArrayField) { + Glob[] globs = glob.get(((GlobArrayField) field)); + for (Glob value : globs) { + deepInPlaceTruncate((MutableGlob) value); + } + } else if (field instanceof GlobUnionField) { + deepInPlaceTruncate((MutableGlob) glob.get((GlobUnionField) field)); + } else if (field instanceof GlobArrayUnionField) { + Glob[] globs = glob.get(((GlobArrayUnionField) field)); + for (Glob value : globs) { + deepInPlaceTruncate((MutableGlob) value); + } + } + } + } + return glob; + } + + static class StringToLongException extends RuntimeException { + public StringToLongException(String value) { + super(value); + } + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/MaxSizeType.java b/src/main/java/org/globsframework/core/metamodel/annotations/MaxSizeType.java deleted file mode 100644 index 1de683a..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/MaxSizeType.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoader; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.fields.*; -import org.globsframework.core.model.FieldValuesAccessor; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; -import org.globsframework.core.model.MutableGlob; -import org.globsframework.core.utils.Strings; - -import java.nio.charset.Charset; - -public class MaxSizeType { - static public GlobType TYPE; - - @DefaultFieldValue - static public IntegerField VALUE; - - static public BooleanField ALLOW_TRUNCATE; - - static public StringField CHARSET; - - @InitUniqueKey - static public Key KEY; - - static { - GlobTypeLoader loader = GlobTypeLoaderFactory.create(MaxSizeType.class); - loader.register(GlobCreateFromAnnotation.class, annotation -> create((MaxSize) annotation)) - .load(); - } - - static public String cut(Field field, FieldValuesAccessor value) { - return value.getOpt(field.asStringField()) - .map(s -> cut(field, s)) - .orElse(null); - } - - static public String cut(Field field, String value) { - Glob annotation = field.findAnnotation(KEY); - if (annotation != null && Strings.isNotEmpty(value) && annotation.get(VALUE) > 0) { - Charset charsetName = Charset.forName(annotation.get(CHARSET)); - if (value.getBytes(charsetName).length > annotation.get(VALUE)) { - if (annotation.get(ALLOW_TRUNCATE, false)) { - String substring = value.substring(0, Math.min(value.length(), annotation.get(VALUE))); - while (substring.getBytes(charsetName).length > annotation.get(VALUE)) { - substring = substring.substring(0, substring.length() - 1); - } - return substring; - } else { - throw new StringToLongException(field.getFullName() + " => " + value); - } - } else { - return value; - } - } - return value; - } - - static public boolean checkSize(Field field, String value) { - Glob annotation = field.findAnnotation(KEY); - if (annotation != null && Strings.isNotEmpty(value)) { - if (value.length() > annotation.get(VALUE)) { - return false; - } - } - return true; - } - - public static Glob create(MaxSize size) { - return TYPE.instantiate().set(VALUE, size.value()) - .set(ALLOW_TRUNCATE, size.allow_truncate()) - .set(CHARSET, size.charSet()); - } - - public static MutableGlob deepInPlaceTruncate(MutableGlob glob) { - if (glob != null) { - GlobType type = glob.getType(); - for (Field field : type.getFields()) { - if (field instanceof StringField) { - StringField stringField = field.asStringField(); - glob.set(stringField, cut(field, glob.get(stringField))); - } else if (field instanceof StringArrayField) { - String[] strings = glob.get((StringArrayField) field); - if (strings != null) { - for (int i = 0; i < strings.length; i++) { - strings[i] = cut(field, strings[i]); - } - } - } else if (field instanceof GlobField) { - deepInPlaceTruncate((MutableGlob) glob.get((GlobField) field)); - } else if (field instanceof GlobArrayField) { - Glob[] globs = glob.get(((GlobArrayField) field)); - for (Glob value : globs) { - deepInPlaceTruncate((MutableGlob) value); - } - } else if (field instanceof GlobUnionField) { - deepInPlaceTruncate((MutableGlob) glob.get((GlobUnionField) field)); - } else if (field instanceof GlobArrayUnionField) { - Glob[] globs = glob.get(((GlobArrayUnionField) field)); - for (Glob value : globs) { - deepInPlaceTruncate((MutableGlob) value); - } - } - } - } - return glob; - } - - static class StringToLongException extends RuntimeException { - public StringToLongException(String value) { - super(value); - } - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/MaxSize_.java b/src/main/java/org/globsframework/core/metamodel/annotations/MaxSize_.java new file mode 100644 index 0000000..864fd89 --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/MaxSize_.java @@ -0,0 +1,24 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.model.Key; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD}) +public @interface MaxSize_ { + int value(); + + boolean allow_truncate() default false; + + String charSet() default "UTF-8"; + + GlobType GLOB_TYPE = MaxSize.TYPE; + + Key KEY = MaxSize.KEY; + +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/MultiLineText.java b/src/main/java/org/globsframework/core/metamodel/annotations/MultiLineText.java old mode 100755 new mode 100644 index 299bbf2..bf0dbb8 --- a/src/main/java/org/globsframework/core/metamodel/annotations/MultiLineText.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/MultiLineText.java @@ -1,19 +1,34 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.metamodel.fields.IntegerField; +import org.globsframework.core.metamodel.fields.StringField; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; +import java.lang.annotation.Annotation; -import static java.lang.annotation.RetentionPolicy.RUNTIME; +public class MultiLineText { + public static GlobType TYPE; -@Retention(RUNTIME) -@java.lang.annotation.Target({ElementType.FIELD}) -public @interface MultiLineText { + public static StringField mimeType; - String mimeType() default "text/plain"; + public static IntegerField maxSize; - int maxSize() default -1; + @InitUniqueKey + public static Key UNIQUE_KEY; - GlobType TYPE = MultiLineTextType.TYPE; + static { + GlobTypeLoaderFactory.create(MultiLineText.class, "MultiLineText") + .register(GlobCreateFromAnnotation.class, MultiLineText::create) + .load(); + } + + private static Glob create(Annotation annotation) { + return TYPE.instantiate() + .set(mimeType, ((MultiLineText_) annotation).mimeType()) + .set(maxSize, ((MultiLineText_) annotation).maxSize()) + ; + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/MultiLineTextType.java b/src/main/java/org/globsframework/core/metamodel/annotations/MultiLineTextType.java deleted file mode 100644 index 9efda36..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/MultiLineTextType.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.fields.IntegerField; -import org.globsframework.core.metamodel.fields.StringField; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -import java.lang.annotation.Annotation; - -public class MultiLineTextType { - public static GlobType TYPE; - - public static StringField mimeType; - - public static IntegerField maxSize; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - static { - GlobTypeLoaderFactory.create(MultiLineTextType.class) - .register(GlobCreateFromAnnotation.class, MultiLineTextType::create) - .load(); - } - - private static Glob create(Annotation annotation) { - return TYPE.instantiate() - .set(mimeType, ((MultiLineText) annotation).mimeType()) - .set(maxSize, ((MultiLineText) annotation).maxSize()) - ; - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/MultiLineText_.java b/src/main/java/org/globsframework/core/metamodel/annotations/MultiLineText_.java new file mode 100755 index 0000000..5ff64c7 --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/MultiLineText_.java @@ -0,0 +1,19 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Retention(RUNTIME) +@java.lang.annotation.Target({ElementType.FIELD}) +public @interface MultiLineText_ { + + String mimeType() default "text/plain"; + + int maxSize() default -1; + + GlobType TYPE = MultiLineText.TYPE; +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/NameAnnotation.java b/src/main/java/org/globsframework/core/metamodel/annotations/Name.java similarity index 81% rename from src/main/java/org/globsframework/core/metamodel/annotations/NameAnnotation.java rename to src/main/java/org/globsframework/core/metamodel/annotations/Name.java index e455e1e..37ce867 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/NameAnnotation.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/Name.java @@ -8,10 +8,10 @@ @Retention(RetentionPolicy.RUNTIME) @java.lang.annotation.Target({ElementType.FIELD}) -public @interface NameAnnotation { +public @interface Name { String name(); String value(); - GlobType TYPE = NameAnnotationType.TYPE; + GlobType TYPE = NameType.TYPE; } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/NameAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/NameType.java similarity index 80% rename from src/main/java/org/globsframework/core/metamodel/annotations/NameAnnotationType.java rename to src/main/java/org/globsframework/core/metamodel/annotations/NameType.java index 5906d2e..c5b5acc 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/NameAnnotationType.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/NameType.java @@ -8,20 +8,20 @@ import org.globsframework.core.model.Key; import org.globsframework.core.model.MutableGlob; -public class NameAnnotationType { +public class NameType { public static GlobType TYPE; - @KeyField + @KeyField_ public static StringField NAME; public static StringField VALUE; static { - GlobTypeLoaderFactory.create(NameAnnotationType.class, "NameAnnotation").load(); + GlobTypeLoaderFactory.create(NameType.class, "Name").load(); } - public static Glob create(NameAnnotation nameAnnotation) { - return create(nameAnnotation.name(), nameAnnotation.value()); + public static Glob create(Name name) { + return create(name.name(), name.value()); } public static MutableGlob create(String name, String value) { diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/NamingField.java b/src/main/java/org/globsframework/core/metamodel/annotations/NamingField.java index e281535..ac4f95e 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/NamingField.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/NamingField.java @@ -1,16 +1,28 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; +import java.lang.annotation.Annotation; -import static java.lang.annotation.RetentionPolicy.RUNTIME; +public class NamingField { + public static GlobType TYPE; -@Retention(RUNTIME) -@Target({ElementType.FIELD}) -public @interface NamingField { + @InitUniqueKey + public static Key UNIQUE_KEY; - GlobType TYPE = NamingFieldAnnotationType.TYPE; + @InitUniqueGlob + public static Glob UNIQUE_GLOB; + + static { + GlobTypeLoaderFactory.create(NamingField.class, "NamingField") + .register(GlobCreateFromAnnotation.class, new GlobCreateFromAnnotation() { + public Glob create(Annotation annotation) { + return UNIQUE_GLOB; + } + }) + .load(); + } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/NamingFieldAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/NamingFieldAnnotationType.java deleted file mode 100644 index 6f891bb..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/NamingFieldAnnotationType.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -import java.lang.annotation.Annotation; - -public class NamingFieldAnnotationType { - public static GlobType TYPE; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - @InitUniqueGlob - public static Glob UNIQUE_GLOB; - - static { - GlobTypeLoaderFactory.create(NamingFieldAnnotationType.class, "NamingFieldAnnotation") - .register(GlobCreateFromAnnotation.class, new GlobCreateFromAnnotation() { - public Glob create(Annotation annotation) { - return UNIQUE_GLOB; - } - }) - .load(); - } -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/NamingField_.java b/src/main/java/org/globsframework/core/metamodel/annotations/NamingField_.java new file mode 100644 index 0000000..1418dad --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/NamingField_.java @@ -0,0 +1,16 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Retention(RUNTIME) +@Target({ElementType.FIELD}) +public @interface NamingField_ { + + GlobType TYPE = NamingField.TYPE; +} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/NotUniqueIndexType.java b/src/main/java/org/globsframework/core/metamodel/annotations/NotUniqueIndex.java similarity index 75% rename from src/main/java/org/globsframework/core/metamodel/annotations/NotUniqueIndexType.java rename to src/main/java/org/globsframework/core/metamodel/annotations/NotUniqueIndex.java index 625c78e..5127cc1 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/NotUniqueIndexType.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/NotUniqueIndex.java @@ -4,13 +4,13 @@ import org.globsframework.core.metamodel.GlobTypeLoaderFactory; import org.globsframework.core.metamodel.fields.StringField; -public class NotUniqueIndexType { +public class NotUniqueIndex { public static GlobType TYPE; public static StringField NAME; static { - GlobTypeLoaderFactory.create(NotUniqueIndexType.class, "NotUniqueIndex") + GlobTypeLoaderFactory.create(NotUniqueIndex.class, "NotUniqueIndex") .load(); } } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/Required.java b/src/main/java/org/globsframework/core/metamodel/annotations/Required.java index 28c30e4..ddf889e 100644 --- a/src/main/java/org/globsframework/core/metamodel/annotations/Required.java +++ b/src/main/java/org/globsframework/core/metamodel/annotations/Required.java @@ -1,15 +1,27 @@ package org.globsframework.core.metamodel.annotations; import org.globsframework.core.metamodel.GlobType; +import org.globsframework.core.metamodel.GlobTypeLoaderFactory; +import org.globsframework.core.model.Glob; +import org.globsframework.core.model.Key; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; +public class Required { + public static GlobType TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; + @InitUniqueKey + public static Key UNIQUE_KEY; + + @InitUniqueGlob + public static Glob UNIQUE_GLOB; + + static { + GlobTypeLoaderFactory.create(Required.class, "Required") + .register(GlobCreateFromAnnotation.class, annotation -> UNIQUE_GLOB) + .load(); +// GlobTypeBuilder globTypeBuilder = new DefaultGlobTypeBuilder("requiredAnnotation"); +// globTypeBuilder.register(GlobCreateFromAnnotation.class, annotation -> create((Required)annotation)); +// TYPE = globTypeBuilder.get(); +// UNIQUE_KEY = KeyBuilder.newEmptyKey(TYPE); + } -@Retention(RUNTIME) -@Target({ElementType.FIELD}) -public @interface Required { - GlobType TYPE = RequiredAnnotationType.TYPE; } diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/RequiredAnnotationType.java b/src/main/java/org/globsframework/core/metamodel/annotations/RequiredAnnotationType.java deleted file mode 100644 index a25183e..0000000 --- a/src/main/java/org/globsframework/core/metamodel/annotations/RequiredAnnotationType.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.globsframework.core.metamodel.annotations; - -import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.model.Glob; -import org.globsframework.core.model.Key; - -public class RequiredAnnotationType { - public static GlobType TYPE; - - @InitUniqueKey - public static Key UNIQUE_KEY; - - @InitUniqueGlob - public static Glob UNIQUE_GLOB; - - static { - GlobTypeLoaderFactory.create(RequiredAnnotationType.class) - .register(GlobCreateFromAnnotation.class, annotation -> UNIQUE_GLOB) - .load(); -// GlobTypeBuilder globTypeBuilder = new DefaultGlobTypeBuilder("requiredAnnotation"); -// globTypeBuilder.register(GlobCreateFromAnnotation.class, annotation -> create((Required)annotation)); -// TYPE = globTypeBuilder.get(); -// UNIQUE_KEY = KeyBuilder.newEmptyKey(TYPE); - } - -} diff --git a/src/main/java/org/globsframework/core/metamodel/annotations/Required_.java b/src/main/java/org/globsframework/core/metamodel/annotations/Required_.java new file mode 100644 index 0000000..ca4a09b --- /dev/null +++ b/src/main/java/org/globsframework/core/metamodel/annotations/Required_.java @@ -0,0 +1,15 @@ +package org.globsframework.core.metamodel.annotations; + +import org.globsframework.core.metamodel.GlobType; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Retention(RUNTIME) +@Target({ElementType.FIELD}) +public @interface Required_ { + GlobType TYPE = Required.TYPE; +} diff --git a/src/main/java/org/globsframework/core/metamodel/fields/impl/AbstractField.java b/src/main/java/org/globsframework/core/metamodel/fields/impl/AbstractField.java index 43d3580..f2458b7 100644 --- a/src/main/java/org/globsframework/core/metamodel/fields/impl/AbstractField.java +++ b/src/main/java/org/globsframework/core/metamodel/fields/impl/AbstractField.java @@ -1,7 +1,7 @@ package org.globsframework.core.metamodel.fields.impl; import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.annotations.RequiredAnnotationType; +import org.globsframework.core.metamodel.annotations.Required; import org.globsframework.core.metamodel.impl.DefaultAnnotations; import org.globsframework.core.metamodel.type.DataType; import org.globsframework.core.model.Glob; @@ -64,7 +64,7 @@ public boolean isKeyField() { } public boolean isRequired() { - return hasAnnotation(RequiredAnnotationType.UNIQUE_KEY); + return hasAnnotation(Required.UNIQUE_KEY); } public DataType getDataType() { diff --git a/src/main/java/org/globsframework/core/metamodel/impl/DefaultAnnotations.java b/src/main/java/org/globsframework/core/metamodel/impl/DefaultAnnotations.java index 703f236..ee426f4 100644 --- a/src/main/java/org/globsframework/core/metamodel/impl/DefaultAnnotations.java +++ b/src/main/java/org/globsframework/core/metamodel/impl/DefaultAnnotations.java @@ -6,9 +6,8 @@ import org.globsframework.core.model.Glob; import org.globsframework.core.model.Key; import org.globsframework.core.model.format.GlobPrinter; +import org.globsframework.core.utils.exceptions.DuplicateGlobType; import org.globsframework.core.utils.exceptions.ItemNotFound; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Collection; import java.util.LinkedHashMap; @@ -16,34 +15,47 @@ import java.util.stream.Stream; public class DefaultAnnotations implements MutableAnnotations { - static private final Logger LOGGER = LoggerFactory.getLogger(DefaultAnnotations.class); + private static final LinkedHashMap EMPTY_MAP = new LinkedHashMap<>(); volatile private Map annotations; public DefaultAnnotations() { - annotations = new LinkedHashMap<>(); + annotations = EMPTY_MAP; } public DefaultAnnotations(LinkedHashMap annotations) { - this.annotations = annotations; + this.annotations = annotations == null ? EMPTY_MAP : annotations; } public DefaultAnnotations(Glob[] annotations) { - this.annotations = new LinkedHashMap<>(annotations.length); - for (Glob annotation : annotations) { - this.annotations.put(annotation.getKey(), annotation); + if (annotations == null || annotations.length == 0) { + this.annotations = EMPTY_MAP; + } else { + this.annotations = new LinkedHashMap<>(annotations.length); + for (Glob annotation : annotations) { + this.annotations.put(annotation.getKey(), annotation); + } } } public DefaultAnnotations(Annotations annotations) { - this.annotations = new LinkedHashMap<>(); - annotations.streamAnnotations() - .forEach(annotation -> this.annotations.put(annotation.getKey(), annotation)); + Collection copy = annotations.getAnnotations(); + if (copy.isEmpty()) { + this.annotations = EMPTY_MAP; + } else { + this.annotations = new LinkedHashMap<>((int) Math.ceil(((double) copy.size()) / 0.75)); + annotations.streamAnnotations() + .forEach(annotation -> this.annotations.put(annotation.getKey(), annotation)); + } } public DefaultAnnotations(Collection annotations) { - this.annotations = new LinkedHashMap<>(annotations.size()); - for (Glob annotation : annotations) { - this.annotations.put(annotation.getKey(), annotation); + if (annotations == null || annotations.isEmpty()) { + this.annotations = EMPTY_MAP; + } else { + this.annotations = new LinkedHashMap<>((int) Math.ceil(((double) annotations.size()) / 0.75)); + for (Glob annotation : annotations) { + this.annotations.put(annotation.getKey(), annotation); + } } } @@ -53,7 +65,8 @@ public MutableAnnotations addAnnotation(Glob glob) { Map tmp = new LinkedHashMap<>(annotations); Glob old = tmp.put(glob.getKey(), glob); if (old != null && old != glob) { - LOGGER.warn(GlobPrinter.toString(glob) + " has replaced " + GlobPrinter.toString(old)); + String msg = GlobPrinter.toString(glob) + " will have replaced " + GlobPrinter.toString(old); + throw new DuplicateGlobType(msg); } annotations = tmp; } @@ -61,13 +74,14 @@ public MutableAnnotations addAnnotation(Glob glob) { return this; } - public MutableAnnotations addAnnotations(Stream globs) { + public MutableAnnotations addAnnotations(Collection globs) { synchronized (this) { Map tmp = new LinkedHashMap<>(annotations); globs.forEach(glob -> { Glob old = tmp.put(glob.getKey(), glob); if (old != null && old != glob) { - LOGGER.warn(GlobPrinter.toString(glob) + " has replaced " + GlobPrinter.toString(old)); + String msg = GlobPrinter.toString(glob) + " will have replaced " + GlobPrinter.toString(old); + throw new DuplicateGlobType(msg); } }); @@ -88,6 +102,10 @@ public boolean hasAnnotation(Key key) { return annotations.containsKey(key); } + public Collection getAnnotations() { + return annotations.values(); + } + public Glob getAnnotation(Key key) { Glob annotation = annotations.get(key); if (annotation == null) { diff --git a/src/main/java/org/globsframework/core/metamodel/impl/DefaultFieldFactory.java b/src/main/java/org/globsframework/core/metamodel/impl/DefaultFieldFactory.java index 75e0fa2..6b4cc3c 100644 --- a/src/main/java/org/globsframework/core/metamodel/impl/DefaultFieldFactory.java +++ b/src/main/java/org/globsframework/core/metamodel/impl/DefaultFieldFactory.java @@ -257,14 +257,14 @@ public MultiFieldUniqueIndex addMultiFieldUniqueIndex(String name) { // } - private static Object computeDefaultValue(Field field, - Annotations annotations, - Key targetAnnotationClass) { - Glob glob = annotations.findAnnotation(targetAnnotationClass); - if (glob != null) { - Field fieldWithValue = glob.getType().getFieldWithAnnotation(DefaultFieldValueType.key); - return glob.getValue(fieldWithValue); - } +// private static Object computeDefaultValue(Field field, +// Annotations annotations, +// Key targetAnnotationClass) { +// Glob glob = annotations.findAnnotation(targetAnnotationClass); +// if (glob != null) { +// Field fieldWithValue = glob.getType().getFieldWithAnnotation(DefaultFieldValueType.key); +// return glob.getValue(fieldWithValue); +// } // for (Class annotationClass : defaultValuesAnnotations) { // Annotation annotation = annotations.get(annotationClass); // if (annotation == null) { @@ -287,6 +287,6 @@ private static Object computeDefaultValue(Field field, // throw new InvalidParameter("Cannot determine default value for field: " + field, e); // } // } - return null; - } +// return null; +// } } diff --git a/src/main/java/org/globsframework/core/metamodel/impl/DefaultGlobType.java b/src/main/java/org/globsframework/core/metamodel/impl/DefaultGlobType.java index 665a0b4..115e8cb 100644 --- a/src/main/java/org/globsframework/core/metamodel/impl/DefaultGlobType.java +++ b/src/main/java/org/globsframework/core/metamodel/impl/DefaultGlobType.java @@ -1,6 +1,6 @@ package org.globsframework.core.metamodel.impl; -import org.globsframework.core.metamodel.annotations.KeyAnnotationType; +import org.globsframework.core.metamodel.annotations.KeyField; import org.globsframework.core.metamodel.fields.Field; import org.globsframework.core.metamodel.index.Index; import org.globsframework.core.metamodel.index.MultiFieldIndex; @@ -12,6 +12,7 @@ import org.globsframework.core.model.GlobFactoryService; import org.globsframework.core.model.Key; import org.globsframework.core.model.format.GlobPrinter; +import org.globsframework.core.model.utils.FieldCheck; import org.globsframework.core.utils.exceptions.InvalidState; import org.globsframework.core.utils.exceptions.ItemAlreadyExists; import org.globsframework.core.utils.exceptions.ItemNotFound; @@ -30,18 +31,17 @@ public class DefaultGlobType extends DefaultAnnotations private Field[] keyFields = new Field[0]; private GlobFactory globFactory; private Comparator keyComparator; - private String[] scope; private final String name; private final Map fieldsByName = new HashMap<>(); private final Map indices = new HashMap<>(2, 1); private final Map, Object> registered = new ConcurrentHashMap<>(); public DefaultGlobType(String name) { - this(null, name); + this(name, null); } - public DefaultGlobType(String[] scope, String name) { - this.scope = scope == null ? EMPTY_SCOPE : null; + public DefaultGlobType(String name, LinkedHashMap annotations) { + super(annotations); this.name = name; } @@ -148,23 +148,24 @@ public void completeInit() { for (Field field : fieldsByName.values()) { fields[field.getIndex()] = field; } - int keyFieldCount = 0; - Set keySet = new HashSet<>(); - for (Field field : fields) { - Glob annotation = field.findAnnotation(KeyAnnotationType.UNIQUE_KEY); - if (annotation != null) { - int index = annotation.get(KeyAnnotationType.INDEX, -1); - if (index == -1) { - field.addAnnotation(KeyAnnotationType.create(field.getKeyIndex())); - keySet.add(field.getKeyIndex()); - } else { - keySet.add(index); + if (FieldCheck.CheckGlob.shouldCheck) { + int keyFieldCount = 0; + Set keySet = new HashSet<>(); + for (Field field : fields) { + Glob annotation = field.findAnnotation(KeyField.UNIQUE_KEY); + if (annotation != null) { + int index = annotation.get(KeyField.INDEX, -1); + if (index == -1) { + throw new RuntimeException("key annotation is not initialized"); + } else { + keySet.add(index); + } + keyFieldCount++; } - keyFieldCount++; } - } - if (!IntStream.range(0, keyFieldCount).allMatch(keySet::contains)) { - throw new RuntimeException("Bug unconstitency between key count " + keyFieldCount + " and key id " + keySet); + if (!IntStream.range(0, keyFieldCount).allMatch(keySet::contains)) { + throw new RuntimeException("Bug unconstitency between key count " + keyFieldCount + " and key id " + keySet); + } } globFactory = GlobFactoryService.Builder.getBuilderFactory().getFactory(this); diff --git a/src/main/java/org/globsframework/core/metamodel/impl/DefaultGlobTypeBuilder.java b/src/main/java/org/globsframework/core/metamodel/impl/DefaultGlobTypeBuilder.java index 6fefe70..c95188e 100644 --- a/src/main/java/org/globsframework/core/metamodel/impl/DefaultGlobTypeBuilder.java +++ b/src/main/java/org/globsframework/core/metamodel/impl/DefaultGlobTypeBuilder.java @@ -19,6 +19,11 @@ public class DefaultGlobTypeBuilder implements GlobTypeBuilder { private int index; private int keyIndex; + public DefaultGlobTypeBuilder(String name, Collection annotations) { + type = new DefaultGlobType(name, adaptAnnotation(annotations)); + factory = new DefaultFieldFactory(type); + } + public static GlobTypeBuilder init(String typeName) { return new DefaultGlobTypeBuilder(typeName); } @@ -28,6 +33,10 @@ public DefaultGlobTypeBuilder(String typeName) { factory = new DefaultFieldFactory(type); } + public static GlobTypeBuilder init(String name, Collection annotations) { + return new DefaultGlobTypeBuilder(name, annotations); + } + private LinkedHashMap adaptAnnotation(Collection annotations) { LinkedHashMap map = new LinkedHashMap<>(); for (Glob annotation : annotations) { @@ -43,6 +52,11 @@ public GlobTypeBuilder addAnnotation(Glob annotation) { return this; } + public GlobTypeBuilder addAnnotations(Collection annotations) { + type.addAnnotations(annotations); + return this; + } + public GlobTypeBuilder addStringField(String fieldName, Collection annotations) { createStringField(fieldName, annotations); return this; @@ -50,10 +64,10 @@ public GlobTypeBuilder addStringField(String fieldName, Collection annotat private DefaultStringField createStringField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob defaultValue = annotations.get(DefaultStringAnnotationType.UNIQUE_KEY); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultStringField field = factory.addString(fieldName, key != null, getKeyId(key), index, - defaultValue != null ? defaultValue.get(DefaultStringAnnotationType.DEFAULT_VALUE) : null, annotations); + Glob defaultValue = annotations.get(DefaultString.UNIQUE_KEY); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultStringField field = factory.addString(fieldName, keyPos != -1, keyPos, index, + defaultValue != null ? defaultValue.get(DefaultString.VALUE) : null, annotations); index++; return field; } @@ -65,8 +79,8 @@ public GlobTypeBuilder addStringArrayField(String fieldName, Collection an private DefaultStringArrayField createStringArrayField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultStringArrayField field = factory.addStringArray(fieldName, key != null, getKeyId(key), index, annotations); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultStringArrayField field = factory.addStringArray(fieldName, keyPos != -1, keyPos, index, annotations); index++; return field; } @@ -78,31 +92,31 @@ public GlobTypeBuilder addIntegerField(String fieldName, Collection globAn private DefaultIntegerField createIntegerField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob defaultValue = annotations.get(DefaultIntegerAnnotationType.UNIQUE_KEY); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultIntegerField field = factory.addInteger(fieldName, key != null, getKeyId(key), index, - defaultValue != null ? defaultValue.get(DefaultIntegerAnnotationType.DEFAULT_VALUE) : null, annotations); + Glob defaultValue = annotations.get(DefaultInteger.UNIQUE_KEY); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultIntegerField field = factory.addInteger(fieldName, keyPos != -1, keyPos, index, + defaultValue != null ? defaultValue.get(DefaultInteger.VALUE) : null, annotations); index++; return field; } - private int getKeyId(Glob key) { + private int getOrUpdateKeyPos(LinkedHashMap annotations) { + Glob key = annotations.get(KeyField.UNIQUE_KEY); + int keyPos = -1; if (key != null) { - Integer index = key.get(KeyAnnotationType.INDEX); - if (index == -1) { - return keyIndex++; - } else { - return index; + if ((keyPos = key.get(KeyField.INDEX, -1)) == -1) { + keyPos = keyIndex++; + Glob glob = KeyField.create(keyPos); + annotations.put(glob.getKey(), glob); } - } else { - return 0; } + return keyPos; } private DefaultIntegerArrayField createIntegerArrayField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultIntegerArrayField field = factory.addIntegerArray(fieldName, key != null, getKeyId(key), index, annotations); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultIntegerArrayField field = factory.addIntegerArray(fieldName, keyPos != -1, keyPos, index, annotations); index++; return field; } @@ -149,53 +163,53 @@ public GlobTypeBuilder addDateTimeField(String fieldName, Collection globA private DefaultDoubleField createDoubleField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob defaultValue = annotations.get(DefaultDoubleAnnotationType.UNIQUE_KEY); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultDoubleField doubleField = factory.addDouble(fieldName, key != null, getKeyId(key), index, - defaultValue != null ? defaultValue.get(DefaultDoubleAnnotationType.DEFAULT_VALUE) : null, annotations); + Glob defaultValue = annotations.get(DefaultDouble.UNIQUE_KEY); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultDoubleField doubleField = factory.addDouble(fieldName, keyPos != -1, keyPos, index, + defaultValue != null ? defaultValue.get(DefaultDouble.VALUE) : null, annotations); index++; return doubleField; } private DefaultDoubleArrayField createDoubleArrayField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultDoubleArrayField field = factory.addDoubleArray(fieldName, key != null, getKeyId(key), index, annotations); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultDoubleArrayField field = factory.addDoubleArray(fieldName, keyPos != -1, keyPos, index, annotations); index++; return field; } private DefaultBigDecimalField createBigDecimalField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - Glob defaultValue = annotations.get(DefaultBigDecimalAnnotationType.UNIQUE_KEY); - DefaultBigDecimalField bigDecimalField = factory.addBigDecimal(fieldName, key != null, getKeyId(key), index, - defaultValue != null ? defaultValue.get(DefaultBigDecimalAnnotationType.DEFAULT_VALUE) : null, annotations); + Glob defaultValue = annotations.get(DefaultBigDecimal.UNIQUE_KEY); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultBigDecimalField bigDecimalField = factory.addBigDecimal(fieldName, keyPos != -1, keyPos, index, + defaultValue != null ? defaultValue.get(DefaultBigDecimal.VALUE) : null, annotations); index++; return bigDecimalField; } private DefaultBigDecimalArrayField createBigDecimalArrayField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); + int keyPos = getOrUpdateKeyPos(annotations); DefaultBigDecimalArrayField bigDecimalArrayField = - factory.addBigDecimalArray(fieldName, key != null, getKeyId(key), index, annotations); + factory.addBigDecimalArray(fieldName, keyPos != -1, keyPos, index, annotations); index++; return bigDecimalArrayField; } private DefaultDateTimeField createDateTimeField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultDateTimeField dateTimeField = factory.addDateTime(fieldName, key != null, getKeyId(key), index, annotations); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultDateTimeField dateTimeField = factory.addDateTime(fieldName, keyPos != -1, keyPos, index, annotations); index++; return dateTimeField; } private DefaultDateField createDateField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultDateField dateField = factory.addDate(fieldName, key != null, getKeyId(key), index, annotations); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultDateField dateField = factory.addDate(fieldName, keyPos != -1, keyPos, index, annotations); index++; return dateField; } @@ -208,18 +222,18 @@ public GlobTypeBuilder addLongField(String fieldName, Collection globAnnot private DefaultLongField createLongField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob defaultValue = annotations.get(DefaultLongAnnotationType.UNIQUE_KEY); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultLongField longField = factory.addLong(fieldName, key != null, getKeyId(key), index, - defaultValue != null ? defaultValue.get(DefaultLongAnnotationType.DEFAULT_VALUE) : null, annotations); + Glob defaultValue = annotations.get(DefaultLong.UNIQUE_KEY); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultLongField longField = factory.addLong(fieldName, keyPos != -1, keyPos, index, + defaultValue != null ? defaultValue.get(DefaultLong.VALUE) : null, annotations); index++; return longField; } private DefaultLongArrayField createLongArrayField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultLongArrayField field = factory.addLongArray(fieldName, key != null, getKeyId(key), index, annotations); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultLongArrayField field = factory.addLongArray(fieldName, keyPos != -1, keyPos, index, annotations); index++; return field; } @@ -231,8 +245,8 @@ public GlobTypeBuilder addBooleanArrayField(String fieldName, Collection g private DefaultBooleanArrayField createBooleanArrayField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultBooleanArrayField field = factory.addBooleanArray(fieldName, key != null, getKeyId(key), index, annotations); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultBooleanArrayField field = factory.addBooleanArray(fieldName, keyPos != -1, keyPos, index, annotations); index++; return field; } @@ -244,10 +258,10 @@ public GlobTypeBuilder addBooleanField(String fieldName, Collection globAn private DefaultBooleanField createBooleanField(String fieldName, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob defaultValue = annotations.get(DefaultBooleanAnnotationType.UNIQUE_KEY); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultBooleanField field = factory.addBoolean(fieldName, key != null, getKeyId(key), index, - defaultValue != null ? defaultValue.get(DefaultBooleanAnnotationType.DEFAULT_VALUE) : null, annotations); + Glob defaultValue = annotations.get(DefaultBoolean.UNIQUE_KEY); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultBooleanField field = factory.addBoolean(fieldName, keyPos != -1, keyPos, index, + defaultValue != null ? defaultValue.get(DefaultBoolean.VALUE) : null, annotations); index++; return field; } @@ -287,24 +301,24 @@ private DefaultBlobField createBlobField(String fieldName, Collection glob private GlobField createGlobField(String fieldName, GlobType globType, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultGlobField field = factory.addGlob(fieldName, globType, key != null, getKeyId(key), index, annotations); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultGlobField field = factory.addGlob(fieldName, globType, keyPos != -1, keyPos, index, annotations); index++; return field; } private GlobArrayField createGlobArrayField(String fieldName, GlobType globType, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); - DefaultGlobArrayField field = factory.addGlobArray(fieldName, globType, key != null, - getKeyId(key), index, annotations); + int keyPos = getOrUpdateKeyPos(annotations); + DefaultGlobArrayField field = factory.addGlobArray(fieldName, globType, keyPos != -1, + keyPos, index, annotations); index++; return field; } private GlobUnionField createGlobUnionField(String fieldName, Collection types, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); + Glob key = annotations.get(KeyField.UNIQUE_KEY); if (key != null) { throw new RuntimeException(fieldName + " of type unionField cannot be a key"); } @@ -315,7 +329,7 @@ private GlobUnionField createGlobUnionField(String fieldName, Collection types, Collection globAnnotations) { LinkedHashMap annotations = adaptAnnotation(globAnnotations); - Glob key = annotations.get(KeyAnnotationType.UNIQUE_KEY); + Glob key = annotations.get(KeyField.UNIQUE_KEY); if (key != null) { throw new RuntimeException(fieldName + " of type unionField cannot be a key"); } diff --git a/src/main/java/org/globsframework/core/metamodel/impl/DefaultValuesFieldVisitor.java b/src/main/java/org/globsframework/core/metamodel/impl/DefaultValuesFieldVisitor.java index 84bffe0..7a3c97c 100644 --- a/src/main/java/org/globsframework/core/metamodel/impl/DefaultValuesFieldVisitor.java +++ b/src/main/java/org/globsframework/core/metamodel/impl/DefaultValuesFieldVisitor.java @@ -8,38 +8,38 @@ public class DefaultValuesFieldVisitor extends FieldVisitorWithContext.AbstractFieldVisitor { public void visitInteger(IntegerField field, MutableGlob context) throws Exception { - if (field.hasAnnotation(DefaultIntegerAnnotationType.UNIQUE_KEY)) { + if (field.hasAnnotation(DefaultInteger.UNIQUE_KEY)) { context.set(field.asIntegerField(), (int) field.getDefaultValue()); } } public void visitDouble(DoubleField field, MutableGlob context) throws Exception { - if (field.hasAnnotation(DefaultDoubleAnnotationType.UNIQUE_KEY)) { + if (field.hasAnnotation(DefaultDouble.UNIQUE_KEY)) { context.set(field.asDoubleField(), (double) field.getDefaultValue()); } } public void visitString(StringField field, MutableGlob context) throws Exception { - if (field.hasAnnotation(DefaultStringAnnotationType.UNIQUE_KEY)) { + if (field.hasAnnotation(DefaultString.UNIQUE_KEY)) { context.set(field.asStringField(), (String) field.getDefaultValue()); } } public void visitBoolean(BooleanField field, MutableGlob context) throws Exception { - if (field.hasAnnotation(DefaultBooleanAnnotationType.UNIQUE_KEY)) { + if (field.hasAnnotation(DefaultBoolean.UNIQUE_KEY)) { context.set(field.asBooleanField(), (boolean) field.getDefaultValue()); } } public void visitBigDecimal(BigDecimalField field, MutableGlob context) throws Exception { - if (field.hasAnnotation(DefaultBigDecimalAnnotationType.UNIQUE_KEY)) { + if (field.hasAnnotation(DefaultBigDecimal.UNIQUE_KEY)) { context.set(field.asBigDecimalField(), (BigDecimal) field.getDefaultValue()); } } public void visitLong(LongField field, MutableGlob context) throws Exception { - if (field.hasAnnotation(DefaultLongAnnotationType.UNIQUE_KEY)) { + if (field.hasAnnotation(DefaultLong.UNIQUE_KEY)) { context.set(field.asLongField(), (long) field.getDefaultValue()); } } diff --git a/src/main/java/org/globsframework/core/metamodel/impl/GlobTypeLoaderImpl.java b/src/main/java/org/globsframework/core/metamodel/impl/GlobTypeLoaderImpl.java index 9f740a9..2530e7b 100644 --- a/src/main/java/org/globsframework/core/metamodel/impl/GlobTypeLoaderImpl.java +++ b/src/main/java/org/globsframework/core/metamodel/impl/GlobTypeLoaderImpl.java @@ -8,6 +8,7 @@ import org.globsframework.core.metamodel.fields.*; import org.globsframework.core.metamodel.fields.impl.AbstractField; import org.globsframework.core.metamodel.index.*; +import org.globsframework.core.metamodel.index.NotUniqueIndex; import org.globsframework.core.metamodel.index.impl.DefaultMultiFieldNotUniqueIndex; import org.globsframework.core.metamodel.index.impl.DefaultMultiFieldUniqueIndex; import org.globsframework.core.metamodel.index.impl.DefaultNotUniqueIndex; @@ -72,7 +73,7 @@ private void processOther(Class targetClass) { if (processor != null && !processor.isEmpty()) { LinkedHashMap annotations = new LinkedHashMap<>(); processFieldAnnotations(classField, annotations); - MutableGlob fieldNameAnnotation = FieldNameAnnotationType.create(getFieldName(classField)); + MutableGlob fieldNameAnnotation = FieldName.create(getFieldName(classField)); annotations.put(fieldNameAnnotation.getKey(), fieldNameAnnotation); applyProcessor(targetClass, classField, processor, annotations); } else { @@ -134,13 +135,17 @@ private void createType(java.lang.reflect.Field classField, throw new ItemAlreadyExists("Class " + targetClass.getName() + " must have only one TYPE field of class " + GlobType.class.getName()); } - this.type = new DefaultGlobType(modelName, getTypeName(targetClass)); + LinkedHashMap annotations = null; for (Annotation annotation : classField.getAnnotations()) { Glob glob = processAnnotation(annotation); if (glob != null) { - type.addAnnotation(glob); + if (annotations == null){ + annotations = new LinkedHashMap<>(); + } + annotations.put(glob.getKey(), glob); } } + this.type = new DefaultGlobType(getTypeName(targetClass), annotations); this.fieldFactory = new DefaultFieldFactory(type); GlobTypeLoaderImpl.setClassField(classField, type, targetClass); } @@ -205,28 +210,28 @@ private void processFields(Class targetClass) { for (java.lang.reflect.Field classField : targetClass.getFields()) { int keyIndex = -1; if (isGlobField(classField)) { - boolean isKeyField = classField.isAnnotationPresent(KeyField.class); + boolean isKeyField = classField.isAnnotationPresent(KeyField_.class); if (isKeyField) { - keyIndex = classField.getAnnotation(KeyField.class).value(); + keyIndex = classField.getAnnotation(KeyField_.class).value(); if (keyIndex == -1) { keyIndex = keyCount; } allocatedKeys.add(keyIndex); } String fieldName; - boolean hasFieldNameAnnotation = classField.isAnnotationPresent(FieldNameAnnotation.class); + boolean hasFieldNameAnnotation = classField.isAnnotationPresent(FieldName_.class); if (hasFieldNameAnnotation) { - fieldName = classField.getAnnotation(FieldNameAnnotation.class).value(); + fieldName = classField.getAnnotation(FieldName_.class).value(); } else { fieldName = getFieldName(classField); } - LinkedHashMap annotations = new LinkedHashMap<>(); + LinkedHashMap annotations = new LinkedHashMap<>(2); if (!hasFieldNameAnnotation) { - MutableGlob glob = FieldNameAnnotationType.create(fieldName); + MutableGlob glob = FieldName.create(fieldName); annotations.put(glob.getKey(), glob); } if (isKeyField) { - Glob glob = KeyAnnotationType.create(keyCount); + Glob glob = KeyField.create(keyCount); annotations.put(glob.getKey(), glob); keyCount++; } @@ -261,23 +266,23 @@ GlobType getTypeFromClass(Class aClass) { private AbstractField create(String name, Class fieldClass, boolean isKeyField, int keyIndex, int index, java.lang.reflect.Field field, LinkedHashMap annotations) { if (StringField.class.isAssignableFrom(fieldClass)) { - DefaultString defaultString = field.getAnnotation(DefaultString.class); + DefaultString_ defaultString = field.getAnnotation(DefaultString_.class); String defaultValue = defaultString != null ? defaultString.value() : null; return fieldFactory.addString(name, isKeyField, keyIndex, index, defaultValue, annotations); } else if (IntegerField.class.isAssignableFrom(fieldClass)) { - DefaultInteger defaultInteger = field.getAnnotation(DefaultInteger.class); + DefaultInteger_ defaultInteger = field.getAnnotation(DefaultInteger_.class); return fieldFactory.addInteger(name, isKeyField, keyIndex, index, defaultInteger != null ? defaultInteger.value() : null, annotations); } else if (LongField.class.isAssignableFrom(fieldClass)) { - DefaultLong defaultLong = field.getAnnotation(DefaultLong.class); + DefaultLong_ defaultLong = field.getAnnotation(DefaultLong_.class); return fieldFactory.addLong(name, isKeyField, keyIndex, index, defaultLong != null ? defaultLong.value() : null, annotations); } else if (BooleanField.class.isAssignableFrom(fieldClass)) { - DefaultBoolean defaultBoolean = field.getAnnotation(DefaultBoolean.class); + DefaultBoolean_ defaultBoolean = field.getAnnotation(DefaultBoolean_.class); return fieldFactory.addBoolean(name, isKeyField, keyIndex, index, defaultBoolean != null ? defaultBoolean.value() : null, annotations); } else if (DoubleField.class.isAssignableFrom(fieldClass)) { - DefaultDouble defaultDouble = field.getAnnotation(DefaultDouble.class); + DefaultDouble_ defaultDouble = field.getAnnotation(DefaultDouble_.class); return fieldFactory.addDouble(name, isKeyField, keyIndex, index, defaultDouble != null ? defaultDouble.value() : null, annotations); } else if (BlobField.class.isAssignableFrom(fieldClass)) { @@ -297,7 +302,7 @@ private AbstractField create(String name, Class fieldClass, boolean isKeyFiel } else if (DateTimeField.class.isAssignableFrom(fieldClass)) { return fieldFactory.addDateTime(name, isKeyField, keyIndex, index, annotations); } else if (BigDecimalField.class.isAssignableFrom(fieldClass)) { - DefaultBigDecimal defaultBigDecimal = field.getAnnotation(DefaultBigDecimal.class); + DefaultBigDecimal_ defaultBigDecimal = field.getAnnotation(DefaultBigDecimal_.class); return fieldFactory.addBigDecimal(name, isKeyField, keyIndex, index, defaultBigDecimal != null ? new BigDecimal(defaultBigDecimal.value()) : null, annotations); diff --git a/src/main/java/org/globsframework/core/metamodel/links/impl/DefaultDirectLink.java b/src/main/java/org/globsframework/core/metamodel/links/impl/DefaultDirectLink.java index d2fefe6..999aa62 100644 --- a/src/main/java/org/globsframework/core/metamodel/links/impl/DefaultDirectLink.java +++ b/src/main/java/org/globsframework/core/metamodel/links/impl/DefaultDirectLink.java @@ -2,7 +2,7 @@ import org.globsframework.core.metamodel.Annotations; import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.annotations.RequiredAnnotationType; +import org.globsframework.core.metamodel.annotations.Required; import org.globsframework.core.metamodel.fields.Field; import org.globsframework.core.metamodel.links.DirectLink; import org.globsframework.core.metamodel.links.FieldMappingFunction; @@ -39,7 +39,7 @@ public GlobType getTargetType() { } public boolean isRequired() { - return hasAnnotation(RequiredAnnotationType.UNIQUE_KEY); + return hasAnnotation(Required.UNIQUE_KEY); } public T apply(T functor) { diff --git a/src/main/java/org/globsframework/core/metamodel/links/impl/DefaultDirectSingleLink.java b/src/main/java/org/globsframework/core/metamodel/links/impl/DefaultDirectSingleLink.java index 5552a93..b08aeb7 100644 --- a/src/main/java/org/globsframework/core/metamodel/links/impl/DefaultDirectSingleLink.java +++ b/src/main/java/org/globsframework/core/metamodel/links/impl/DefaultDirectSingleLink.java @@ -2,7 +2,7 @@ import org.globsframework.core.metamodel.Annotations; import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.annotations.RequiredAnnotationType; +import org.globsframework.core.metamodel.annotations.Required; import org.globsframework.core.metamodel.fields.Field; import org.globsframework.core.metamodel.links.DirectSingleLink; import org.globsframework.core.metamodel.links.FieldMappingFunction; @@ -30,7 +30,7 @@ public GlobType getTargetType() { } public boolean isRequired() { - return hasAnnotation(RequiredAnnotationType.UNIQUE_KEY); + return hasAnnotation(Required.UNIQUE_KEY); } public T apply(T functor) { diff --git a/src/main/java/org/globsframework/core/metamodel/links/impl/DefaultMutableGlobLinkModel.java b/src/main/java/org/globsframework/core/metamodel/links/impl/DefaultMutableGlobLinkModel.java index 49f3366..b970b9e 100644 --- a/src/main/java/org/globsframework/core/metamodel/links/impl/DefaultMutableGlobLinkModel.java +++ b/src/main/java/org/globsframework/core/metamodel/links/impl/DefaultMutableGlobLinkModel.java @@ -4,21 +4,20 @@ import org.globsframework.core.metamodel.GlobModel; import org.globsframework.core.metamodel.GlobType; import org.globsframework.core.metamodel.MutableGlobLinkModel; -import org.globsframework.core.metamodel.annotations.FieldNameAnnotationType; -import org.globsframework.core.metamodel.annotations.LinkModelNameAnnotationType; +import org.globsframework.core.metamodel.annotations.FieldName; +import org.globsframework.core.metamodel.annotations.LinkModelName; import org.globsframework.core.metamodel.fields.Field; import org.globsframework.core.metamodel.impl.DefaultAnnotations; import org.globsframework.core.metamodel.links.DirectLink; import org.globsframework.core.metamodel.links.FieldMappingFunction; import org.globsframework.core.metamodel.links.Link; +import org.globsframework.core.metamodel.utils.MutableAnnotations; import org.globsframework.core.model.Glob; import org.globsframework.core.model.Key; import org.globsframework.core.utils.collections.MapOfMaps; import org.globsframework.core.utils.exceptions.GlobsException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import java.util.stream.Stream; public class DefaultMutableGlobLinkModel implements MutableGlobLinkModel { @@ -61,11 +60,11 @@ public LinkBuilder getLinkBuilder(Annotations annotations) { appendInTarget(link); }); } - Glob linkModel = annotations.findAnnotation(LinkModelNameAnnotationType.UNIQUE_KEY); - Glob annotation = annotations.findAnnotation(FieldNameAnnotationType.UNIQUE_KEY); - DirectLinkBuilder builder = getDirectLinkBuilder(linkModel != null ? linkModel.get(LinkModelNameAnnotationType.NAME) : null, - annotation != null ? annotation.get(FieldNameAnnotationType.NAME) : null); - builder.addAnnotations(annotations.streamAnnotations()); + Glob linkModel = annotations.findAnnotation(LinkModelName.UNIQUE_KEY); + Glob annotation = annotations.findAnnotation(FieldName.UNIQUE_KEY); + DirectLinkBuilder builder = getDirectLinkBuilder(linkModel != null ? linkModel.get(LinkModelName.NAME) : null, + annotation != null ? annotation.get(FieldName.NAME) : null); + builder.addAnnotations(annotations.getAnnotations()); return builder; } @@ -89,13 +88,13 @@ public DirectLinkBuilder getDirectLinkBuilder(Annotations annotations) { if (annotations instanceof Link && !(annotations instanceof UnInitializedLink)) { return new AlreadyInitializedBuilder((Link) annotations, publish); } - Glob fieldName = annotations.getAnnotation(FieldNameAnnotationType.UNIQUE_KEY); - Glob modelNameAnnotation = annotations.findAnnotation(LinkModelNameAnnotationType.UNIQUE_KEY); + Glob fieldName = annotations.getAnnotation(FieldName.UNIQUE_KEY); + Glob modelNameAnnotation = annotations.findAnnotation(LinkModelName.UNIQUE_KEY); String modelName = null; if (modelNameAnnotation != null) { - modelName = modelNameAnnotation.get(LinkModelNameAnnotationType.NAME); + modelName = modelNameAnnotation.get(LinkModelName.NAME); } - return new DefaultDirectLinkBuilder(modelName, fieldName.get(FieldNameAnnotationType.NAME), + return new DefaultDirectLinkBuilder(modelName, fieldName.get(FieldName.NAME), publish, annotations); } @@ -130,6 +129,13 @@ public DirectLinkBuilder addAnnotation(Glob annotation) { return this; } + public MutableAnnotations addAnnotations(Collection glob) { + for (Glob g : glob) { + addAnnotation(g); + } + return this; + } + public DirectLinkBuilder add(Field id1, Field id2) { if (!link.apply(new FieldMappingFunction() { boolean found = false; @@ -151,11 +157,6 @@ public DirectLink publish() { return (DirectLink) link; } - public DirectLinkBuilder addAnnotations(Stream globs) { - globs.forEach(this::addAnnotation); - return this; - } - public Stream streamAnnotations() { return link.streamAnnotations(); } @@ -168,6 +169,10 @@ public boolean hasAnnotation(Key key) { return link.hasAnnotation(key); } + public Collection getAnnotations() { + return link.getAnnotations(); + } + public Glob getAnnotation(Key key) { return link.getAnnotation(key); } diff --git a/src/main/java/org/globsframework/core/metamodel/links/impl/UnInitializedLink.java b/src/main/java/org/globsframework/core/metamodel/links/impl/UnInitializedLink.java index 1f7ff46..b345c4b 100644 --- a/src/main/java/org/globsframework/core/metamodel/links/impl/UnInitializedLink.java +++ b/src/main/java/org/globsframework/core/metamodel/links/impl/UnInitializedLink.java @@ -2,7 +2,7 @@ import org.globsframework.core.metamodel.Annotations; import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.annotations.FieldNameAnnotationType; +import org.globsframework.core.metamodel.annotations.FieldName; import org.globsframework.core.metamodel.fields.Field; import org.globsframework.core.metamodel.links.DirectSingleLink; import org.globsframework.core.metamodel.links.FieldMappingFunction; @@ -21,9 +21,9 @@ public UnInitializedLink(GlobType type, Annotations annotations, Annotation[] na } static String getName(Annotations annotations) { - Glob annotation = annotations.findAnnotation(FieldNameAnnotationType.UNIQUE_KEY); + Glob annotation = annotations.findAnnotation(FieldName.UNIQUE_KEY); if (annotation != null) { - return annotation.get(FieldNameAnnotationType.NAME); + return annotation.get(FieldName.NAME); } throw new GlobsException("Missing field name annotation"); } diff --git a/src/main/java/org/globsframework/core/metamodel/type/GlobArrayFieldType.java b/src/main/java/org/globsframework/core/metamodel/type/GlobArrayFieldType.java index 609642b..f6d6f53 100644 --- a/src/main/java/org/globsframework/core/metamodel/type/GlobArrayFieldType.java +++ b/src/main/java/org/globsframework/core/metamodel/type/GlobArrayFieldType.java @@ -2,7 +2,7 @@ import org.globsframework.core.metamodel.GlobType; import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.annotations.IsTargetType_; +import org.globsframework.core.metamodel.annotations.IsTarget_; import org.globsframework.core.metamodel.annotations.Targets; import org.globsframework.core.metamodel.fields.GlobArrayUnionField; import org.globsframework.core.metamodel.fields.StringField; @@ -13,7 +13,7 @@ public class GlobArrayFieldType { public static StringField name; - @IsTargetType_() + @IsTarget_() public static StringField targetType; @Targets({}) diff --git a/src/main/java/org/globsframework/core/metamodel/type/GlobFieldType.java b/src/main/java/org/globsframework/core/metamodel/type/GlobFieldType.java index 5281edc..984c28c 100644 --- a/src/main/java/org/globsframework/core/metamodel/type/GlobFieldType.java +++ b/src/main/java/org/globsframework/core/metamodel/type/GlobFieldType.java @@ -2,7 +2,7 @@ import org.globsframework.core.metamodel.GlobType; import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.annotations.IsTargetType_; +import org.globsframework.core.metamodel.annotations.IsTarget_; import org.globsframework.core.metamodel.annotations.Targets; import org.globsframework.core.metamodel.fields.GlobArrayUnionField; import org.globsframework.core.metamodel.fields.StringField; @@ -13,7 +13,7 @@ public class GlobFieldType { public static StringField name; - @IsTargetType_() + @IsTarget_() public static StringField targetType; @Targets({}) diff --git a/src/main/java/org/globsframework/core/metamodel/type/GlobUnionArrayFieldType.java b/src/main/java/org/globsframework/core/metamodel/type/GlobUnionArrayFieldType.java index 2abcc6a..b14e26b 100644 --- a/src/main/java/org/globsframework/core/metamodel/type/GlobUnionArrayFieldType.java +++ b/src/main/java/org/globsframework/core/metamodel/type/GlobUnionArrayFieldType.java @@ -2,7 +2,7 @@ import org.globsframework.core.metamodel.GlobType; import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.annotations.IsTargetType_; +import org.globsframework.core.metamodel.annotations.IsTarget_; import org.globsframework.core.metamodel.annotations.Targets; import org.globsframework.core.metamodel.fields.GlobArrayUnionField; import org.globsframework.core.metamodel.fields.StringArrayField; @@ -14,7 +14,7 @@ public class GlobUnionArrayFieldType { public static StringField name; - @IsTargetType_() + @IsTarget_() public static StringArrayField targetTypes; @Targets({}) diff --git a/src/main/java/org/globsframework/core/metamodel/type/GlobUnionFieldType.java b/src/main/java/org/globsframework/core/metamodel/type/GlobUnionFieldType.java index 0d802fe..ed10daa 100644 --- a/src/main/java/org/globsframework/core/metamodel/type/GlobUnionFieldType.java +++ b/src/main/java/org/globsframework/core/metamodel/type/GlobUnionFieldType.java @@ -2,7 +2,7 @@ import org.globsframework.core.metamodel.GlobType; import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.annotations.IsTargetType_; +import org.globsframework.core.metamodel.annotations.IsTarget_; import org.globsframework.core.metamodel.annotations.Targets; import org.globsframework.core.metamodel.fields.GlobArrayUnionField; import org.globsframework.core.metamodel.fields.StringArrayField; @@ -14,7 +14,7 @@ public class GlobUnionFieldType { public static StringField name; - @IsTargetType_ + @IsTarget_ public static StringArrayField targetTypes; @Targets({}) diff --git a/src/main/java/org/globsframework/core/metamodel/type/StringFieldType.java b/src/main/java/org/globsframework/core/metamodel/type/StringFieldType.java index a548fa5..dd41122 100644 --- a/src/main/java/org/globsframework/core/metamodel/type/StringFieldType.java +++ b/src/main/java/org/globsframework/core/metamodel/type/StringFieldType.java @@ -12,8 +12,8 @@ public class StringFieldType { public static StringField name; - @Targets({KeyAnnotationType.class, IsTargetType.class, MaxSizeType.class, MultiLineTextType.class, RequiredAnnotationType.class, - NamingFieldAnnotationType.class, FieldNameAnnotationType.class, EnumAnnotationType.class}) + @Targets({KeyField.class, IsTarget.class, MaxSize.class, MultiLineText.class, Required.class, + NamingField.class, FieldName.class, EnumAnnotation.class}) public static GlobArrayUnionField annotations; public static MutableGlob create(String name) { diff --git a/src/main/java/org/globsframework/core/metamodel/utils/GlobTypeUtils.java b/src/main/java/org/globsframework/core/metamodel/utils/GlobTypeUtils.java index a5635be..8101cf3 100644 --- a/src/main/java/org/globsframework/core/metamodel/utils/GlobTypeUtils.java +++ b/src/main/java/org/globsframework/core/metamodel/utils/GlobTypeUtils.java @@ -1,8 +1,8 @@ package org.globsframework.core.metamodel.utils; import org.globsframework.core.metamodel.GlobType; -import org.globsframework.core.metamodel.annotations.FieldNameAnnotationType; -import org.globsframework.core.metamodel.annotations.NamingFieldAnnotationType; +import org.globsframework.core.metamodel.annotations.FieldName; +import org.globsframework.core.metamodel.annotations.NamingField; import org.globsframework.core.metamodel.fields.Field; import org.globsframework.core.metamodel.fields.StringField; import org.globsframework.core.model.Glob; @@ -28,7 +28,7 @@ public static GlobType getType(Class targetClass) throws InvalidParameter { } public static StringField findNamingField(GlobType type) { - Field field = type.findFieldWithAnnotation(NamingFieldAnnotationType.UNIQUE_KEY); + Field field = type.findFieldWithAnnotation(NamingField.UNIQUE_KEY); if (field != null) { return stringField(field, type); } @@ -36,7 +36,7 @@ public static StringField findNamingField(GlobType type) { } public static StringField getNamingField(GlobType type) throws ItemNotFound, ItemAmbiguity, InvalidParameter { - Field field = type.getFieldWithAnnotation(NamingFieldAnnotationType.UNIQUE_KEY); + Field field = type.getFieldWithAnnotation(NamingField.UNIQUE_KEY); return stringField(field, type); } @@ -48,7 +48,7 @@ private static StringField stringField(Field field, GlobType type) { } public static Field findNamedField(GlobType type, String name) { - Field fieldWithAnnotation = findFieldWithAnnotation(type, FieldNameAnnotationType.create(name)); + Field fieldWithAnnotation = findFieldWithAnnotation(type, FieldName.create(name)); if (fieldWithAnnotation == null) { fieldWithAnnotation = type.findField(name); } diff --git a/src/main/java/org/globsframework/core/metamodel/utils/MutableAnnotations.java b/src/main/java/org/globsframework/core/metamodel/utils/MutableAnnotations.java index 67af207..ef37da1 100644 --- a/src/main/java/org/globsframework/core/metamodel/utils/MutableAnnotations.java +++ b/src/main/java/org/globsframework/core/metamodel/utils/MutableAnnotations.java @@ -3,11 +3,12 @@ import org.globsframework.core.metamodel.Annotations; import org.globsframework.core.model.Glob; -import java.util.stream.Stream; +import java.util.Collection; public interface MutableAnnotations extends Annotations { MutableAnnotations addAnnotation(Glob glob); - MutableAnnotations addAnnotations(Stream globs); + MutableAnnotations addAnnotations(Collection glob); + } diff --git a/src/main/java/org/globsframework/core/model/Key.java b/src/main/java/org/globsframework/core/model/Key.java index a5c7b81..f7a2379 100644 --- a/src/main/java/org/globsframework/core/model/Key.java +++ b/src/main/java/org/globsframework/core/model/Key.java @@ -21,15 +21,15 @@ public interface Key extends FieldValuesAccessor, Comparable { FieldValues asFieldValues(); default int compareTo(Key o) { - int c = getGlobType().getName().compareTo(o.getGlobType().getName()); + GlobType globType = getGlobType(); + GlobType otherGlobType = o.getGlobType(); + if (globType == otherGlobType) { + return globType.sameKeyComparator().compare(this, o); + } + int c = globType.getName().compareTo(otherGlobType.getName()); if (c != 0) { return c; } - return compareSameKey(o); - } - - default int compareSameKey(Key key) { - return key.getGlobType().sameKeyComparator().compare(this, key); + throw new RuntimeException("Duplicate GlobType name " + globType.getName()); } - } diff --git a/src/test/java/org/globsframework/core/Sample.java b/src/test/java/org/globsframework/core/Sample.java index 12e1641..cef436e 100644 --- a/src/test/java/org/globsframework/core/Sample.java +++ b/src/test/java/org/globsframework/core/Sample.java @@ -19,8 +19,8 @@ public class Sample { public void readmeDynamic() { GlobType type = GlobTypeBuilderFactory.create("aType") .addIntegerKey("id") - .addStringField("string", NamingFieldAnnotationType.UNIQUE_GLOB) - .addIntegerField("anInt", FieldNameAnnotationType.create("int")) + .addStringField("string", NamingField.UNIQUE_GLOB) + .addIntegerField("anInt", FieldName.create("int")) .addLongField("long") .addDoubleField("double") .addBlobField("blob") @@ -34,21 +34,21 @@ public void readmeDynamic() { assertEquals("Hello", data.get(stringField)); - Field namingField = data.getType().findFieldWithAnnotation(NamingFieldAnnotationType.UNIQUE_KEY); + Field namingField = data.getType().findFieldWithAnnotation(NamingField.UNIQUE_KEY); assertEquals("Hello", data.getValue(namingField)); - assertEquals("int", FieldNameAnnotationType.getName(type.getField("anInt"))); + assertEquals("int", FieldName.getName(type.getField("anInt"))); } public static class AType { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; - @NamingField() + @NamingField_() public static StringField string; - @FieldNameAnnotation("int") + @FieldName_("int") public static IntegerField anInt; static { diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObject.java b/src/test/java/org/globsframework/core/metamodel/DummyObject.java index 8919cc3..02fe03f 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObject.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObject.java @@ -9,11 +9,11 @@ public class DummyObject { public static GlobType TYPE; - @KeyField - @AutoIncrement + @KeyField_ + @AutoIncrement_ public static IntegerField ID; - @NamingField + @NamingField_ public static StringField NAME; public static DoubleField VALUE; @@ -22,7 +22,7 @@ public class DummyObject { public static IntegerField DATE; public static BlobField PASSWORD; - @ContainmentLink + @ContainmentLink_ public static IntegerField LINK_ID; public static DirectLink LINK; diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObject2.java b/src/test/java/org/globsframework/core/metamodel/DummyObject2.java index 054df29..bc999dc 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObject2.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObject2.java @@ -1,7 +1,7 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.DoublePrecision; -import org.globsframework.core.metamodel.annotations.KeyField; +import org.globsframework.core.metamodel.annotations.DoublePrecision_; +import org.globsframework.core.metamodel.annotations.KeyField_; import org.globsframework.core.metamodel.fields.DoubleField; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.fields.StringField; @@ -10,12 +10,12 @@ public class DummyObject2 { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static StringField LABEL; - @DoublePrecision(4) + @DoublePrecision_(4) public static DoubleField VALUE; static { diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectIndex.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectIndex.java index 5838cb6..df44ec0 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectIndex.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectIndex.java @@ -1,7 +1,7 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.KeyField; -import org.globsframework.core.metamodel.annotations.NamingField; +import org.globsframework.core.metamodel.annotations.KeyField_; +import org.globsframework.core.metamodel.annotations.NamingField_; import org.globsframework.core.metamodel.fields.DoubleField; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.fields.StringField; @@ -14,7 +14,7 @@ public class DummyObjectIndex { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static DoubleField VALUE; @@ -22,7 +22,7 @@ public class DummyObjectIndex { public static IntegerField VALUE_2; public static IntegerField DATE; - @NamingField + @NamingField_ public static StringField NAME; public static StringField UNIQUE_NAME; diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithCompositeKey.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithCompositeKey.java index cc5aaea..d89e959 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithCompositeKey.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithCompositeKey.java @@ -1,7 +1,7 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.KeyField; -import org.globsframework.core.metamodel.annotations.NamingField; +import org.globsframework.core.metamodel.annotations.KeyField_; +import org.globsframework.core.metamodel.annotations.NamingField_; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.fields.StringField; @@ -9,12 +9,12 @@ public class DummyObjectWithCompositeKey { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID1; - @KeyField + @KeyField_ public static IntegerField ID2; - @NamingField + @NamingField_ public static StringField NAME; static { diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithDefaultValues.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithDefaultValues.java index a8a5588..c4b0296 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithDefaultValues.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithDefaultValues.java @@ -6,29 +6,29 @@ public class DummyObjectWithDefaultValues { public static GlobType TYPE; - @KeyField - @AutoIncrement + @KeyField_ + @AutoIncrement_ public static IntegerField ID; - @DefaultInteger(7) + @DefaultInteger_(7) public static IntegerField INTEGER; - @DefaultBigDecimal("1.61803398875") + @DefaultBigDecimal_("1.61803398875") public static BigDecimalField BIG_DECIMAL; - @DefaultLong(5l) + @DefaultLong_(5l) public static LongField LONG; - @DefaultDouble(3.14159265) + @DefaultDouble_(3.14159265) public static DoubleField DOUBLE; - @DefaultBoolean(true) + @DefaultBoolean_(true) public static BooleanField BOOLEAN; @Target(DummyObject.class) public static IntegerField LINK; - @DefaultString("Hello") + @DefaultString_("Hello") public static StringField STRING; static { diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithInner.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithInner.java index 7892866..2edc74d 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithInner.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithInner.java @@ -1,6 +1,6 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.KeyField; +import org.globsframework.core.metamodel.annotations.KeyField_; import org.globsframework.core.metamodel.annotations.Target; import org.globsframework.core.metamodel.annotations.Targets; import org.globsframework.core.metamodel.fields.*; @@ -9,7 +9,7 @@ public class DummyObjectWithInner { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static BlobField byteArrayData; diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithLinkFieldId.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithLinkFieldId.java index 04ee6e2..b831767 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithLinkFieldId.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithLinkFieldId.java @@ -1,7 +1,7 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.KeyField; -import org.globsframework.core.metamodel.annotations.LinkModelName; +import org.globsframework.core.metamodel.annotations.KeyField_; +import org.globsframework.core.metamodel.annotations.LinkModelName_; import org.globsframework.core.metamodel.annotations.Target; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.links.Link; @@ -9,10 +9,10 @@ public class DummyObjectWithLinkFieldId { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField LINK_ID; - @LinkModelName("ANY") + @LinkModelName_("ANY") @Target(DummyObject.class) public static Link LINK; diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithLinks.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithLinks.java index 9ec2ff2..406ff05 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithLinks.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithLinks.java @@ -1,7 +1,7 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.ContainmentLink; -import org.globsframework.core.metamodel.annotations.KeyField; +import org.globsframework.core.metamodel.annotations.ContainmentLink_; +import org.globsframework.core.metamodel.annotations.KeyField_; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.links.Link; @@ -9,7 +9,7 @@ public class DummyObjectWithLinks { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static IntegerField TARGET_ID_1; @@ -20,7 +20,7 @@ public class DummyObjectWithLinks { public static Link COMPOSITE_LINK; - @ContainmentLink + @ContainmentLink_ public static Link PARENT_LINK; public static Link SIBLING_LINK; diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithMaxSizeString.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithMaxSizeString.java index dd1f695..3fd19b4 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithMaxSizeString.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithMaxSizeString.java @@ -1,19 +1,19 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.KeyField; -import org.globsframework.core.metamodel.annotations.MaxSize; -import org.globsframework.core.metamodel.annotations.NamingField; +import org.globsframework.core.metamodel.annotations.KeyField_; +import org.globsframework.core.metamodel.annotations.MaxSize_; +import org.globsframework.core.metamodel.annotations.NamingField_; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.fields.StringField; public class DummyObjectWithMaxSizeString { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; - @NamingField - @MaxSize(10) + @NamingField_ + @MaxSize_(10) public static StringField TEXT; static { diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithMultiLineText.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithMultiLineText.java index d9428fd..b728bc5 100755 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithMultiLineText.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithMultiLineText.java @@ -1,17 +1,17 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.KeyField; -import org.globsframework.core.metamodel.annotations.MultiLineText; +import org.globsframework.core.metamodel.annotations.KeyField_; +import org.globsframework.core.metamodel.annotations.MultiLineText_; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.fields.StringField; public class DummyObjectWithMultiLineText { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; - @MultiLineText() + @MultiLineText_() public static StringField COMMENT; static { diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithQuadrupleKey.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithQuadrupleKey.java index 8230e49..ce46308 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithQuadrupleKey.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithQuadrupleKey.java @@ -1,7 +1,7 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.KeyField; -import org.globsframework.core.metamodel.annotations.NamingField; +import org.globsframework.core.metamodel.annotations.KeyField_; +import org.globsframework.core.metamodel.annotations.NamingField_; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.fields.StringField; @@ -9,16 +9,16 @@ public class DummyObjectWithQuadrupleKey { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID1; - @KeyField + @KeyField_ public static IntegerField ID2; - @KeyField + @KeyField_ public static IntegerField ID3; - @KeyField + @KeyField_ public static IntegerField ID4; - @NamingField + @NamingField_ public static StringField NAME; static { diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithRequiredFields.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithRequiredFields.java index 94382bd..2ec0088 100755 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithRequiredFields.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithRequiredFields.java @@ -1,20 +1,20 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.KeyField; -import org.globsframework.core.metamodel.annotations.Required; +import org.globsframework.core.metamodel.annotations.KeyField_; +import org.globsframework.core.metamodel.annotations.Required_; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.fields.StringField; public class DummyObjectWithRequiredFields { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; - @Required + @Required_ public static IntegerField VALUE; - @Required + @Required_ public static StringField NAME; static { diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithRequiredLink.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithRequiredLink.java index e09062d..a34171e 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithRequiredLink.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithRequiredLink.java @@ -1,7 +1,7 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.KeyField; -import org.globsframework.core.metamodel.annotations.Required; +import org.globsframework.core.metamodel.annotations.KeyField_; +import org.globsframework.core.metamodel.annotations.Required_; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.fields.StringField; import org.globsframework.core.metamodel.links.Link; @@ -9,14 +9,14 @@ public class DummyObjectWithRequiredLink { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static IntegerField TARGET_ID; public static StringField NAME; - @Required + @Required_ public static Link LINK; static { diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithStringKey.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithStringKey.java index b10bde7..1428f03 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithStringKey.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithStringKey.java @@ -1,12 +1,12 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.KeyField; +import org.globsframework.core.metamodel.annotations.KeyField_; import org.globsframework.core.metamodel.fields.StringField; public class DummyObjectWithStringKey { public static GlobType TYPE; - @KeyField + @KeyField_ public static StringField ID; static { diff --git a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithTripleKey.java b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithTripleKey.java index 7a1f91d..529f2fb 100644 --- a/src/test/java/org/globsframework/core/metamodel/DummyObjectWithTripleKey.java +++ b/src/test/java/org/globsframework/core/metamodel/DummyObjectWithTripleKey.java @@ -1,7 +1,7 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.KeyField; -import org.globsframework.core.metamodel.annotations.NamingField; +import org.globsframework.core.metamodel.annotations.KeyField_; +import org.globsframework.core.metamodel.annotations.NamingField_; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.fields.StringField; @@ -9,14 +9,14 @@ public class DummyObjectWithTripleKey { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID1; - @KeyField + @KeyField_ public static IntegerField ID2; - @KeyField + @KeyField_ public static IntegerField ID3; - @NamingField + @NamingField_ public static StringField NAME; static { diff --git a/src/test/java/org/globsframework/core/metamodel/GlobTypeBuilderTest.java b/src/test/java/org/globsframework/core/metamodel/GlobTypeBuilderTest.java index 6621c6a..07f962d 100644 --- a/src/test/java/org/globsframework/core/metamodel/GlobTypeBuilderTest.java +++ b/src/test/java/org/globsframework/core/metamodel/GlobTypeBuilderTest.java @@ -1,7 +1,7 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.DefaultDoubleAnnotationType; -import org.globsframework.core.metamodel.annotations.NamingFieldAnnotationType; +import org.globsframework.core.metamodel.annotations.DefaultDouble; +import org.globsframework.core.metamodel.annotations.NamingField; import org.globsframework.core.metamodel.fields.*; import org.globsframework.core.metamodel.type.DataType; import org.globsframework.core.metamodel.utils.GlobTypeUtils; @@ -92,7 +92,7 @@ public void testAtLeastOneKeyMustBeDefined() throws Exception { public void testNamingField() throws Exception { GlobType type = GlobTypeBuilderFactory.create("aType") .addIntegerKey("id") - .addStringField("name", NamingFieldAnnotationType.UNIQUE_GLOB) + .addStringField("name", NamingField.UNIQUE_GLOB) .get(); StringField field = GlobTypeUtils.findNamingField(type); @@ -103,7 +103,7 @@ public void testNamingField() throws Exception { @Test public void testWithAnnotations() throws Exception { GlobTypeBuilderFactory.create("aType") - .addDoubleField("aDouble", DefaultDoubleAnnotationType.create(2.2)); + .addDoubleField("aDouble", DefaultDouble.create(2.2)); } } diff --git a/src/test/java/org/globsframework/core/metamodel/GlobTypeLoaderTest.java b/src/test/java/org/globsframework/core/metamodel/GlobTypeLoaderTest.java index 93bb636..bef22df 100644 --- a/src/test/java/org/globsframework/core/metamodel/GlobTypeLoaderTest.java +++ b/src/test/java/org/globsframework/core/metamodel/GlobTypeLoaderTest.java @@ -39,7 +39,7 @@ public static class AnObject { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static StringField STRING; @@ -182,7 +182,7 @@ public void testObjectWithSeveralTypeDefs() throws Exception { public static class AnObjectForDoubleInit { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; } @@ -214,9 +214,9 @@ public void testObjectWithNoKey() throws Exception { public static class AnObjectWithACompositeKey { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID1; - @KeyField + @KeyField_ public static IntegerField ID2; static { @@ -233,7 +233,7 @@ public void testAnObjectWithACompositeKey() throws Exception { public static class AnObjectWithALinkField { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static IntegerField LINK_ID; @@ -268,7 +268,7 @@ public void testLinkField() throws Exception { public static class AnObjectWithALinkFieldWithoutTheTargetAnnotation { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static IntegerField LINK_ID; @@ -291,7 +291,7 @@ public void testAnObjectWithALinkFieldWithoutTheTargetAnnotation() throws Except public static class AnObjectWithALinkFieldTargettingAMultiKeyObject { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; @Target(AnObjectWithACompositeKey.class) @@ -317,7 +317,7 @@ public void testAnObjectWithALinkFieldTargettingAMultiKeyObject() throws Excepti public static class AnObjectWithALinkFieldTargettingANonGlobsObject { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static IntegerField LINK; @@ -340,7 +340,7 @@ public void testAnObjectWithALinkFieldTargettingANonGlobsObject() throws Excepti public static class AnObjectWithAStringId { public static GlobType TYPE; - @KeyField + @KeyField_ public static StringField ID; static { @@ -350,7 +350,7 @@ public static class AnObjectWithAStringId { public static class AnObjectWithALinkFieldTargettingAnObjectWithAStringId { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static StringField LINK_ID; @@ -371,7 +371,7 @@ public void testAnObjectWithALinkFieldTargettingAnObjectWithAStringId() throws E public static class AnObjectWithASingleIntegerFieldUsedAsALink { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static IntegerField LINK_ID; public static Link LINK; @@ -433,7 +433,7 @@ public static class AnObjectWithCustomAnnotations { @MyAnnotation("class annotations") public static GlobType TYPE; - @KeyField + @KeyField_ @MyAnnotation("field annotations") public static IntegerField ID; @@ -463,7 +463,7 @@ public void testRetrievingAnnotatedFields() throws Exception { public static class AnObjectWithCustomLinkAnnotations { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; @MyAnnotation("link annotation") @@ -485,11 +485,11 @@ public static class AnObjectWithRequiredFields { public static GlobType TYPE; - @Required - @KeyField + @Required_ + @KeyField_ public static IntegerField ID; - @Required + @Required_ public static StringField STRING; public static DoubleField DOUBLE; @@ -509,8 +509,8 @@ public void testAnObjectWithRequiredFields() throws Exception { @Test public void testAnObjectWithDefaultValues() throws Exception { assertEquals(7, DummyObjectWithDefaultValues.INTEGER.getDefaultValue()); - assertEquals(7, DummyObjectWithDefaultValues.INTEGER.getAnnotation(DefaultIntegerAnnotationType.UNIQUE_KEY) - .get(DefaultIntegerAnnotationType.DEFAULT_VALUE).intValue()); + assertEquals(7, DummyObjectWithDefaultValues.INTEGER.getAnnotation(DefaultInteger.UNIQUE_KEY) + .get(DefaultInteger.VALUE).intValue()); assertEquals(3.14159265, DummyObjectWithDefaultValues.DOUBLE.getDefaultValue()); assertEquals(5l, DummyObjectWithDefaultValues.LONG.getDefaultValue()); assertEquals(true, DummyObjectWithDefaultValues.BOOLEAN.getDefaultValue()); @@ -522,10 +522,10 @@ public void testAnObjectWithDefaultValues() throws Exception { public static class AnObjectWithADefaultValueTypeError { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; - @DefaultBoolean(true) + @DefaultBoolean_(true) public static IntegerField COUNT; } @@ -546,12 +546,12 @@ public static class AnObjectWithRequiredLinks { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static IntegerField LINK_ID; - @Required + @Required_ public static Link LINK; static { @@ -573,13 +573,13 @@ public static class AnObjectWithRequiredLinkField { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; @Target(DummyObject.class) public static IntegerField LINK_ID; - @Required + @Required_ public static Link LINK; diff --git a/src/test/java/org/globsframework/core/metamodel/GlobTypeTest.java b/src/test/java/org/globsframework/core/metamodel/GlobTypeTest.java index 4ae3230..269be18 100644 --- a/src/test/java/org/globsframework/core/metamodel/GlobTypeTest.java +++ b/src/test/java/org/globsframework/core/metamodel/GlobTypeTest.java @@ -1,6 +1,6 @@ package org.globsframework.core.metamodel; -import org.globsframework.core.metamodel.annotations.NamingFieldAnnotationType; +import org.globsframework.core.metamodel.annotations.NamingField; import org.globsframework.core.utils.TestUtils; import org.junit.Test; @@ -9,7 +9,7 @@ public class GlobTypeTest { @Test public void testRetrieveFieldFromAnnotation() { TestUtils.assertContains(DummyObjectWithMaxSizeString.TYPE - .getFieldsWithAnnotation(NamingFieldAnnotationType.UNIQUE_KEY), DummyObjectWithMaxSizeString.TEXT); + .getFieldsWithAnnotation(NamingField.UNIQUE_KEY), DummyObjectWithMaxSizeString.TEXT); } diff --git a/src/test/java/org/globsframework/core/metamodel/annotations/MaxSizeTypeTest.java b/src/test/java/org/globsframework/core/metamodel/annotations/MaxSizeTest.java similarity index 83% rename from src/test/java/org/globsframework/core/metamodel/annotations/MaxSizeTypeTest.java rename to src/test/java/org/globsframework/core/metamodel/annotations/MaxSizeTest.java index 5c13e02..31e80f0 100644 --- a/src/test/java/org/globsframework/core/metamodel/annotations/MaxSizeTypeTest.java +++ b/src/test/java/org/globsframework/core/metamodel/annotations/MaxSizeTest.java @@ -10,7 +10,7 @@ import static org.junit.Assert.fail; -public class MaxSizeTypeTest { +public class MaxSizeTest { @Test public void deepSize() { @@ -18,7 +18,7 @@ public void deepSize() { MutableGlob g1 = Dummy_Level1.TYPE.instantiate() .set(Dummy_Level1.VALUE_1, "123") .set(Dummy_Level1.VALUE_2, "12345"); - MutableGlob mutableGlob = MaxSizeType.deepInPlaceTruncate(g1); + MutableGlob mutableGlob = MaxSize.deepInPlaceTruncate(g1); Assert.assertEquals(mutableGlob.get(Dummy_Level1.VALUE_2), "123"); Assert.assertEquals(mutableGlob.get(Dummy_Level1.VALUE_1), "123"); @@ -27,9 +27,9 @@ public void deepSize() { .set(Dummy_Level1.VALUE_2, "12345"); try { - MaxSizeType.deepInPlaceTruncate(g2); + MaxSize.deepInPlaceTruncate(g2); fail(); - } catch (MaxSizeType.StringToLongException e) { + } catch (MaxSize.StringToLongException e) { } } { @@ -40,7 +40,7 @@ public void deepSize() { MutableGlob g2 = Dummy_Level1.TYPE.instantiate() .set(Dummy_Level1.UNDER, g1); - MaxSizeType.deepInPlaceTruncate(g2); + MaxSize.deepInPlaceTruncate(g2); Assert.assertEquals(g2.get(Dummy_Level1.UNDER).get(Dummy_Level1.VALUE_2), "123"); @@ -52,7 +52,7 @@ public void deepSize() { MutableGlob g2 = Dummy_Level1.TYPE.instantiate() .set(Dummy_Level1.UNDER, g1); - MaxSizeType.deepInPlaceTruncate(g2); + MaxSize.deepInPlaceTruncate(g2); Assert.assertEquals(g2.get(Dummy_Level1.UNDER).get(Dummy_Level1.VALUE_2), "é"); @@ -62,13 +62,13 @@ public void deepSize() { public static class Dummy_Level1 { public static GlobType TYPE; - @MaxSize(3) + @MaxSize_(3) public static StringField VALUE_1; - @MaxSize(value = 3, allow_truncate = true) + @MaxSize_(value = 3, allow_truncate = true) public static StringField VALUE_2; - @MaxSize(value = 50, allow_truncate = true) + @MaxSize_(value = 50, allow_truncate = true) public static StringField VALUE_3; @Target(Dummy_Level1.class) diff --git a/src/test/java/org/globsframework/core/metamodel/utils/DefaultGlobModelTest.java b/src/test/java/org/globsframework/core/metamodel/utils/DefaultGlobModelTest.java index 5a3b0bb..81b892e 100644 --- a/src/test/java/org/globsframework/core/metamodel/utils/DefaultGlobModelTest.java +++ b/src/test/java/org/globsframework/core/metamodel/utils/DefaultGlobModelTest.java @@ -1,8 +1,8 @@ package org.globsframework.core.metamodel.utils; import org.globsframework.core.metamodel.*; -import org.globsframework.core.metamodel.annotations.KeyField; -import org.globsframework.core.metamodel.annotations.Required; +import org.globsframework.core.metamodel.annotations.KeyField_; +import org.globsframework.core.metamodel.annotations.Required_; import org.globsframework.core.metamodel.annotations.Target; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.impl.DefaultGlobModel; @@ -31,7 +31,7 @@ public void testStandardCase() throws Exception { public static class LargeLinkCycle1 { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; @Target(LargeLinkCycle2.class) @@ -52,7 +52,7 @@ public static class LargeLinkCycle1 { public static class LargeLinkCycle2 { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; @Target(LargeLinkCycle3.class) @@ -73,7 +73,7 @@ public static class LargeLinkCycle2 { public static class LargeLinkCycle3 { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; @Target(LargeLinkCycle1.class) @@ -129,10 +129,10 @@ public void testDependenciesWithInnerModel() throws Exception { public static class LargeLinkCycleWithRequiredFieldError1 { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; - @Required + @Required_ @Target(LargeLinkCycleWithRequiredFieldError2.class) public static IntegerField LINK_ID; @@ -151,10 +151,10 @@ public static class LargeLinkCycleWithRequiredFieldError1 { public static class LargeLinkCycleWithRequiredFieldError2 { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; - @Required + @Required_ @Target(LargeLinkCycleWithRequiredFieldError3.class) public static IntegerField LINK_ID; @@ -173,10 +173,10 @@ public static class LargeLinkCycleWithRequiredFieldError2 { public static class LargeLinkCycleWithRequiredFieldError3 { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; - @Required + @Required_ @Target(LargeLinkCycleWithRequiredFieldError1.class) public static IntegerField LINK_ID; diff --git a/src/test/java/org/globsframework/core/metamodel/utils/DefaultGlobTypeTest.java b/src/test/java/org/globsframework/core/metamodel/utils/DefaultGlobTypeTest.java index bb9f500..65cecd3 100644 --- a/src/test/java/org/globsframework/core/metamodel/utils/DefaultGlobTypeTest.java +++ b/src/test/java/org/globsframework/core/metamodel/utils/DefaultGlobTypeTest.java @@ -4,9 +4,9 @@ import org.globsframework.core.metamodel.GlobType; import org.globsframework.core.metamodel.GlobTypeLoader; import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.annotations.FieldNameAnnotation; -import org.globsframework.core.metamodel.annotations.FieldNameAnnotationType; -import org.globsframework.core.metamodel.annotations.KeyField; +import org.globsframework.core.metamodel.annotations.FieldName_; +import org.globsframework.core.metamodel.annotations.FieldName; +import org.globsframework.core.metamodel.annotations.KeyField_; import org.globsframework.core.metamodel.fields.Field; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.impl.DefaultGlobModel; @@ -34,17 +34,17 @@ public void testFields() { @Test public void testFindFieldByAnnotation() { - Field qty = GlobTypeUtils.findFieldWithAnnotation(TypeWithAnnotation.TYPE, FieldNameAnnotationType.create("qty")); + Field qty = GlobTypeUtils.findFieldWithAnnotation(TypeWithAnnotation.TYPE, FieldName.create("qty")); Assert.assertSame(qty, TypeWithAnnotation.F1); - Field sku = GlobTypeUtils.findFieldWithAnnotation(TypeWithAnnotation.TYPE, FieldNameAnnotationType.create("ean")); + Field sku = GlobTypeUtils.findFieldWithAnnotation(TypeWithAnnotation.TYPE, FieldName.create("ean")); Assert.assertSame(sku, TypeWithAnnotation.F2); } public static class Type { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField FIELD1; } @@ -60,10 +60,10 @@ private void initGlobType() { public static class TypeWithAnnotation { public static GlobType TYPE; - @FieldNameAnnotation("qty") + @FieldName_("qty") public static IntegerField F1; - @FieldNameAnnotation("ean") + @FieldName_("ean") public static IntegerField F2; static { diff --git a/src/test/java/org/globsframework/core/metamodel/utils/GlobTypeUtilsTest.java b/src/test/java/org/globsframework/core/metamodel/utils/GlobTypeUtilsTest.java index 911d035..67061e7 100644 --- a/src/test/java/org/globsframework/core/metamodel/utils/GlobTypeUtilsTest.java +++ b/src/test/java/org/globsframework/core/metamodel/utils/GlobTypeUtilsTest.java @@ -2,7 +2,7 @@ import org.globsframework.core.metamodel.DummyObject; import org.globsframework.core.metamodel.DummyObject2; -import org.globsframework.core.metamodel.annotations.NamingFieldAnnotationType; +import org.globsframework.core.metamodel.annotations.NamingField; import org.globsframework.core.utils.exceptions.ItemNotFound; import org.junit.Test; @@ -29,7 +29,7 @@ public void testGetNamingField() throws Exception { GlobTypeUtils.getNamingField(DummyObject2.TYPE); fail(); } catch (ItemNotFound e) { - assertEquals("no field found with EmptyKey/" + NamingFieldAnnotationType.TYPE.getName() + " under dummyObject2", e.getMessage()); + assertEquals("no field found with EmptyKey/" + NamingField.TYPE.getName() + " under dummyObject2", e.getMessage()); } } diff --git a/src/test/java/org/globsframework/core/model/delta/InDepthChangeSetTest.java b/src/test/java/org/globsframework/core/model/delta/InDepthChangeSetTest.java index 5a18c17..47109e4 100644 --- a/src/test/java/org/globsframework/core/model/delta/InDepthChangeSetTest.java +++ b/src/test/java/org/globsframework/core/model/delta/InDepthChangeSetTest.java @@ -2,7 +2,7 @@ import org.globsframework.core.metamodel.GlobType; import org.globsframework.core.metamodel.GlobTypeLoaderFactory; -import org.globsframework.core.metamodel.annotations.KeyField; +import org.globsframework.core.metamodel.annotations.KeyField_; import org.globsframework.core.metamodel.annotations.Target; import org.globsframework.core.metamodel.fields.GlobArrayField; import org.globsframework.core.metamodel.fields.GlobField; @@ -82,7 +82,7 @@ public void name() { public static class DummyType { public static GlobType TYPE; - @KeyField + @KeyField_ public static StringField UUID; public static StringField NAME; @@ -101,7 +101,7 @@ public static class DummyType { public static class SubType { public static GlobType TYPE; - @KeyField + @KeyField_ public static StringField UUID; public static StringField SUB_NAME; @@ -115,7 +115,7 @@ public static class SubType { public static class SubTypeWWithoutKey { public static GlobType TYPE; - @KeyField + @KeyField_ public static StringField UUID; public static IntegerField COUNT; diff --git a/src/test/java/org/globsframework/core/model/impl/CompositeKeyTest.java b/src/test/java/org/globsframework/core/model/impl/CompositeKeyTest.java index 0ffa585..14f0dc8 100644 --- a/src/test/java/org/globsframework/core/model/impl/CompositeKeyTest.java +++ b/src/test/java/org/globsframework/core/model/impl/CompositeKeyTest.java @@ -1,7 +1,7 @@ package org.globsframework.core.model.impl; import org.globsframework.core.metamodel.*; -import org.globsframework.core.metamodel.annotations.KeyAnnotationType; +import org.globsframework.core.metamodel.annotations.KeyField; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.model.Glob; import org.globsframework.core.model.Key; @@ -16,10 +16,10 @@ public class CompositeKeyTest { public void keyFieldNotAtBegin() throws Exception { GlobTypeBuilder builder = GlobTypeBuilderFactory.create("CompositeKey"); builder.addStringField("field_1"); - IntegerField id1 = builder.declareIntegerField("id1", KeyAnnotationType.UNINITIALIZED); + IntegerField id1 = builder.declareIntegerField("id1", KeyField.UNINITIALIZED); builder.addStringField("field_2"); - IntegerField id2 = builder.declareIntegerField("id2", KeyAnnotationType.UNINITIALIZED); - IntegerField id3 = builder.declareIntegerField("id3", KeyAnnotationType.UNINITIALIZED); + IntegerField id2 = builder.declareIntegerField("id2", KeyField.UNINITIALIZED); + IntegerField id3 = builder.declareIntegerField("id3", KeyField.UNINITIALIZED); GlobType type = builder.get(); Glob glob = type.instantiate().set(id1, 1).set(id2, 2).set(id3, 3); Key actual = KeyBuilder.init(type).set(id1, 1) diff --git a/src/test/java/org/globsframework/core/model/utils/ChangeSetSequencerTest.java b/src/test/java/org/globsframework/core/model/utils/ChangeSetSequencerTest.java index 93796ff..7a35767 100644 --- a/src/test/java/org/globsframework/core/model/utils/ChangeSetSequencerTest.java +++ b/src/test/java/org/globsframework/core/model/utils/ChangeSetSequencerTest.java @@ -2,7 +2,7 @@ import junit.framework.AssertionFailedError; import org.globsframework.core.metamodel.*; -import org.globsframework.core.metamodel.annotations.KeyField; +import org.globsframework.core.metamodel.annotations.KeyField_; import org.globsframework.core.metamodel.annotations.Target; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.fields.StringField; @@ -21,10 +21,10 @@ public class ChangeSetSequencerTest { public static class ObjectWithCompositeKey { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID1; - @KeyField + @KeyField_ public static IntegerField ID2; public static StringField NAME; @@ -37,7 +37,7 @@ public static class ObjectWithCompositeKey { public static class LinkedToObjectWithCompositeKey { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static IntegerField LINK1; @@ -86,7 +86,7 @@ public void testSingleTypeWithUpdateOnCreate() throws Exception { public static class ObjectWithSelfReference { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static IntegerField LINK_ID; @@ -134,10 +134,10 @@ public void testObjectWithSelfReference() throws Exception { public static class LinkCycle1 { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID1; - @KeyField + @KeyField_ public static IntegerField ID2; @Target(ObjectWithCompositeKey.class) @@ -161,10 +161,10 @@ public static class LinkCycle1 { public static class LinkCycle2 { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID1; - @KeyField + @KeyField_ public static IntegerField ID2; @Target(ObjectWithCompositeKey.class) @@ -227,7 +227,7 @@ public void testLinkCycle() throws Exception { public static class LargeLinkCycle1 { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; // @Target(LargeLinkCycle2.class) @@ -248,7 +248,7 @@ public static class LargeLinkCycle1 { public static class LargeLinkCycle2 { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; // @Target(LargeLinkCycle3.class) @@ -269,7 +269,7 @@ public static class LargeLinkCycle2 { public static class LargeLinkCycle3 { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; @Target(LargeLinkCycle1.class) diff --git a/src/test/java/org/globsframework/core/utils/container/specific/HashMapGlobKeyContainerTest.java b/src/test/java/org/globsframework/core/utils/container/specific/HashMapGlobKeyContainerTest.java index f22f55b..a24d759 100644 --- a/src/test/java/org/globsframework/core/utils/container/specific/HashMapGlobKeyContainerTest.java +++ b/src/test/java/org/globsframework/core/utils/container/specific/HashMapGlobKeyContainerTest.java @@ -4,7 +4,9 @@ import org.globsframework.core.metamodel.GlobType; import org.globsframework.core.metamodel.GlobTypeLoaderFactory; import org.globsframework.core.metamodel.annotations.AutoIncrement; +import org.globsframework.core.metamodel.annotations.AutoIncrement_; import org.globsframework.core.metamodel.annotations.KeyField; +import org.globsframework.core.metamodel.annotations.KeyField_; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.model.Glob; import org.globsframework.core.model.Key; @@ -21,16 +23,16 @@ static public class DummyObject { public static GlobType TYPE; - @KeyField - @AutoIncrement + @KeyField_ + @AutoIncrement_ public static IntegerField ID1; - @KeyField - @AutoIncrement + @KeyField_ + @AutoIncrement_ public static IntegerField ID2; - @KeyField - @AutoIncrement + @KeyField_ + @AutoIncrement_ public static IntegerField ID3; static { diff --git a/src/test/java/org/globsframework/core/xml/XmlGlobWriter.java b/src/test/java/org/globsframework/core/xml/XmlGlobWriter.java index 5325609..60c91e1 100644 --- a/src/test/java/org/globsframework/core/xml/XmlGlobWriter.java +++ b/src/test/java/org/globsframework/core/xml/XmlGlobWriter.java @@ -1,7 +1,7 @@ package org.globsframework.core.xml; import org.globsframework.core.metamodel.GlobLinkModel; -import org.globsframework.core.metamodel.annotations.FieldNameAnnotationType; +import org.globsframework.core.metamodel.annotations.FieldName; import org.globsframework.core.metamodel.fields.Field; import org.globsframework.core.metamodel.links.Link; import org.globsframework.core.metamodel.links.impl.DefaultDirectSingleLink; @@ -83,7 +83,7 @@ private void writeFields(Glob glob, Writer writer) throws IOException { } private void writeFieldValue(Writer writer, Field field, Object value) throws IOException { - writeAttribute(writer, FieldNameAnnotationType.getName(field), fieldConverter.toString(field, value)); + writeAttribute(writer, FieldName.getName(field), fieldConverter.toString(field, value)); } public static void write(Collection globs, GlobRepository repository, Writer writer, GlobLinkModel globLinkModel) throws ResourceAccessFailed { diff --git a/src/test/java/org/globsframework/core/xml/tests/XmlGlobParserTest.java b/src/test/java/org/globsframework/core/xml/tests/XmlGlobParserTest.java index 099f215..fcbde03 100644 --- a/src/test/java/org/globsframework/core/xml/tests/XmlGlobParserTest.java +++ b/src/test/java/org/globsframework/core/xml/tests/XmlGlobParserTest.java @@ -1,7 +1,7 @@ package org.globsframework.core.xml.tests; import org.globsframework.core.metamodel.*; -import org.globsframework.core.metamodel.annotations.KeyField; +import org.globsframework.core.metamodel.annotations.KeyField_; import org.globsframework.core.metamodel.annotations.Target; import org.globsframework.core.metamodel.fields.IntegerField; import org.globsframework.core.metamodel.links.Link; @@ -145,7 +145,7 @@ public void testContainmentWithCompositeLink() throws Exception { public static class AnObjectLinkingToATypeWithNoNamingField { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; public static IntegerField OBJ2_ID; @@ -212,7 +212,7 @@ public void testInvalideReadSetDefaultValues() throws Exception { public static class AnObject { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; static { @@ -222,7 +222,7 @@ public static class AnObject { public static class AnObjectWithTwoLinks { public static GlobType TYPE; - @KeyField + @KeyField_ public static IntegerField ID; @Target(AnObject.class)