Package org.openhab.core.library.types
Class PercentType
java.lang.Object
java.lang.Number
org.openhab.core.library.types.DecimalType
org.openhab.core.library.types.PercentType
- All Implemented Interfaces:
Serializable,Comparable<DecimalType>,Command,PrimitiveType,State,Type
- Direct Known Subclasses:
HSBType
The PercentType extends the
DecimalType by putting constraints for its value on top (0-100).- Author:
- Kai Kreuzer - Initial contribution
- See Also:
-
Field Summary
FieldsFields inherited from class org.openhab.core.library.types.DecimalType
BIG_DECIMAL_HUNDRED, value -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newPercentTypewith 0 as value.PercentType(int value) Creates a newPercentTypewith the given value.PercentType(String value) Creates a newPercentTypewith the given value.PercentType(String value, Locale locale) Creates a newPercentTypewith the given value.PercentType(BigDecimal value) Creates a newPercentTypewith the given value. -
Method Summary
Modifier and TypeMethodDescription<T extends State>
@Nullable TConvert thisState's value into another typestatic PercentTypeStatic access toPercentType(String).Methods inherited from class org.openhab.core.library.types.DecimalType
compareTo, defaultConversion, doubleValue, equals, floatValue, format, hashCode, intValue, longValue, toBigDecimal, toFullString, toStringMethods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
ZERO
-
HUNDRED
-
-
Constructor Details
-
PercentType
public PercentType()Creates a newPercentTypewith 0 as value. -
PercentType
public PercentType(int value) Creates a newPercentTypewith the given value.- Parameters:
value- the value representing a percentage- Throws:
IllegalArgumentException- when the value is not between 0 and 100
-
PercentType
Creates a newPercentTypewith the given value. The English locale is used to determine (decimal/grouping) separator characters.- Parameters:
value- the non null value representing a percentage- Throws:
NumberFormatException- when the number could not be parsed to aBigDecimalIllegalArgumentException- when the value is not between 0 and 100
-
PercentType
Creates a newPercentTypewith the given value.- Parameters:
value- the non null value representing a percentagelocale- the locale used to determine (decimal/grouping) separator characters- Throws:
NumberFormatException- when the number could not be parsed to aBigDecimalIllegalArgumentException- when the value is not between 0 and 100
-
PercentType
Creates a newPercentTypewith the given value.- Parameters:
value- the value representing a percentage.- Throws:
IllegalArgumentException- when the value is not between 0 and 100
-
-
Method Details
-
valueOf
Static access toPercentType(String).- Parameters:
value- the non null value representing a percentage- Returns:
- new
PercentType - Throws:
NumberFormatException- when the number could not be parsed to aBigDecimalIllegalArgumentException- when the value is not between 0 and 100
-
as
Description copied from interface:StateConvert thisState's value into another type
-