jadex.bridge.sensor.unit.PercentUnit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-platform-bridge Show documentation
Show all versions of jadex-platform-bridge Show documentation
Jadex bridge is a base package for kernels and platforms, i.e., it is used by both and provides commonly used interfaces and classes for active components and their management.
package jadex.bridge.sensor.unit;
/**
* Percent unit.
*/
public enum PercentUnit implements IConvertableUnit, IPrettyPrintUnit
{
PERCENT;
/**
* Convert to a known unit.
*/
public Double convert(Double value)
{
int val = (int)(value*10000);
double ret = ((double)val)/100;
return ret;
}
/**
* Pretty print a value according to the underlying unit to a string.
* @param value The value.
* @return The pretty printed string.
*/
public String prettyPrint(Double value)
{
return ""+convert(value)+" %";
}
}