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

graphql.execution.nextgen.result.ResultNodeAdapter Maven / Gradle / Ivy

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

import graphql.Assert;
import graphql.PublicApi;
import graphql.util.NodeAdapter;
import graphql.util.NodeLocation;

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

@PublicApi
public class ResultNodeAdapter implements NodeAdapter {

    public static final ResultNodeAdapter RESULT_NODE_ADAPTER = new ResultNodeAdapter();

    private ResultNodeAdapter() {

    }

    @Override
    public Map> getNamedChildren(ExecutionResultNode node) {
        Map> result = new LinkedHashMap<>();
        result.put(null, node.getChildren());
        return result;
    }

    @Override
    public ExecutionResultNode withNewChildren(ExecutionResultNode node, Map> newChildren) {
        Assert.assertTrue(newChildren.size() == 1);
        List childrenList = newChildren.get(null);
        Assert.assertNotNull(childrenList);
        return node.withNewChildren(childrenList);
    }

    @Override
    public ExecutionResultNode removeChild(ExecutionResultNode node, NodeLocation location) {
        throw new UnsupportedOperationException();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy