# The Java Embedded Aggregator Class Count Aggregate

CountAggregate implements the "Count all" aggregation.

### For an overview see page Java Aggregator Class

### Class Definition

        public static class CountAggregate implements Aggregate
        {
            public void initialize(Object val)
            {
                count = 1;
            }

            public void accumulate(Object val)
            {
                count += 1;
            }

            public Object result()
            {
                return new Long(count);
            }

            public void merge(Aggregate other)
            {
                count += ((CountAggregate)other).count;
            }

            long count;
        }