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

graphql.execution.instrumentation.DocumentAndVariables Maven / Gradle / Ivy

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

import graphql.PublicApi;
import graphql.collect.ImmutableMapWithNullValues;
import graphql.language.Document;

import java.util.Map;
import java.util.function.Consumer;

import static graphql.Assert.assertNotNull;

@PublicApi
public class DocumentAndVariables {
    private final Document document;
    private final ImmutableMapWithNullValues variables;

    private DocumentAndVariables(Document document, Map variables) {
        this.document = assertNotNull(document);
        this.variables = ImmutableMapWithNullValues.copyOf(assertNotNull(variables));
    }

    public Document getDocument() {
        return document;
    }

    public Map getVariables() {
        return variables;
    }

    public DocumentAndVariables transform(Consumer builderConsumer) {
        Builder builder = new Builder().document(this.document).variables(this.variables);
        builderConsumer.accept(builder);
        return builder.build();
    }

    public static Builder newDocumentAndVariables() {
        return new Builder();
    }

    public static class Builder {
        private Document document;
        private Map variables;

        public Builder document(Document document) {
            this.document = document;
            return this;
        }

        public Builder variables(Map variables) {
            this.variables = variables;
            return this;
        }

        public DocumentAndVariables build() {
            return new DocumentAndVariables(document, variables);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy