Archiviert
13
0

Add back EnumConverters#getGenericConverter(Class)

It should work, but is deprecated and not recommended
Addresses #394
Dieser Commit ist enthalten in:
Dan Mulloy 2017-09-27 19:43:38 -04:00
Ursprung 7573459a48
Commit 5f14ccdc34
2 geänderte Dateien mit 27 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -317,6 +317,20 @@ public class BukkitConverters {
}); });
} }
/**
* @deprecated While this solution is not as abhorrent as I had imagined, I still highly recommend switching to the
* new conversion API.
*/
@Deprecated
public static <T> EquivalentConverter<Set<T>> getSetConverter(final Class<?> genericType,
final EquivalentConverter<T> itemConverter) {
if (itemConverter instanceof EnumWrappers.EnumConverter) {
((EnumWrappers.EnumConverter) itemConverter).setGenericType(genericType);
}
return getSetConverter(itemConverter);
}
/** /**
* Retrieve an equivalent converter for a set of generic items. * Retrieve an equivalent converter for a set of generic items.
* @param <T> Element type * @param <T> Element type

Datei anzeigen

@ -652,6 +652,14 @@ public abstract class EnumWrappers {
return new EnumConverter<>(genericClass, specificType); return new EnumConverter<>(genericClass, specificType);
} }
/**
* @deprecated Replaced with {@link #getGenericConverter(Class, Class)}
*/
@Deprecated
public static <T extends Enum<T>> EquivalentConverter<T> getGenericConverter(Class<T> specificType) {
return new EnumConverter<>(null, specificType);
}
// The common enum converter // The common enum converter
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public static class EnumConverter<T extends Enum<T>> implements EquivalentConverter<T> { public static class EnumConverter<T extends Enum<T>> implements EquivalentConverter<T> {
@ -675,7 +683,11 @@ public abstract class EnumWrappers {
@Override @Override
public Class<T> getSpecificType() { public Class<T> getSpecificType() {
return null; return specificType;
}
void setGenericType(Class<?> genericType) {
this.genericType = genericType;
} }
} }
} }