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

graphql.schema.GraphQLDirectiveContainer Maven / Gradle / Ivy

There is a newer version: 230521-nf-execution
Show newest version
package graphql.schema;


import graphql.PublicApi;

import java.util.List;
import java.util.Map;

import static graphql.DirectivesUtil.directivesByName;
import static graphql.DirectivesUtil.directiveByName;

/**
 * Represents a graphql object that can have {@link graphql.schema.GraphQLDirective}s
 */
@PublicApi
public interface GraphQLDirectiveContainer extends GraphQLNamedSchemaElement {

    /**
     * @return a list of directives associated with the type or field
     */
    List getDirectives();

    /**
     * @return a a map of directives by directive name
     */
    default Map getDirectivesByName() {
        return directivesByName(getDirectives());
    }

    /**
     * Returns a named directive
     *
     * @param directiveName the name of the directive to retrieve
     *
     * @return the directive or null if there is one one with that name
     */
    default GraphQLDirective getDirective(String directiveName) {
        return directiveByName(getDirectives(), directiveName).orElse(null);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy