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

Alachisoft.NCache.Common.Queries.AverageResult Maven / Gradle / Ivy

package Alachisoft.NCache.Common.Queries;


import java.io.Serializable;
import java.math.MathContext;
import java.math.RoundingMode;

public class AverageResult implements Serializable { //: ICompactSerializable
    private java.math.BigDecimal sum = new java.math.BigDecimal(0);
    private java.math.BigDecimal count = new java.math.BigDecimal(0);

    public final java.math.BigDecimal getSum() {
        return this.sum;
    }

    public final void setSum(java.math.BigDecimal value) {
        this.sum = value;
    }

    public final java.math.BigDecimal getCount() {
        return this.count;
    }

    public final void setCount(java.math.BigDecimal value) {
        this.count = value;
    }

    public final java.math.BigDecimal getAverage() {
        java.math.BigDecimal average = new java.math.BigDecimal(0);

        if (getCount().compareTo(average) > 0) {
            MathContext mc= new MathContext(34, RoundingMode.UP);
            average = getSum().divide(getCount(),mc);
        }

        return average;
    }

    ///#region ICompactSerializable Members

    //public void Deserialize(Alachisoft.NCache.Runtime.Serialization.IO.CompactReader reader)
    //{
    //    sum = reader.ReadDecimal();
    //    count = reader.ReadDecimal();
    //}

    //public void Serialize(Alachisoft.NCache.Runtime.Serialization.IO.CompactWriter writer)
    //{
    //    writer.Write(sum);
    //    writer.Write(count);
    //}

    ///#endregion
}
//: ICompactSerializable




© 2015 - 2024 Weber Informatics LLC | Privacy Policy