From adee06ad3f5e7fd780837b23cfcc566a98dfad83 Mon Sep 17 00:00:00 2001 From: altrisi Date: Mon, 24 May 2021 14:51:14 +0200 Subject: [PATCH] Mention custom converters in Param javadoc, make a few things final and remove commented out LazyValue provider --- .../java/carpet/script/annotation/Param.java | 36 +++---------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/src/main/java/carpet/script/annotation/Param.java b/src/main/java/carpet/script/annotation/Param.java index 9d28ea1f..343189e7 100644 --- a/src/main/java/carpet/script/annotation/Param.java +++ b/src/main/java/carpet/script/annotation/Param.java @@ -133,42 +133,14 @@ public interface Param /** *

Class that holds the actual converters and converter getting logic for those annotated types and things.

* - *

It also holds the registry for strict {@link ValueConverter}s.

+ *

It also holds the registry for strict and custom {@link ValueConverter}s.

* * @see #registerStrictConverter(Class, boolean, ValueConverter) + * @see #registerCustomConverterFactory(BiFunction) * */ public static final class Params { - /** - *

A {@link ValueConverter} that outputs the given {@link LazyValue} when running {@link #checkAndConvert(Iterator, Context, Context.Type)}, and - * throws {@link UnsupportedOperationException} when trying to convert a {@link Value} directly.

- * - *

Public in order to allow custom {@link ValueConverter} to check whether values should be evaluated while testing conditions.

- */ - /*public static final ValueConverter LAZY_VALUE_IDENTITY = new ValueConverter() - { // No longer possible - - @Override - public LazyValue convert(Value val) - { - throw new UnsupportedOperationException( - "Called convert() with a Value in LazyValue identity, where only evalAndConvert is supported"); - } - - @Override - public LazyValue checkAndConvert(Iterator lazyValueIterator, Context c, Context.Type theLazyT) - { - return lazyValueIterator.hasNext() ? lazyValueIterator.next() : null; - } - - @Override - public String getTypeName() - { - return "something"; - } - };*/ - /** *

A {@link ValueConverter} that outputs the {@link Context} in which the function has been called, and throws {@link UnsupportedOperationException} when trying to convert a {@link Value} * directly.

@@ -228,7 +200,7 @@ public interface Param * *

Stored as {@code , Converter>}

*/ - private static Map, Boolean>, ValueConverter> strictParamsByClassAndShallowness = new HashMap<>(); + private static final Map, Boolean>, ValueConverter> strictParamsByClassAndShallowness = new HashMap<>(); static { // TODO Specify strictness in name? registerStrictConverter(String.class, false, new SimpleTypeConverter<>(StringValue.class, StringValue::getString, "string")); @@ -279,7 +251,7 @@ public interface Param strictParamsByClassAndShallowness.put(key, converter); } - private static List, ValueConverter>> customFactories = new ArrayList<>(); + private static final List, ValueConverter>> customFactories = new ArrayList<>(); /** *

Allows extensions to register COMPLEX {@link ValueConverter} factories in order to be used with the {@link Param.Custom}