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