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
Fields inherited from class org.openhab.core.library.types.DecimalType
BIG_DECIMAL_HUNDRED, value
-
Constructor Summary
ConstructorDescriptionCreates a newPercentType
with 0 as value.PercentType
(int value) Creates a newPercentType
with the given value.PercentType
(String value) Creates a newPercentType
with the given value.PercentType
(String value, Locale locale) Creates a newPercentType
with the given value.PercentType
(BigDecimal value) Creates a newPercentType
with the given value. -
Method Summary
Modifier and TypeMethodDescription<T extends State>
@Nullable TConvert thisState
's value into another typestatic PercentType
Static access toPercentType(String)
.Methods inherited from class org.openhab.core.library.types.DecimalType
compareTo, defaultConversion, doubleValue, equals, floatValue, format, hashCode, intValue, longValue, toBigDecimal, toFullString, toString
Methods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
ZERO
-
HUNDRED
-
-
Constructor Details
-
PercentType
public PercentType()Creates a newPercentType
with 0 as value. -
PercentType
public PercentType(int value) Creates a newPercentType
with the given value.- Parameters:
value
- the value representing a percentage- Throws:
IllegalArgumentException
- when the value is not between 0 and 100
-
PercentType
Creates a newPercentType
with 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 aBigDecimal
IllegalArgumentException
- when the value is not between 0 and 100
-
PercentType
Creates a newPercentType
with 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 aBigDecimal
IllegalArgumentException
- when the value is not between 0 and 100
-
PercentType
Creates a newPercentType
with 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 aBigDecimal
IllegalArgumentException
- when the value is not between 0 and 100
-
as
Description copied from interface:State
Convert thisState
's value into another type
-