[*-extension] Move extension ids to interface level
This commit is contained in:
@@ -11,6 +11,11 @@ import java.util.function.Consumer;
|
||||
|
||||
public interface AttributesExtension extends TweedExtension {
|
||||
Class<? extends AttributesExtension> DEFAULT = AttributesExtensionImpl.class;
|
||||
String EXTENSION_ID = "attributes";
|
||||
|
||||
default String getId() {
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
static <C extends ConfigEntry<?>> Consumer<C> attribute(String key, String value) {
|
||||
return entry -> entry.container().extension(AttributesExtension.class)
|
||||
|
||||
@@ -6,6 +6,11 @@ import de.siphalor.tweed5.patchwork.api.Patchwork;
|
||||
|
||||
public interface AttributesReadWriteFilterExtension extends TweedExtension {
|
||||
Class<? extends AttributesReadWriteFilterExtension> DEFAULT = AttributesReadWriteFilterExtensionImpl.class;
|
||||
String EXTENSION_ID = "attributes-read-write-filter";
|
||||
|
||||
default String getId() {
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
void markAttributeForFiltering(String key);
|
||||
|
||||
|
||||
@@ -26,11 +26,6 @@ public class AttributesExtensionImpl implements AttributesExtension {
|
||||
this.dataAccess = setupContext.registerEntryExtensionData(CustomEntryData.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "attributes";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(ConfigEntry<?> entry, String key, List<String> values) {
|
||||
requireEditable();
|
||||
|
||||
@@ -15,7 +15,6 @@ import de.siphalor.tweed5.data.extension.api.TweedEntryWriter;
|
||||
import de.siphalor.tweed5.data.extension.api.TweedReadContext;
|
||||
import de.siphalor.tweed5.data.extension.api.extension.ReadWriteExtensionSetupContext;
|
||||
import de.siphalor.tweed5.data.extension.api.extension.ReadWriteRelatedExtension;
|
||||
import de.siphalor.tweed5.data.extension.api.readwrite.TweedEntryReaderWriters;
|
||||
import de.siphalor.tweed5.data.extension.impl.TweedEntryReaderWriterImpls;
|
||||
import de.siphalor.tweed5.dataapi.api.DelegatingTweedDataVisitor;
|
||||
import de.siphalor.tweed5.dataapi.api.TweedDataReader;
|
||||
@@ -25,7 +24,10 @@ import de.siphalor.tweed5.dataapi.api.decoration.TweedDataDecoration;
|
||||
import de.siphalor.tweed5.patchwork.api.Patchwork;
|
||||
import de.siphalor.tweed5.patchwork.api.PatchworkPartAccess;
|
||||
import de.siphalor.tweed5.utils.api.UniqueSymbol;
|
||||
import lombok.*;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.var;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@@ -33,7 +35,6 @@ import java.util.*;
|
||||
|
||||
public class AttributesReadWriteFilterExtensionImpl
|
||||
implements AttributesReadWriteFilterExtension, AttributesRelatedExtension, ReadWriteRelatedExtension {
|
||||
private static final String ID = "attributes-serde-filter";
|
||||
private static final Set<String> MIDDLEWARES_MUST_COME_BEFORE = new HashSet<>(Arrays.asList(
|
||||
Middleware.DEFAULT_START,
|
||||
"validation"
|
||||
@@ -53,11 +54,6 @@ public class AttributesReadWriteFilterExtensionImpl
|
||||
entryDataAccess = setupContext.registerEntryExtensionData(EntryCustomData.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupReadWriteExtension(ReadWriteExtensionSetupContext context) {
|
||||
readWriteContextDataAccess = context.registerReadWriteContextExtensionData(ReadWriteContextCustomData.class);
|
||||
@@ -178,7 +174,7 @@ public class AttributesReadWriteFilterExtensionImpl
|
||||
private class ReaderMiddleware implements Middleware<TweedEntryReader<?, ?>> {
|
||||
@Override
|
||||
public String id() {
|
||||
return ID;
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -220,7 +216,7 @@ public class AttributesReadWriteFilterExtensionImpl
|
||||
private class WriterMiddleware implements Middleware<TweedEntryWriter<?, ?>> {
|
||||
@Override
|
||||
public String id() {
|
||||
return ID;
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.function.Consumer;
|
||||
|
||||
public interface CommentExtension extends TweedExtension {
|
||||
Class<? extends CommentExtension> DEFAULT = CommentExtensionImpl.class;
|
||||
String EXTENSION_ID = "comment";
|
||||
|
||||
static <C extends ConfigEntry<?>> Consumer<C> baseComment(String baseComment) {
|
||||
return entry -> {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class CommentExtensionImpl implements ReadWriteRelatedExtension, CommentE
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "comment";
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,12 @@ import de.siphalor.tweed5.defaultextensions.pather.impl.PatherExtensionImpl;
|
||||
|
||||
public interface PatherExtension extends TweedExtension {
|
||||
Class<? extends PatherExtension> DEFAULT = PatherExtensionImpl.class;
|
||||
String EXTENSION_ID = "pather";
|
||||
|
||||
@Override
|
||||
default String getId() {
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
String getPath(TweedReadContext context);
|
||||
String getPath(TweedWriteContext context);
|
||||
|
||||
@@ -2,7 +2,6 @@ package de.siphalor.tweed5.defaultextensions.pather.impl;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import de.siphalor.tweed5.core.api.entry.ConfigEntry;
|
||||
import de.siphalor.tweed5.core.api.extension.TweedExtension;
|
||||
import de.siphalor.tweed5.core.api.middleware.Middleware;
|
||||
import de.siphalor.tweed5.data.extension.api.*;
|
||||
import de.siphalor.tweed5.data.extension.api.extension.ReadWriteExtensionSetupContext;
|
||||
@@ -20,16 +19,9 @@ import org.jspecify.annotations.NonNull;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@AutoService(PatherExtension.class)
|
||||
public class PatherExtensionImpl implements PatherExtension, TweedExtension, ReadWriteRelatedExtension {
|
||||
private static final String PATHER_ID = "pather";
|
||||
|
||||
public class PatherExtensionImpl implements PatherExtension, ReadWriteRelatedExtension {
|
||||
private @Nullable PatchworkPartAccess<PathTracking> rwContextPathTrackingAccess;
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return PATHER_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupReadWriteExtension(ReadWriteExtensionSetupContext context) {
|
||||
rwContextPathTrackingAccess = context.registerReadWriteContextExtensionData(PathTracking.class);
|
||||
@@ -63,7 +55,7 @@ public class PatherExtensionImpl implements PatherExtension, TweedExtension, Rea
|
||||
return new Middleware<TweedEntryReader<?, ?>>() {
|
||||
@Override
|
||||
public String id() {
|
||||
return PATHER_ID;
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,7 +97,7 @@ public class PatherExtensionImpl implements PatherExtension, TweedExtension, Rea
|
||||
return new Middleware<TweedEntryWriter<?, ?>>() {
|
||||
@Override
|
||||
public String id() {
|
||||
return PATHER_ID;
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,12 @@ import java.util.function.Function;
|
||||
|
||||
public interface ValidationExtension extends TweedExtension {
|
||||
Class<? extends ValidationExtension> DEFAULT = ValidationExtensionImpl.class;
|
||||
String EXTENSION_ID = "validation";
|
||||
|
||||
@Override
|
||||
default String getId() {
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
static <C extends ConfigEntry<T>, T> Consumer<C> validators(ConfigEntryValidator... validators) {
|
||||
return entry -> {
|
||||
|
||||
@@ -79,11 +79,6 @@ public class ValidationExtensionImpl implements ReadWriteRelatedExtension, Valid
|
||||
context.registerExtension(PatherExtension.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "validation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extensionsFinalized() {
|
||||
for (TweedExtension extension : configContainer.extensions()) {
|
||||
@@ -104,7 +99,7 @@ public class ValidationExtensionImpl implements ReadWriteRelatedExtension, Valid
|
||||
return new Middleware<CommentProducer>() {
|
||||
@Override
|
||||
public String id() {
|
||||
return "validation";
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,12 +200,12 @@ public class ValidationExtensionImpl implements ReadWriteRelatedExtension, Valid
|
||||
private class EntryValidationReaderMiddleware implements Middleware<TweedEntryReader<?, ?>> {
|
||||
@Override
|
||||
public String id() {
|
||||
return "validation";
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> mustComeAfter() {
|
||||
return Collections.singleton("pather");
|
||||
return Collections.singleton(PatherExtension.EXTENSION_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,12 @@ import java.util.function.Consumer;
|
||||
|
||||
public interface ValidationFallbackExtension extends TweedExtension {
|
||||
Class<? extends ValidationFallbackExtension> DEFAULT = ValidationFallbackExtensionImpl.class;
|
||||
String EXTENSION_ID = "validation-fallback";
|
||||
|
||||
@Override
|
||||
default String getId() {
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
static <C extends ConfigEntry<T>, T> Consumer<C> validationFallbackValue(T value) {
|
||||
return entry -> {
|
||||
|
||||
@@ -28,11 +28,6 @@ public class ValidationFallbackExtensionImpl implements ValidationFallbackExtens
|
||||
customEntryDataAccess = context.registerEntryExtensionData(CustomEntryData.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "validation-fallback";
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void setFallbackValue(ConfigEntry<T> entry, T value) {
|
||||
getOrCreateCustomEntryData(entry).fallbackValue(value);
|
||||
@@ -60,7 +55,7 @@ public class ValidationFallbackExtensionImpl implements ValidationFallbackExtens
|
||||
private class ValidationFallbackMiddleware implements Middleware<ConfigEntryValidator> {
|
||||
@Override
|
||||
public String id() {
|
||||
return "validation-fallback";
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,6 +14,12 @@ import java.util.function.Function;
|
||||
|
||||
public interface ReadWriteExtension extends TweedExtension {
|
||||
Class<? extends ReadWriteExtension> DEFAULT = ReadWriteExtensionImpl.class;
|
||||
String EXTENSION_ID = "read-write";
|
||||
|
||||
@Override
|
||||
default String getId() {
|
||||
return EXTENSION_ID;
|
||||
}
|
||||
|
||||
static <T> Consumer<ConfigEntry<T>> entryReaderWriter(
|
||||
TweedEntryReaderWriter<T, ? extends ConfigEntry<T>> entryReaderWriter
|
||||
|
||||
@@ -38,11 +38,6 @@ public class ReadWriteExtensionImpl implements ReadWriteExtension {
|
||||
this.customEntryDataAccess = context.registerEntryExtensionData(CustomEntryData.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "read-write";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extensionsFinalized() {
|
||||
Collection<TweedExtension> extensions = configContainer.extensions();
|
||||
|
||||
Reference in New Issue
Block a user