package graphql.execution;

import graphql.Assert;
import graphql.language.FragmentDefinition;
import graphql.schema.GraphQLFieldsContainer;
import graphql.schema.GraphQLSchema;

import java.util.LinkedHashMap;
import java.util.Map;

public class FieldCollectorParameters {
    private final GraphQLSchema graphQLSchema;
    private final Map<String, FragmentDefinition> fragmentsByName;
    private final Map<String, Object> variables;
    private final GraphQLFieldsContainer fieldsContainer;

    public GraphQLSchema getGraphQLSchema() {
        return graphQLSchema;
    }

    public Map<String, FragmentDefinition> getFragmentsByName() {
        return fragmentsByName;
    }

    public Map<String, Object> getVariables() {
        return variables;
    }

    public GraphQLFieldsContainer getFieldsContainer() {
        return fieldsContainer;
    }

    private FieldCollectorParameters(GraphQLSchema graphQLSchema, Map<String, Object> variables, Map<String, FragmentDefinition> fragmentsByName, GraphQLFieldsContainer fieldsContainer) {
        this.fragmentsByName = fragmentsByName;
        this.graphQLSchema = graphQLSchema;
        this.variables = variables;
        this.fieldsContainer = fieldsContainer;
    }

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

    public static class Builder {
        private GraphQLSchema graphQLSchema;
        private Map<String, FragmentDefinition> fragmentsByName = new LinkedHashMap<>();
        private Map<String, Object> variables = new LinkedHashMap<>();
        private GraphQLFieldsContainer fieldsContainer;

        /**
         * @see FieldCollectorParameters#newParameters()
         */
        private Builder() {

        }

        public Builder schema(GraphQLSchema graphQLSchema) {
            this.graphQLSchema = graphQLSchema;
            return this;
        }

        public Builder fieldsContainer(GraphQLFieldsContainer fieldsContainer) {
            this.fieldsContainer = fieldsContainer;
            return this;
        }

        public Builder fragments(Map<String, FragmentDefinition> fragmentsByName) {
            this.fragmentsByName.putAll(fragmentsByName);
            return this;
        }

        public Builder variables(Map<String, Object> variables) {
            this.variables.putAll(variables);
            return this;
        }

        public FieldCollectorParameters build() {
            Assert.assertNotNull(graphQLSchema, "You must provide a schema");
            Assert.assertNotNull(fieldsContainer, "You must provide an fieldsContainer type");
            return new FieldCollectorParameters(graphQLSchema, variables, fragmentsByName, fieldsContainer);
        }

    }
}

@@ -44,16 +44,41 @@
 Assert;%0A
+import graphql.Internal;%0A
 import g
@@ -252,16 +252,82 @@
 l.Map;%0A%0A
+/**%0A * Internal because FieldCollector is internal.%0A */%0A@Internal%0A
 public c

mark it as internal