All Downloads are FREE. Search and download functionalities are using the official Maven repository.

graphql.schema.idl.NaturalEnumValuesProvider Maven / Gradle / Ivy

There is a newer version: 230521-nf-execution
Show newest version
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