SteamWar/SpigotCore
Archiviert
13
0

Remove SWCommandUtils.mapper

Dieser Commit ist enthalten in:
yoyosource 2021-03-25 12:38:42 +01:00
Ursprung 10cb766be9
Commit e9fbfcac70

Datei anzeigen

@ -199,28 +199,6 @@ class SWCommandUtils {
return arguments;
}
@SuppressWarnings("unchecked")
private static Function<String, Object> mapper(Parameter parameter) {
Class<?> clazz = parameter.getType();
if (parameter.isVarArgs()) {
clazz = clazz.getComponentType();
}
if (clazz.isEnum()) {
Class<Enum<?>> enumClass = (Class<Enum<?>>) clazz;
return s -> ENUM_MAPPER.apply(enumClass, s);
}
String name = clazz.getTypeName();
SWCommand.Mapper mapper = parameter.getAnnotation(SWCommand.Mapper.class);
if (mapper != null) {
name = mapper.mapper();
}
TypeMapper<?> typeMapper = MAPPER_FUNCTIONS.getOrDefault(name, ERROR_FUNCTION);
return typeMapper::map;
}
public static void addMapper(String name, TypeMapper<?> mapper) {
if (MAPPER_FUNCTIONS.containsKey(name)) return;
MAPPER_FUNCTIONS.put(name, mapper);