Add back EnumConverters#getGenericConverter(Class)

It should work, but is deprecated and not recommended
Addresses #394
This commit is contained in:
Dan Mulloy 2017-09-27 19:43:38 -04:00
parent 7573459a48
commit 5f14ccdc34
2 changed files with 27 additions and 1 deletions

View File

@ -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.
* @param <T> Element type

View File

@ -652,6 +652,14 @@ public abstract class EnumWrappers {
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
@SuppressWarnings({ "rawtypes", "unchecked" })
public static class EnumConverter<T extends Enum<T>> implements EquivalentConverter<T> {
@ -675,7 +683,11 @@ public abstract class EnumWrappers {
@Override
public Class<T> getSpecificType() {
return null;
return specificType;
}
void setGenericType(Class<?> genericType) {
this.genericType = genericType;
}
}
}