From de92d6843fb07007973352d13c19dd36c7e10462 Mon Sep 17 00:00:00 2001 From: Siphalor Date: Sun, 20 Apr 2025 21:19:00 +0200 Subject: [PATCH] [core, serde-extension, weaver-pojo] Remove the coherent from collection stuff --- ...gEntry.java => CollectionConfigEntry.java} | 2 +- ...pl.java => CollectionConfigEntryImpl.java} | 4 +- .../readwrite/TweedEntryReaderWriters.java | 6 +-- ...ltTweedEntryReaderWriterImplsProvider.java | 4 +- .../impl/TweedEntryReaderWriterImpls.java | 10 ++--- .../impl/ReadWriteExtensionImplTest.java | 8 ++-- ...ionWeaving.java => CollectionWeaving.java} | 6 +-- ...ava => WeavableCollectionConfigEntry.java} | 8 ++-- ...oWeaver.java => CollectionPojoWeaver.java} | 45 ++++++++++--------- ...pl.java => CollectionConfigEntryImpl.java} | 6 +-- .../CoherentCollectionWeavingConfig.java | 10 ----- .../CoherentCollectionWeavingConfigImpl.java | 21 --------- .../collection/CollectionWeavingConfig.java | 10 +++++ .../CollectionWeavingConfigImpl.java | 21 +++++++++ .../TweedPojoWeaverBootstrapperTest.java | 4 +- .../pojo/test/ConfigEntryAssertions.java | 8 ++-- 16 files changed, 86 insertions(+), 87 deletions(-) rename tweed5-core/src/main/java/de/siphalor/tweed5/core/api/entry/{CoherentCollectionConfigEntry.java => CollectionConfigEntry.java} (59%) rename tweed5-core/src/main/java/de/siphalor/tweed5/core/impl/entry/{CoherentCollectionConfigEntryImpl.java => CollectionConfigEntryImpl.java} (84%) rename tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/annotation/{CoherentCollectionWeaving.java => CollectionWeaving.java} (54%) rename tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/entry/{WeavableCoherentCollectionConfigEntry.java => WeavableCollectionConfigEntry.java} (81%) rename tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/weaving/{CoherentCollectionPojoWeaver.java => CollectionPojoWeaver.java} (61%) rename tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/entry/{CoherentCollectionConfigEntryImpl.java => CollectionConfigEntryImpl.java} (82%) delete mode 100644 tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/coherentcollection/CoherentCollectionWeavingConfig.java delete mode 100644 tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/coherentcollection/CoherentCollectionWeavingConfigImpl.java create mode 100644 tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/collection/CollectionWeavingConfig.java create mode 100644 tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/collection/CollectionWeavingConfigImpl.java diff --git a/tweed5-core/src/main/java/de/siphalor/tweed5/core/api/entry/CoherentCollectionConfigEntry.java b/tweed5-core/src/main/java/de/siphalor/tweed5/core/api/entry/CollectionConfigEntry.java similarity index 59% rename from tweed5-core/src/main/java/de/siphalor/tweed5/core/api/entry/CoherentCollectionConfigEntry.java rename to tweed5-core/src/main/java/de/siphalor/tweed5/core/api/entry/CollectionConfigEntry.java index 16e70a7..1d7ab5f 100644 --- a/tweed5-core/src/main/java/de/siphalor/tweed5/core/api/entry/CoherentCollectionConfigEntry.java +++ b/tweed5-core/src/main/java/de/siphalor/tweed5/core/api/entry/CollectionConfigEntry.java @@ -2,7 +2,7 @@ package de.siphalor.tweed5.core.api.entry; import java.util.Collection; -public interface CoherentCollectionConfigEntry> extends ConfigEntry { +public interface CollectionConfigEntry> extends ConfigEntry { ConfigEntry elementEntry(); T instantiateCollection(int size); diff --git a/tweed5-core/src/main/java/de/siphalor/tweed5/core/impl/entry/CoherentCollectionConfigEntryImpl.java b/tweed5-core/src/main/java/de/siphalor/tweed5/core/impl/entry/CollectionConfigEntryImpl.java similarity index 84% rename from tweed5-core/src/main/java/de/siphalor/tweed5/core/impl/entry/CoherentCollectionConfigEntryImpl.java rename to tweed5-core/src/main/java/de/siphalor/tweed5/core/impl/entry/CollectionConfigEntryImpl.java index 479d583..d9933a6 100644 --- a/tweed5-core/src/main/java/de/siphalor/tweed5/core/impl/entry/CoherentCollectionConfigEntryImpl.java +++ b/tweed5-core/src/main/java/de/siphalor/tweed5/core/impl/entry/CollectionConfigEntryImpl.java @@ -6,11 +6,11 @@ import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.function.IntFunction; -public class CoherentCollectionConfigEntryImpl> extends BaseConfigEntry implements CoherentCollectionConfigEntry { +public class CollectionConfigEntryImpl> extends BaseConfigEntry implements CollectionConfigEntry { private final IntFunction collectionConstructor; private ConfigEntry elementEntry; - public CoherentCollectionConfigEntryImpl(Class valueClass, IntFunction collectionConstructor) { + public CollectionConfigEntryImpl(Class valueClass, IntFunction collectionConstructor) { super(valueClass); this.collectionConstructor = collectionConstructor; } diff --git a/tweed5-serde-extension/src/main/java/de/siphalor/tweed5/data/extension/api/readwrite/TweedEntryReaderWriters.java b/tweed5-serde-extension/src/main/java/de/siphalor/tweed5/data/extension/api/readwrite/TweedEntryReaderWriters.java index 056b0bc..19f6679 100644 --- a/tweed5-serde-extension/src/main/java/de/siphalor/tweed5/data/extension/api/readwrite/TweedEntryReaderWriters.java +++ b/tweed5-serde-extension/src/main/java/de/siphalor/tweed5/data/extension/api/readwrite/TweedEntryReaderWriters.java @@ -1,6 +1,6 @@ package de.siphalor.tweed5.data.extension.api.readwrite; -import de.siphalor.tweed5.core.api.entry.CoherentCollectionConfigEntry; +import de.siphalor.tweed5.core.api.entry.CollectionConfigEntry; import de.siphalor.tweed5.core.api.entry.CompoundConfigEntry; import de.siphalor.tweed5.core.api.entry.ConfigEntry; import de.siphalor.tweed5.data.extension.api.TweedEntryReader; @@ -53,9 +53,9 @@ public class TweedEntryReaderWriters { return new TweedEntryReaderWriterImpls.NullableWriter<>(delegate); } - public static > TweedEntryReaderWriter> coherentCollectionReaderWriter() { + public static > TweedEntryReaderWriter> collectionReaderWriter() { //noinspection unchecked - return (TweedEntryReaderWriter>)(TweedEntryReaderWriter) TweedEntryReaderWriterImpls.COHERENT_COLLECTION_READER_WRITER; + return (TweedEntryReaderWriter>)(TweedEntryReaderWriter) TweedEntryReaderWriterImpls.COLLECTION_READER_WRITER; } public static TweedEntryReaderWriter> compoundReaderWriter() { diff --git a/tweed5-serde-extension/src/main/java/de/siphalor/tweed5/data/extension/impl/DefaultTweedEntryReaderWriterImplsProvider.java b/tweed5-serde-extension/src/main/java/de/siphalor/tweed5/data/extension/impl/DefaultTweedEntryReaderWriterImplsProvider.java index 50a4dcd..2450f46 100644 --- a/tweed5-serde-extension/src/main/java/de/siphalor/tweed5/data/extension/impl/DefaultTweedEntryReaderWriterImplsProvider.java +++ b/tweed5-serde-extension/src/main/java/de/siphalor/tweed5/data/extension/impl/DefaultTweedEntryReaderWriterImplsProvider.java @@ -37,8 +37,8 @@ public class DefaultTweedEntryReaderWriterImplsProvider implements TweedReaderWr context.registerWriterFactory("tweed5.double", new StaticReaderWriterFactory<>(doubleReaderWriter())); context.registerReaderFactory("tweed5.string", new StaticReaderWriterFactory<>(stringReaderWriter())); context.registerWriterFactory("tweed5.string", new StaticReaderWriterFactory<>(stringReaderWriter())); - context.registerReaderFactory("tweed5.collection.coherent", new StaticReaderWriterFactory<>(coherentCollectionReaderWriter())); - context.registerWriterFactory("tweed5.collection.coherent", new StaticReaderWriterFactory<>(coherentCollectionReaderWriter())); + context.registerReaderFactory("tweed5.collection", new StaticReaderWriterFactory<>(collectionReaderWriter())); + context.registerWriterFactory("tweed5.collection", new StaticReaderWriterFactory<>(collectionReaderWriter())); context.registerReaderFactory("tweed5.compound", new StaticReaderWriterFactory<>(compoundReaderWriter())); context.registerWriterFactory("tweed5.compound", new StaticReaderWriterFactory<>(compoundReaderWriter())); diff --git a/tweed5-serde-extension/src/main/java/de/siphalor/tweed5/data/extension/impl/TweedEntryReaderWriterImpls.java b/tweed5-serde-extension/src/main/java/de/siphalor/tweed5/data/extension/impl/TweedEntryReaderWriterImpls.java index eeab26c..4dd2c9f 100644 --- a/tweed5-serde-extension/src/main/java/de/siphalor/tweed5/data/extension/impl/TweedEntryReaderWriterImpls.java +++ b/tweed5-serde-extension/src/main/java/de/siphalor/tweed5/data/extension/impl/TweedEntryReaderWriterImpls.java @@ -1,6 +1,6 @@ package de.siphalor.tweed5.data.extension.impl; -import de.siphalor.tweed5.core.api.entry.CoherentCollectionConfigEntry; +import de.siphalor.tweed5.core.api.entry.CollectionConfigEntry; import de.siphalor.tweed5.core.api.entry.CompoundConfigEntry; import de.siphalor.tweed5.core.api.entry.ConfigEntry; import de.siphalor.tweed5.data.extension.api.*; @@ -26,7 +26,7 @@ public class TweedEntryReaderWriterImpls { public static final TweedEntryReaderWriter> DOUBLE_READER_WRITER = new PrimitiveReaderWriter<>(TweedDataToken::readAsDouble, TweedDataVisitor::visitDouble); public static final TweedEntryReaderWriter> STRING_READER_WRITER = new PrimitiveReaderWriter<>(TweedDataToken::readAsString, TweedDataVisitor::visitString); - public static final TweedEntryReaderWriter, CoherentCollectionConfigEntry>> COHERENT_COLLECTION_READER_WRITER = new CoherentCollectionReaderWriter<>(); + public static final TweedEntryReaderWriter, CollectionConfigEntry>> COLLECTION_READER_WRITER = new CollectionReaderWriter<>(); public static final TweedEntryReaderWriter> COMPOUND_READER_WRITER = new CompoundReaderWriter<>(); public static final TweedEntryReaderWriter> NOOP_READER_WRITER = new NoopReaderWriter(); @@ -76,9 +76,9 @@ public class TweedEntryReaderWriterImpls { } } - public static class CoherentCollectionReaderWriter> implements TweedEntryReaderWriter> { + public static class CollectionReaderWriter> implements TweedEntryReaderWriter> { @Override - public C read(TweedDataReader reader, CoherentCollectionConfigEntry entry, TweedReadContext context) throws TweedEntryReadException, TweedDataReadException { + public C read(TweedDataReader reader, CollectionConfigEntry entry, TweedReadContext context) throws TweedEntryReadException, TweedDataReadException { assertIsToken(reader.readToken(), TweedDataToken::isListStart, "Expected list start"); TweedDataToken token = reader.peekToken(); if (token.isListEnd()) { @@ -107,7 +107,7 @@ public class TweedEntryReaderWriterImpls { } @Override - public void write(TweedDataVisitor writer, C value, CoherentCollectionConfigEntry entry, TweedWriteContext context) throws TweedEntryWriteException, TweedDataWriteException { + public void write(TweedDataVisitor writer, C value, CollectionConfigEntry entry, TweedWriteContext context) throws TweedEntryWriteException, TweedDataWriteException { requireNonNullWriteValue(value); if (value.isEmpty()) { diff --git a/tweed5-serde-extension/src/test/java/de/siphalor/tweed5/data/extension/impl/ReadWriteExtensionImplTest.java b/tweed5-serde-extension/src/test/java/de/siphalor/tweed5/data/extension/impl/ReadWriteExtensionImplTest.java index d1e04b0..3cefcbc 100644 --- a/tweed5-serde-extension/src/test/java/de/siphalor/tweed5/data/extension/impl/ReadWriteExtensionImplTest.java +++ b/tweed5-serde-extension/src/test/java/de/siphalor/tweed5/data/extension/impl/ReadWriteExtensionImplTest.java @@ -4,7 +4,7 @@ import de.siphalor.tweed5.core.api.container.ConfigContainer; import de.siphalor.tweed5.core.api.extension.EntryExtensionsData; import de.siphalor.tweed5.core.api.extension.RegisteredExtensionData; import de.siphalor.tweed5.core.impl.DefaultConfigContainer; -import de.siphalor.tweed5.core.impl.entry.CoherentCollectionConfigEntryImpl; +import de.siphalor.tweed5.core.impl.entry.CollectionConfigEntryImpl; import de.siphalor.tweed5.core.impl.entry.SimpleConfigEntryImpl; import de.siphalor.tweed5.core.impl.entry.StaticMapCompoundConfigEntryImpl; import de.siphalor.tweed5.data.extension.api.EntryReaderWriterDefinition; @@ -49,7 +49,7 @@ class ReadWriteExtensionImplTest { SimpleConfigEntryImpl intEntry = new SimpleConfigEntryImpl<>(Integer.class); rootEntry.addSubEntry("int", intEntry); - CoherentCollectionConfigEntryImpl> listEntry = new CoherentCollectionConfigEntryImpl<>((Class>) (Class) List.class, ArrayList::new); + CollectionConfigEntryImpl> listEntry = new CollectionConfigEntryImpl<>((Class>) (Class) List.class, ArrayList::new); rootEntry.addSubEntry("list", listEntry); SimpleConfigEntryImpl booleanEntry = new SimpleConfigEntryImpl<>(Boolean.class); @@ -60,7 +60,7 @@ class ReadWriteExtensionImplTest { RegisteredExtensionData readerWriterData = (RegisteredExtensionData) configContainer.entryDataExtensions().get(EntryReaderWriterDefinition.class); readerWriterData.set(rootEntry.extensionsData(), new TrivialEntryReaderWriterDefinition(TweedEntryReaderWriters.compoundReaderWriter())); readerWriterData.set(intEntry.extensionsData(), new TrivialEntryReaderWriterDefinition(TweedEntryReaderWriters.intReaderWriter())); - readerWriterData.set(listEntry.extensionsData(), new TrivialEntryReaderWriterDefinition(TweedEntryReaderWriters.coherentCollectionReaderWriter())); + readerWriterData.set(listEntry.extensionsData(), new TrivialEntryReaderWriterDefinition(TweedEntryReaderWriters.collectionReaderWriter())); readerWriterData.set(booleanEntry.extensionsData(), new TrivialEntryReaderWriterDefinition(TweedEntryReaderWriters.booleanReaderWriter())); configContainer.initialize(); @@ -115,4 +115,4 @@ class ReadWriteExtensionImplTest { return readerWriter; } } -} \ No newline at end of file +} diff --git a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/annotation/CoherentCollectionWeaving.java b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/annotation/CollectionWeaving.java similarity index 54% rename from tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/annotation/CoherentCollectionWeaving.java rename to tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/annotation/CollectionWeaving.java index 7685143..358589d 100644 --- a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/annotation/CoherentCollectionWeaving.java +++ b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/annotation/CollectionWeaving.java @@ -1,6 +1,6 @@ package de.siphalor.tweed5.weaver.pojo.api.annotation; -import de.siphalor.tweed5.weaver.pojo.api.entry.WeavableCoherentCollectionConfigEntry; +import de.siphalor.tweed5.weaver.pojo.api.entry.WeavableCollectionConfigEntry; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -9,6 +9,6 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.TYPE_USE}) -public @interface CoherentCollectionWeaving { - Class entryClass() default WeavableCoherentCollectionConfigEntry.class; +public @interface CollectionWeaving { + Class entryClass() default WeavableCollectionConfigEntry.class; } diff --git a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/entry/WeavableCoherentCollectionConfigEntry.java b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/entry/WeavableCollectionConfigEntry.java similarity index 81% rename from tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/entry/WeavableCoherentCollectionConfigEntry.java rename to tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/entry/WeavableCollectionConfigEntry.java index c6831b6..ec8e496 100644 --- a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/entry/WeavableCoherentCollectionConfigEntry.java +++ b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/entry/WeavableCollectionConfigEntry.java @@ -1,6 +1,6 @@ package de.siphalor.tweed5.weaver.pojo.api.entry; -import de.siphalor.tweed5.core.api.entry.CoherentCollectionConfigEntry; +import de.siphalor.tweed5.core.api.entry.CollectionConfigEntry; import de.siphalor.tweed5.core.api.entry.ConfigEntry; import de.siphalor.tweed5.weaver.pojo.impl.weaving.PojoWeavingException; @@ -15,9 +15,9 @@ import java.util.function.IntFunction; * A constructor taking the value {@link Class} * and a {@link java.util.function.IntFunction} that allows to instantiate the value class with a single capacity argument. */ -public interface WeavableCoherentCollectionConfigEntry> - extends CoherentCollectionConfigEntry { - static , C extends WeavableCoherentCollectionConfigEntry> C instantiate( +public interface WeavableCollectionConfigEntry> + extends CollectionConfigEntry { + static , C extends WeavableCollectionConfigEntry> C instantiate( Class weavableClass, Class valueClass, IntFunction constructor ) throws PojoWeavingException { try { diff --git a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/weaving/CoherentCollectionPojoWeaver.java b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/weaving/CollectionPojoWeaver.java similarity index 61% rename from tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/weaving/CoherentCollectionPojoWeaver.java rename to tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/weaving/CollectionPojoWeaver.java index e3757e9..6ece4ff 100644 --- a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/weaving/CoherentCollectionPojoWeaver.java +++ b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/api/weaving/CollectionPojoWeaver.java @@ -3,11 +3,12 @@ package de.siphalor.tweed5.weaver.pojo.api.weaving; import de.siphalor.tweed5.core.api.entry.ConfigEntry; import de.siphalor.tweed5.core.api.extension.RegisteredExtensionData; import de.siphalor.tweed5.typeutils.api.type.ActualType; -import de.siphalor.tweed5.weaver.pojo.api.annotation.CoherentCollectionWeaving; -import de.siphalor.tweed5.weaver.pojo.api.entry.WeavableCoherentCollectionConfigEntry; +import de.siphalor.tweed5.weaver.pojo.api.annotation.CollectionWeaving; +import de.siphalor.tweed5.weaver.pojo.api.entry.WeavableCollectionConfigEntry; +import de.siphalor.tweed5.weaver.pojo.impl.entry.CollectionConfigEntryImpl; import de.siphalor.tweed5.weaver.pojo.impl.weaving.PojoWeavingException; -import de.siphalor.tweed5.weaver.pojo.impl.weaving.coherentcollection.CoherentCollectionWeavingConfig; -import de.siphalor.tweed5.weaver.pojo.impl.weaving.coherentcollection.CoherentCollectionWeavingConfigImpl; +import de.siphalor.tweed5.weaver.pojo.impl.weaving.collection.CollectionWeavingConfig; +import de.siphalor.tweed5.weaver.pojo.impl.weaving.collection.CollectionWeavingConfigImpl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -18,16 +19,16 @@ import java.lang.reflect.AnnotatedElement; import java.util.*; import java.util.function.IntFunction; -public class CoherentCollectionPojoWeaver implements TweedPojoWeaver { - private static final CoherentCollectionWeavingConfig DEFAULT_WEAVING_CONFIG = CoherentCollectionWeavingConfigImpl.builder() - .coherentCollectionEntryClass(de.siphalor.tweed5.weaver.pojo.impl.entry.CoherentCollectionConfigEntryImpl.class) +public class CollectionPojoWeaver implements TweedPojoWeaver { + private static final CollectionWeavingConfig DEFAULT_WEAVING_CONFIG = CollectionWeavingConfigImpl.builder() + .collectionEntryClass(CollectionConfigEntryImpl.class) .build(); - private RegisteredExtensionData weavingConfigAccess; + private RegisteredExtensionData weavingConfigAccess; @Override public void setup(SetupContext context) { - this.weavingConfigAccess = context.registerWeavingContextExtensionData(CoherentCollectionWeavingConfig.class); + this.weavingConfigAccess = context.registerWeavingContextExtensionData(CollectionWeavingConfig.class); } @Override @@ -37,15 +38,15 @@ public class CoherentCollectionPojoWeaver implements TweedPojoWeaver { return null; } try { - CoherentCollectionWeavingConfig weavingConfig = getOrCreateWeavingConfig(context); + CollectionWeavingConfig weavingConfig = getOrCreateWeavingConfig(context); WeavingContext.ExtensionsData newExtensionsData = context.extensionsData().copy(); weavingConfigAccess.set(newExtensionsData, weavingConfig); IntFunction> constructor = getCollectionConstructor(valueType); //noinspection unchecked,rawtypes - WeavableCoherentCollectionConfigEntry configEntry = WeavableCoherentCollectionConfigEntry.instantiate( - (Class) weavingConfig.coherentCollectionEntryClass(), + WeavableCollectionConfigEntry configEntry = WeavableCollectionConfigEntry.instantiate( + (Class) weavingConfig.collectionEntryClass(), (Class) valueType.declaredType(), constructor ); @@ -65,31 +66,31 @@ public class CoherentCollectionPojoWeaver implements TweedPojoWeaver { } } - private CoherentCollectionWeavingConfig getOrCreateWeavingConfig(WeavingContext context) { - CoherentCollectionWeavingConfig parent; - if (context.extensionsData().isPatchworkPartSet(CoherentCollectionWeavingConfig.class)) { - parent = (CoherentCollectionWeavingConfig) context.extensionsData(); + private CollectionWeavingConfig getOrCreateWeavingConfig(WeavingContext context) { + CollectionWeavingConfig parent; + if (context.extensionsData().isPatchworkPartSet(CollectionWeavingConfig.class)) { + parent = (CollectionWeavingConfig) context.extensionsData(); } else { parent = DEFAULT_WEAVING_CONFIG; } - CoherentCollectionWeavingConfig local = createWeavingConfigFromAnnotations(context.annotations()); + CollectionWeavingConfig local = createWeavingConfigFromAnnotations(context.annotations()); if (local == null) { return parent; } - return CoherentCollectionWeavingConfigImpl.withOverrides(parent, local); + return CollectionWeavingConfigImpl.withOverrides(parent, local); } - private CoherentCollectionWeavingConfig createWeavingConfigFromAnnotations(@NotNull AnnotatedElement annotations) { - CoherentCollectionWeaving annotation = annotations.getAnnotation(CoherentCollectionWeaving.class); + private CollectionWeavingConfig createWeavingConfigFromAnnotations(@NotNull AnnotatedElement annotations) { + CollectionWeaving annotation = annotations.getAnnotation(CollectionWeaving.class); if (annotation == null) { return null; } - CoherentCollectionWeavingConfigImpl.CoherentCollectionWeavingConfigImplBuilder builder = CoherentCollectionWeavingConfigImpl.builder(); + CollectionWeavingConfigImpl.CollectionWeavingConfigImplBuilder builder = CollectionWeavingConfigImpl.builder(); if (annotation.entryClass() != null) { - builder.coherentCollectionEntryClass(annotation.entryClass()); + builder.collectionEntryClass(annotation.entryClass()); } return builder.build(); diff --git a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/entry/CoherentCollectionConfigEntryImpl.java b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/entry/CollectionConfigEntryImpl.java similarity index 82% rename from tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/entry/CoherentCollectionConfigEntryImpl.java rename to tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/entry/CollectionConfigEntryImpl.java index f953fef..532b177 100644 --- a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/entry/CoherentCollectionConfigEntryImpl.java +++ b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/entry/CollectionConfigEntryImpl.java @@ -4,7 +4,7 @@ import de.siphalor.tweed5.core.api.entry.BaseConfigEntry; import de.siphalor.tweed5.core.api.entry.ConfigEntry; import de.siphalor.tweed5.core.api.entry.ConfigEntryValueVisitor; import de.siphalor.tweed5.core.api.entry.ConfigEntryVisitor; -import de.siphalor.tweed5.weaver.pojo.api.entry.WeavableCoherentCollectionConfigEntry; +import de.siphalor.tweed5.weaver.pojo.api.entry.WeavableCollectionConfigEntry; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; @@ -16,11 +16,11 @@ import java.util.function.IntFunction; @Getter @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class CoherentCollectionConfigEntryImpl> extends BaseConfigEntry implements WeavableCoherentCollectionConfigEntry { +public class CollectionConfigEntryImpl> extends BaseConfigEntry implements WeavableCollectionConfigEntry { private final IntFunction constructor; private ConfigEntry elementEntry; - public CoherentCollectionConfigEntryImpl(@NotNull Class valueClass, IntFunction constructor) { + public CollectionConfigEntryImpl(@NotNull Class valueClass, IntFunction constructor) { super(valueClass); this.constructor = constructor; } diff --git a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/coherentcollection/CoherentCollectionWeavingConfig.java b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/coherentcollection/CoherentCollectionWeavingConfig.java deleted file mode 100644 index c421ab8..0000000 --- a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/coherentcollection/CoherentCollectionWeavingConfig.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.siphalor.tweed5.weaver.pojo.impl.weaving.coherentcollection; - -import de.siphalor.tweed5.weaver.pojo.api.entry.WeavableCoherentCollectionConfigEntry; -import org.jetbrains.annotations.Nullable; - -public interface CoherentCollectionWeavingConfig { - @SuppressWarnings("rawtypes") - @Nullable - Class coherentCollectionEntryClass(); -} diff --git a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/coherentcollection/CoherentCollectionWeavingConfigImpl.java b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/coherentcollection/CoherentCollectionWeavingConfigImpl.java deleted file mode 100644 index 9ac2c40..0000000 --- a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/coherentcollection/CoherentCollectionWeavingConfigImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package de.siphalor.tweed5.weaver.pojo.impl.weaving.coherentcollection; - -import de.siphalor.tweed5.weaver.pojo.api.entry.WeavableCoherentCollectionConfigEntry; -import lombok.Builder; -import lombok.Value; -import org.jetbrains.annotations.Nullable; - -@Builder -@Value -public class CoherentCollectionWeavingConfigImpl implements CoherentCollectionWeavingConfig { - - @SuppressWarnings("rawtypes") - @Nullable - Class coherentCollectionEntryClass; - - public static CoherentCollectionWeavingConfigImpl withOverrides(CoherentCollectionWeavingConfig self, CoherentCollectionWeavingConfig overrides) { - return CoherentCollectionWeavingConfigImpl.builder() - .coherentCollectionEntryClass(overrides.coherentCollectionEntryClass() != null ? overrides.coherentCollectionEntryClass() : self.coherentCollectionEntryClass()) - .build(); - } -} diff --git a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/collection/CollectionWeavingConfig.java b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/collection/CollectionWeavingConfig.java new file mode 100644 index 0000000..2fa67c9 --- /dev/null +++ b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/collection/CollectionWeavingConfig.java @@ -0,0 +1,10 @@ +package de.siphalor.tweed5.weaver.pojo.impl.weaving.collection; + +import de.siphalor.tweed5.weaver.pojo.api.entry.WeavableCollectionConfigEntry; +import org.jetbrains.annotations.Nullable; + +public interface CollectionWeavingConfig { + @SuppressWarnings("rawtypes") + @Nullable + Class collectionEntryClass(); +} diff --git a/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/collection/CollectionWeavingConfigImpl.java b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/collection/CollectionWeavingConfigImpl.java new file mode 100644 index 0000000..78d05b3 --- /dev/null +++ b/tweed5-weaver-pojo/src/main/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/collection/CollectionWeavingConfigImpl.java @@ -0,0 +1,21 @@ +package de.siphalor.tweed5.weaver.pojo.impl.weaving.collection; + +import de.siphalor.tweed5.weaver.pojo.api.entry.WeavableCollectionConfigEntry; +import lombok.Builder; +import lombok.Value; +import org.jetbrains.annotations.Nullable; + +@Builder +@Value +public class CollectionWeavingConfigImpl implements CollectionWeavingConfig { + + @SuppressWarnings("rawtypes") + @Nullable + Class collectionEntryClass; + + public static CollectionWeavingConfigImpl withOverrides(CollectionWeavingConfig self, CollectionWeavingConfig overrides) { + return CollectionWeavingConfigImpl.builder() + .collectionEntryClass(overrides.collectionEntryClass() != null ? overrides.collectionEntryClass() : self.collectionEntryClass()) + .build(); + } +} diff --git a/tweed5-weaver-pojo/src/test/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/TweedPojoWeaverBootstrapperTest.java b/tweed5-weaver-pojo/src/test/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/TweedPojoWeaverBootstrapperTest.java index abcf363..82b43c9 100644 --- a/tweed5-weaver-pojo/src/test/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/TweedPojoWeaverBootstrapperTest.java +++ b/tweed5-weaver-pojo/src/test/java/de/siphalor/tweed5/weaver/pojo/impl/weaving/TweedPojoWeaverBootstrapperTest.java @@ -5,7 +5,7 @@ import de.siphalor.tweed5.core.api.container.ConfigContainer; import de.siphalor.tweed5.core.api.extension.TweedExtension; import de.siphalor.tweed5.weaver.pojo.api.annotation.CompoundWeaving; import de.siphalor.tweed5.weaver.pojo.api.annotation.PojoWeaving; -import de.siphalor.tweed5.weaver.pojo.api.weaving.CoherentCollectionPojoWeaver; +import de.siphalor.tweed5.weaver.pojo.api.weaving.CollectionPojoWeaver; import de.siphalor.tweed5.weaver.pojo.api.weaving.CompoundPojoWeaver; import de.siphalor.tweed5.weaver.pojo.api.weaving.TrivialPojoWeaver; import lombok.Data; @@ -90,7 +90,7 @@ class TweedPojoWeaverBootstrapperTest { boolean somethingElse; } - @PojoWeaving(weavers = {CompoundPojoWeaver.class, CoherentCollectionPojoWeaver.class, TrivialPojoWeaver.class}) + @PojoWeaving(weavers = {CompoundPojoWeaver.class, CollectionPojoWeaver.class, TrivialPojoWeaver.class}) @CompoundWeaving(namingFormat = "camel_case") @Data public static class CompoundWithList { diff --git a/tweed5-weaver-pojo/src/test/java/de/siphalor/tweed5/weaver/pojo/test/ConfigEntryAssertions.java b/tweed5-weaver-pojo/src/test/java/de/siphalor/tweed5/weaver/pojo/test/ConfigEntryAssertions.java index 136bc91..2a37164 100644 --- a/tweed5-weaver-pojo/src/test/java/de/siphalor/tweed5/weaver/pojo/test/ConfigEntryAssertions.java +++ b/tweed5-weaver-pojo/src/test/java/de/siphalor/tweed5/weaver/pojo/test/ConfigEntryAssertions.java @@ -1,12 +1,10 @@ package de.siphalor.tweed5.weaver.pojo.test; -import de.siphalor.tweed5.core.api.entry.CoherentCollectionConfigEntry; +import de.siphalor.tweed5.core.api.entry.CollectionConfigEntry; import de.siphalor.tweed5.core.api.entry.CompoundConfigEntry; import de.siphalor.tweed5.core.api.entry.ConfigEntry; import de.siphalor.tweed5.core.api.entry.SimpleConfigEntry; -import de.siphalor.tweed5.weaver.pojo.api.weaving.CoherentCollectionPojoWeaver; -import java.util.Collection; import java.util.function.Consumer; import static org.assertj.core.api.Assertions.assertThat; @@ -39,11 +37,11 @@ public class ConfigEntryAssertions { public static Consumer isCollectionEntryForClass( Class collectionClass, - Consumer> condition + Consumer> condition ) { return object -> assertThat(object) .as("Should be a collection config entry for class " + collectionClass.getName()) - .asInstanceOf(type(CoherentCollectionConfigEntry.class)) + .asInstanceOf(type(CollectionConfigEntry.class)) .as("Collection entry for class " + collectionClass.getSimpleName()) .satisfies( listEntry -> assertThat(listEntry.valueClass())