![JAR search and dependency download from the Maven repository](/logo.png)
com.infilos.spring.utils.NameBasedEnum Maven / Gradle / Ivy
package com.infilos.spring.utils;
import com.fasterxml.jackson.annotation.JsonValue;
public interface NameBasedEnum> {
@JsonValue
String name();
static , E extends Enum> T fromName(Class type, String name) {
for (T t : type.getEnumConstants()) {
if (t.name().equals(name)) {
return t;
}
}
throw new IllegalArgumentException(String.format("%s cannot match the name: %s", type.getSimpleName(), name));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy