org.srplib.conversion.StringToEnumConverter Maven / Gradle / Ivy
package org.srplib.conversion;
/**
* @author Anton Pechinsky
*/
public class StringToEnumConverter implements Converter {
private Class enumClass;
public StringToEnumConverter(Class enumClass) {
this.enumClass = enumClass;
}
public T convert(String input) {
for (T enumValue : enumClass.getEnumConstants()) {
if (enumValue.name().equals(input)) {
return enumValue;
}
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy