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

graphql.schema.diff.reporting.CapturingReporter Maven / Gradle / Ivy

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

import graphql.PublicApi;
import graphql.schema.diff.DiffEvent;
import graphql.schema.diff.DiffLevel;

import java.util.ArrayList;
import java.util.List;

/**
 * A reporter that captures all the difference events as they occur
 */
@PublicApi
public class CapturingReporter implements DifferenceReporter {
    private final List events = new ArrayList<>();
    private final List infos = new ArrayList<>();
    private final List breakages = new ArrayList<>();
    private final List dangers = new ArrayList<>();

    @Override
    public void report(DiffEvent differenceEvent) {
        events.add(differenceEvent);

        if (differenceEvent.getLevel() == DiffLevel.BREAKING) {
            breakages.add(differenceEvent);
        } else if (differenceEvent.getLevel() == DiffLevel.DANGEROUS) {
            dangers.add(differenceEvent);
        } else if (differenceEvent.getLevel() == DiffLevel.INFO) {
            infos.add(differenceEvent);
        }
    }

    @Override
    public void onEnd() {
    }

    public List getEvents() {
        return new ArrayList<>(events);
    }

    public List getInfos() {
        return new ArrayList<>(infos);
    }

    public List getBreakages() {
        return new ArrayList<>(breakages);
    }

    public List getDangers() {
        return new ArrayList<>(dangers);
    }

    public int getInfoCount() {
        return infos.size();
    }

    public int getBreakageCount() {
        return breakages.size();
    }

    public int getDangerCount() {
        return dangers.size();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy