nl.vpro.rs.converters.CaseInsensitiveEnumParamConverterProvider Maven / Gradle / Ivy
package nl.vpro.rs.converters;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import jakarta.ws.rs.ext.ParamConverter;
import jakarta.ws.rs.ext.ParamConverterProvider;
import jakarta.ws.rs.ext.Provider;
/**
* @author Michiel Meeuwissen
* @since 1.75
*/
@Provider
public class CaseInsensitiveEnumParamConverterProvider implements ParamConverterProvider {
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public ParamConverter getConverter(Class rawType, Type genericType, Annotation[] annotations) {
if (Enum.class.isAssignableFrom(rawType)) {
Class extends Enum> clazz = (Class>) rawType;
return CaseInsensitiveEnumParamConverter.getInstant(clazz);
} else {
return null;
}
}
}