[*-extension] Move extension ids to interface level
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user