graphql.schema.idl.NaturalEnumValuesProvider Maven / Gradle / Ivy
package graphql.schema.idl;
import graphql.Assert;
import graphql.PublicApi;
/**
* Simple EnumValuesProvided which maps the GraphQL Enum name to the Java Enum instance.
*/
@PublicApi
public class NaturalEnumValuesProvider> implements EnumValuesProvider {
private final Class enumType;
public NaturalEnumValuesProvider(Class enumType) {
Assert.assertNotNull(enumType, () -> "enumType can't be null");
this.enumType = enumType;
}
@Override
public T getValue(String name) {
return Enum.valueOf(enumType, name);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy