src/main/java/io/maggregator/Aggregator.java
public static <T> T count(AggregateIterable<Document> aggregate,
                              String propertyName, T identity) {
        Iterator iterator = aggregate.iterator();
        if (!iterator.hasNext()) {
            return identity;
        }
        Document result = (Document) iterator.next();
        return (T) result.get(propertyName);
    }
/**
     * Returns the result of the {@code aggregate} extracting the value of the {@code propertyName},
     * or {@code identity} if nothing was aggregated.
     *
     * @param aggregate Result of an aggregation process
     * @param propertyName Name of the property by which taking the value to be returned
     * @param identity Value returned if the aggregation is empty
     * @param <T> Return type
     *
     * @return Value associated to {@code propertyName} in the document built during the
     *         aggregation process
     */
Returns the result of the  aggregate extracting the value of the  propertyName,
or  identity if nothing was aggregated.

@param aggregate Result of an aggregation process
@param propertyName Name of the property by which taking the value to be returned
@param identity Value returned if the aggregation is empty
@param  Return type

@return Value associated to  propertyName in the document built during the
aggregation process
Returns the result of the aggregate extracting the value of the propertyName or identity if nothing was aggregated . @param aggregate Result of an aggregation process @param propertyName Name of the property by which taking the value to be returned @param identity Value returned if the aggregation is empty @param Return type @return Value associated to propertyName in the document built during the aggregation process
public static <T> T count(AggregateIterable<Document> aggregate,
                              String propertyName, T identity) {
        Iterator iterator = aggregate.iterator();
        if (!iterator.hasNext()) {
            return identity;
        }
        Document result = (Document) iterator.next();
        return (T) result.get(propertyName);
    }
public static < T > T count ( AggregateIterable < Document > aggregate , String propertyName , T identity ) { Iterator iterator = aggregate . iterator ( ) ; if ( ! iterator . hasNext ( ) ) { return identity ; } Document result = ( Document ) iterator . next ( ) ; return ( T ) result . get ( propertyName ) ; }
Returns the result of the {@code aggregate} extracting the value of the {@code propertyName},
 or {@code identity} if nothing was aggregated.
Returns the result of the { @code aggregate } extracting the value of the { @code propertyName } or { @code identity } if nothing was aggregated .