warning cleanup

This commit is contained in:
gnembon committed 2023-02-08 21:13:15 +01:00
1 parent 5ab4a9e442
commit 277872b33c
106 files changed
+4495 -4345

No files matched your search

@@ -10,6 +10,8 @@ import carpet.script.Context;
import carpet.script.value.ListValue;
import carpet.script.value.Value;
import javax.annotation.Nullable;
/**
* <p>Converts a given {@link ListValue} into a {@link List} of values converted to {@code <T>}.</p>
*
@@ -32,18 +34,20 @@ final class ListConverter<T> implements ValueConverter<List<T>>
return (allowSingletonCreation ? itemConverter.getTypeName() + " or " : "") + "list of " + itemConverter.getTypeName() + "s";
}
@Nullable
@Override
public List<T> convert(final Value value, final Context context)
public List<T> convert(Value value, @Nullable Context context)
{
return value instanceof ListValue ? convertListValue((ListValue) value, context) : allowSingletonCreation ? convertSingleton(value, context) : null;
}
private List<T> convertListValue(final ListValue values, final Context context)
@Nullable
private List<T> convertListValue(ListValue values, @Nullable Context context)
{
final List<T> list = new ArrayList<>(values.getItems().size());
for (final Value value : values)
List<T> list = new ArrayList<>(values.getItems().size());
for (Value value : values)
{
final T converted = itemConverter.convert(value, context);
T converted = itemConverter.convert(value, context);
if (converted == null)
{
return null;
@@ -53,9 +57,10 @@ final class ListConverter<T> implements ValueConverter<List<T>>
return list;
}
private List<T> convertSingleton(final Value val, final Context context)
@Nullable
private List<T> convertSingleton(Value val, @Nullable Context context)
{
final T converted = itemConverter.convert(val, context);
T converted = itemConverter.convert(val, context);
if (converted == null)
{
return null;
@@ -64,7 +69,7 @@ final class ListConverter<T> implements ValueConverter<List<T>>
}
private ListConverter(final AnnotatedType itemType, final boolean allowSingletonCreation)
private ListConverter(AnnotatedType itemType, boolean allowSingletonCreation)
{
itemConverter = ValueConverter.fromAnnotatedType(itemType);
this.allowSingletonCreation = allowSingletonCreation;
@@ -84,11 +89,11 @@ final class ListConverter<T> implements ValueConverter<List<T>>
* @param annotatedType The type to get generics information from
* @return A new {@link ListConverter} for the data specified in the {@link AnnotatedType}
*/
static ListConverter<?> fromAnnotatedType(final AnnotatedType annotatedType)
static ListConverter<?> fromAnnotatedType(AnnotatedType annotatedType)
{
final AnnotatedParameterizedType paramType = (AnnotatedParameterizedType) annotatedType;
final AnnotatedType itemType = paramType.getAnnotatedActualTypeArguments()[0];
final boolean allowSingletonCreation = annotatedType.isAnnotationPresent(Param.AllowSingleton.class);
AnnotatedParameterizedType paramType = (AnnotatedParameterizedType) annotatedType;
AnnotatedType itemType = paramType.getAnnotatedActualTypeArguments()[0];
boolean allowSingletonCreation = annotatedType.isAnnotationPresent(Param.AllowSingleton.class);
return new ListConverter<>(itemType, allowSingletonCreation);
}