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

com.openxc.units.Quantity Maven / Gradle / Ivy

The newest version!
package com.openxc.units;

/**
 * A quantitative type of {@link Unit}.
 *
 * All quantitative children of {@link Unit} extend from this abstract class,
 * which encapsulates common logic for converting among different numerical
 * values.
 */
public abstract class Quantity extends Unit {
    private T mValue;

    /**
     * Construct an instance of Quantity with the value.
     *
     * @param value a quantitative Unit value.
     */
    public Quantity(T value) {
        mValue = value;
    }

    @Override
    public boolean equals(Object obj) {
        if(!super.equals(obj)) {
            return false;
        }

        @SuppressWarnings("unchecked")
        final Quantity other = (Quantity) obj;
        return mValue.equals(other.mValue);
    }

    public double doubleValue() {
        return mValue.doubleValue();
    }

    public Object getSerializedValue() {
        return doubleValue();
    }

    public int intValue() {
        return mValue.intValue();
    }

    public String getTypeString() {
        return "";
    }

    @Override
    public String toString() {
        return mValue.toString() + " " + getTypeString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy