com.openxc.units.Quantity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openxc-it Show documentation
Show all versions of openxc-it Show documentation
Instrumentation test suite for OpenXC library
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();
}
}