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

com.tangosol.util.aggregator.AbstractLongAggregator Maven / Gradle / Ivy

There is a newer version: 24.09
Show newest version
/*
 * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
 *
 * Licensed under the Universal Permissive License v 1.0 as shown at
 * http://oss.oracle.com/licenses/upl.
 */

package com.tangosol.util.aggregator;


import com.tangosol.util.ValueExtractor;


/**
* Abstract aggregator that processes numeric values extracted from a set of
* entries in a Map. All the extracted Number objects will be treated as Java
* long values and the result of the aggregator is a Long.
* If the set of entries is empty, a null result is returned.
*
* @param   the type of the value to extract from
*
* @author cp/gg/jh  2005.07.19
* @since Coherence 3.1
*/
public abstract class AbstractLongAggregator
        extends AbstractAggregator
    {
    // ----- constructors ---------------------------------------------------

    /**
    * Default constructor (necessary for the ExternalizableLite interface).
    */
    public AbstractLongAggregator()
        {
        super();
        }

    /**
    * Construct an AbstractLongAggregator object.
    *
    * @param extractor  the extractor that provides a value in the form of
    *                   any Java object that is a {@link Number}
    */
    public AbstractLongAggregator(ValueExtractor extractor)
        {
        super(extractor);
        }

    /**
    * Construct an AbstractLongAggregator object.
    *
    * @param sMethod  the name of the method that returns a value in the form
    *                 of any Java object that is a {@link Number}
    */
    public AbstractLongAggregator(String sMethod)
        {
        super(sMethod);
        }


    // ----- AbstractAggregator methods -------------------------------------

    /**
    * {@inheritDoc}
    */
    protected void init(boolean fFinal)
        {
        m_count = 0;
        }

    /**
    * {@inheritDoc}
    */
    protected Long finalizeResult(boolean fFinal)
        {
        return m_count == 0 ? null : m_lResult;
        }


    // ----- data members ---------------------------------------------------

    /**
    * The count of processed entries.
    */
    protected transient int m_count;

    /**
    * The running result value.
    */
    protected transient long m_lResult;
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy