com.openxc.units.State 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;
import java.util.Locale;
import com.google.common.base.Objects;
/**
* A State is a type of Unit with a limited number of acceptable values.
*/
public class State> extends Unit {
private T mValue;
/**
* Construct an instance of State from the Enum T value.
*
* @param value an instance of the Enum T.
*/
public State(T value) {
mValue = value;
}
@Override
public boolean equals(Object obj) {
if(!super.equals(obj)) {
return false;
}
@SuppressWarnings("unchecked")
final State other = (State) obj;
return mValue.equals(other.mValue);
}
/**
* Return the value of this State as an Enum.
*
* This is primarily useful for comparison.
*
* @return this State's base Enum value.
*/
public T enumValue() {
return mValue;
}
public String getSerializedValue() {
return mValue.toString().toLowerCase(Locale.US);
}
@Override
public String toString() {
return mValue.toString();
}
}