Example usage for org.antlr.v4.runtime.misc OrderedHashSet OrderedHashSet

List of usage examples for org.antlr.v4.runtime.misc OrderedHashSet OrderedHashSet

Introduction

In this page you can find the example usage for org.antlr.v4.runtime.misc OrderedHashSet OrderedHashSet.

Prototype

OrderedHashSet

Source Link

Usage

From source file:io.viewserver.operators.group.GroupByOperator.java

License:Apache License

@Override
protected IGroupByConfig mergePendingConfig(IGroupByConfig pendingConfig, IGroupByConfig newConfig) {
    if (!ObjectUtils.equals(pendingConfig.getCountColumnName(), newConfig.getCountColumnName())) {
        throw new IllegalStateException("Cannot merge configs with conflicting count column names");
    }//from  w w  w  .  jav a 2 s  .  c o m
    if (!ObjectUtils.equals(pendingConfig.getGroupBy(), newConfig.getGroupBy())) {
        throw new IllegalStateException("Cannot merge configs with conflicting group by columns");
    }
    if (!ObjectUtils.equals(pendingConfig.getSubtotals(), newConfig.getSubtotals())) {
        throw new IllegalStateException("Cannot merge configs with conflicting subtotals setting");
    }
    return new IGroupByConfig() {
        @Override
        public List<String> getGroupBy() {
            return pendingConfig.getGroupBy();
        }

        @Override
        public List<Summary> getSummaries() {
            HashSet<Summary> summaries = new OrderedHashSet<>();
            summaries.addAll(pendingConfig.getSummaries());
            summaries.addAll(newConfig.getSummaries());
            return new ArrayList<>(summaries);
        }

        @Override
        public String getCountColumnName() {
            return pendingConfig.getCountColumnName();
        }

        @Override
        public List<String> getSubtotals() {
            return pendingConfig.getSubtotals();
        }
    };
}