[core, serde-extension, weaver-pojo] Remove the coherent from collection stuff
This commit is contained in:
@@ -2,7 +2,7 @@ package de.siphalor.tweed5.core.api.entry;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface CoherentCollectionConfigEntry<E, T extends Collection<E>> extends ConfigEntry<T> {
|
||||
public interface CollectionConfigEntry<E, T extends Collection<E>> extends ConfigEntry<T> {
|
||||
ConfigEntry<E> elementEntry();
|
||||
|
||||
T instantiateCollection(int size);
|
||||
@@ -6,11 +6,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Collection;
|
||||
import java.util.function.IntFunction;
|
||||
|
||||
public class CoherentCollectionConfigEntryImpl<E, T extends Collection<E>> extends BaseConfigEntry<T> implements CoherentCollectionConfigEntry<E, T> {
|
||||
public class CollectionConfigEntryImpl<E, T extends Collection<E>> extends BaseConfigEntry<T> implements CollectionConfigEntry<E, T> {
|
||||
private final IntFunction<T> collectionConstructor;
|
||||
private ConfigEntry<E> elementEntry;
|
||||
|
||||
public CoherentCollectionConfigEntryImpl(Class<T> valueClass, IntFunction<T> collectionConstructor) {
|
||||
public CollectionConfigEntryImpl(Class<T> valueClass, IntFunction<T> collectionConstructor) {
|
||||
super(valueClass);
|
||||
this.collectionConstructor = collectionConstructor;
|
||||
}
|
||||
@@ -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 <T, C extends Collection<T>> TweedEntryReaderWriter<C, CoherentCollectionConfigEntry<T, C>> coherentCollectionReaderWriter() {
|
||||
public static <T, C extends Collection<T>> TweedEntryReaderWriter<C, CollectionConfigEntry<T, C>> collectionReaderWriter() {
|
||||
//noinspection unchecked
|
||||
return (TweedEntryReaderWriter<C, CoherentCollectionConfigEntry<T,C>>)(TweedEntryReaderWriter<?, ?>) TweedEntryReaderWriterImpls.COHERENT_COLLECTION_READER_WRITER;
|
||||
return (TweedEntryReaderWriter<C, CollectionConfigEntry<T,C>>)(TweedEntryReaderWriter<?, ?>) TweedEntryReaderWriterImpls.COLLECTION_READER_WRITER;
|
||||
}
|
||||
|
||||
public static <T> TweedEntryReaderWriter<T, CompoundConfigEntry<T>> compoundReaderWriter() {
|
||||
|
||||
@@ -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()));
|
||||
|
||||
|
||||
@@ -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, ConfigEntry<Double>> DOUBLE_READER_WRITER = new PrimitiveReaderWriter<>(TweedDataToken::readAsDouble, TweedDataVisitor::visitDouble);
|
||||
public static final TweedEntryReaderWriter<String, ConfigEntry<String>> STRING_READER_WRITER = new PrimitiveReaderWriter<>(TweedDataToken::readAsString, TweedDataVisitor::visitString);
|
||||
|
||||
public static final TweedEntryReaderWriter<Collection<Object>, CoherentCollectionConfigEntry<Object, Collection<Object>>> COHERENT_COLLECTION_READER_WRITER = new CoherentCollectionReaderWriter<>();
|
||||
public static final TweedEntryReaderWriter<Collection<Object>, CollectionConfigEntry<Object, Collection<Object>>> COLLECTION_READER_WRITER = new CollectionReaderWriter<>();
|
||||
public static final TweedEntryReaderWriter<Object, CompoundConfigEntry<Object>> COMPOUND_READER_WRITER = new CompoundReaderWriter<>();
|
||||
|
||||
public static final TweedEntryReaderWriter<Object, ConfigEntry<Object>> NOOP_READER_WRITER = new NoopReaderWriter();
|
||||
@@ -76,9 +76,9 @@ public class TweedEntryReaderWriterImpls {
|
||||
}
|
||||
}
|
||||
|
||||
public static class CoherentCollectionReaderWriter<T, C extends Collection<T>> implements TweedEntryReaderWriter<C, CoherentCollectionConfigEntry<T, C>> {
|
||||
public static class CollectionReaderWriter<T, C extends Collection<T>> implements TweedEntryReaderWriter<C, CollectionConfigEntry<T, C>> {
|
||||
@Override
|
||||
public C read(TweedDataReader reader, CoherentCollectionConfigEntry<T, C> entry, TweedReadContext context) throws TweedEntryReadException, TweedDataReadException {
|
||||
public C read(TweedDataReader reader, CollectionConfigEntry<T, C> 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<T, C> entry, TweedWriteContext context) throws TweedEntryWriteException, TweedDataWriteException {
|
||||
public void write(TweedDataVisitor writer, C value, CollectionConfigEntry<T, C> entry, TweedWriteContext context) throws TweedEntryWriteException, TweedDataWriteException {
|
||||
requireNonNullWriteValue(value);
|
||||
|
||||
if (value.isEmpty()) {
|
||||
|
||||
@@ -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<Integer> intEntry = new SimpleConfigEntryImpl<>(Integer.class);
|
||||
rootEntry.addSubEntry("int", intEntry);
|
||||
|
||||
CoherentCollectionConfigEntryImpl<Boolean, List<Boolean>> listEntry = new CoherentCollectionConfigEntryImpl<>((Class<List<Boolean>>) (Class<?>) List.class, ArrayList::new);
|
||||
CollectionConfigEntryImpl<Boolean, List<Boolean>> listEntry = new CollectionConfigEntryImpl<>((Class<List<Boolean>>) (Class<?>) List.class, ArrayList::new);
|
||||
rootEntry.addSubEntry("list", listEntry);
|
||||
|
||||
SimpleConfigEntryImpl<Boolean> booleanEntry = new SimpleConfigEntryImpl<>(Boolean.class);
|
||||
@@ -60,7 +60,7 @@ class ReadWriteExtensionImplTest {
|
||||
RegisteredExtensionData<EntryExtensionsData, EntryReaderWriterDefinition> readerWriterData = (RegisteredExtensionData<EntryExtensionsData, EntryReaderWriterDefinition>) 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();
|
||||
|
||||
@@ -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<? extends WeavableCoherentCollectionConfigEntry> entryClass() default WeavableCoherentCollectionConfigEntry.class;
|
||||
public @interface CollectionWeaving {
|
||||
Class<? extends WeavableCollectionConfigEntry> entryClass() default WeavableCollectionConfigEntry.class;
|
||||
}
|
||||
@@ -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<E, T extends Collection<E>>
|
||||
extends CoherentCollectionConfigEntry<E, T> {
|
||||
static <E, T extends Collection<E>, C extends WeavableCoherentCollectionConfigEntry<E, T>> C instantiate(
|
||||
public interface WeavableCollectionConfigEntry<E, T extends Collection<E>>
|
||||
extends CollectionConfigEntry<E, T> {
|
||||
static <E, T extends Collection<E>, C extends WeavableCollectionConfigEntry<E, T>> C instantiate(
|
||||
Class<C> weavableClass, Class<T> valueClass, IntFunction<T> constructor
|
||||
) throws PojoWeavingException {
|
||||
try {
|
||||
@@ -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<WeavingContext.ExtensionsData, CoherentCollectionWeavingConfig> weavingConfigAccess;
|
||||
private RegisteredExtensionData<WeavingContext.ExtensionsData, CollectionWeavingConfig> 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<Collection<Object>> 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();
|
||||
@@ -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<E, T extends Collection<E>> extends BaseConfigEntry<T> implements WeavableCoherentCollectionConfigEntry<E, T> {
|
||||
public class CollectionConfigEntryImpl<E, T extends Collection<E>> extends BaseConfigEntry<T> implements WeavableCollectionConfigEntry<E, T> {
|
||||
private final IntFunction<T> constructor;
|
||||
private ConfigEntry<E> elementEntry;
|
||||
|
||||
public CoherentCollectionConfigEntryImpl(@NotNull Class<T> valueClass, IntFunction<T> constructor) {
|
||||
public CollectionConfigEntryImpl(@NotNull Class<T> valueClass, IntFunction<T> constructor) {
|
||||
super(valueClass);
|
||||
this.constructor = constructor;
|
||||
}
|
||||
@@ -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<? extends WeavableCoherentCollectionConfigEntry> coherentCollectionEntryClass();
|
||||
}
|
||||
@@ -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<? extends WeavableCoherentCollectionConfigEntry> coherentCollectionEntryClass;
|
||||
|
||||
public static CoherentCollectionWeavingConfigImpl withOverrides(CoherentCollectionWeavingConfig self, CoherentCollectionWeavingConfig overrides) {
|
||||
return CoherentCollectionWeavingConfigImpl.builder()
|
||||
.coherentCollectionEntryClass(overrides.coherentCollectionEntryClass() != null ? overrides.coherentCollectionEntryClass() : self.coherentCollectionEntryClass())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -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<? extends WeavableCollectionConfigEntry> collectionEntryClass();
|
||||
}
|
||||
@@ -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<? extends WeavableCollectionConfigEntry> collectionEntryClass;
|
||||
|
||||
public static CollectionWeavingConfigImpl withOverrides(CollectionWeavingConfig self, CollectionWeavingConfig overrides) {
|
||||
return CollectionWeavingConfigImpl.builder()
|
||||
.collectionEntryClass(overrides.collectionEntryClass() != null ? overrides.collectionEntryClass() : self.collectionEntryClass())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<Object> isCollectionEntryForClass(
|
||||
Class<?> collectionClass,
|
||||
Consumer<CoherentCollectionConfigEntry<?, ?>> condition
|
||||
Consumer<CollectionConfigEntry<?, ?>> 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())
|
||||
|
||||
Reference in New Issue
Block a user