Class IntegerCharacteristic
- java.lang.Object
-
- io.github.hapjava.characteristics.impl.base.BaseCharacteristic<Integer>
-
- io.github.hapjava.characteristics.impl.base.IntegerCharacteristic
-
- All Implemented Interfaces:
Characteristic,EventableCharacteristic
- Direct Known Subclasses:
ActiveIdentifierCharacteristic,AirPlayEnableCharacteristic,BatteryLevelCharacteristic,BrightnessCharacteristic,ColorTemperatureCharacteristic,CurrentHorizontalTiltAngleCharacteristic,CurrentPositionCharacteristic,CurrentTiltAngleCharacteristic,CurrentVerticalTiltAngleCharacteristic,IdentifierCharacteristic,RemainingDurationCharacteristic,ResetFilterIndicationCharacteristic,ServiceLabelIndexCharacteristic,SetDurationCharacteristic,TargetHorizontalTiltAngleCharacteristic,TargetPositionCharacteristic,TargetTiltAngleCharacteristic,TargetVerticalTiltAngleCharacteristic,VolumeCharacteristic
public abstract class IntegerCharacteristic extends BaseCharacteristic<Integer>
A characteristic that provides an Integer data type.- Author:
- Andy Lintner
-
-
Constructor Summary
Constructors Constructor Description IntegerCharacteristic(String type, String description, int minValue, int maxValue, String unit, Optional<Supplier<CompletableFuture<Integer>>> getter, Optional<ExceptionalConsumer<Integer>> setter, Optional<Consumer<HomekitCharacteristicChangeCallback>> subscriber, Optional<Runnable> unsubscriber)Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Integerconvert(javax.json.JsonValue jsonValue)Converts from the JSON value to a Java object of the type TIntegergetDefault()Supplies a default value for the characteristic to send to connected clients when the real value.protected CompletableFuture<Integer>getValue()Retrieves the current value of the characteristic.protected CompletableFuture<javax.json.JsonObjectBuilder>makeBuilder(int iid)Creates the JSON serialized form of the accessory for use over the HomeKit Accessory Protocol.protected voidsetValue(Integer value)Update the characteristic value using a new value supplied by the connected client.-
Methods inherited from class io.github.hapjava.characteristics.impl.base.BaseCharacteristic
setJsonValue, setValue, subscribe, supplyValue, toJson, unsubscribe
-
-
-
-
Constructor Detail
-
IntegerCharacteristic
public IntegerCharacteristic(String type, String description, int minValue, int maxValue, String unit, Optional<Supplier<CompletableFuture<Integer>>> getter, Optional<ExceptionalConsumer<Integer>> setter, Optional<Consumer<HomekitCharacteristicChangeCallback>> subscriber, Optional<Runnable> unsubscriber)
Default constructor- Parameters:
type- a string containing a UUID that indicates the type of characteristic. Apple defines a set of these, however implementors can create their own as well.description- a description of the characteristic to be passed to the consuming device.minValue- the minimum supported value.maxValue- the maximum supported valueunit- a description of the unit this characteristic supports.getter- getter for valuesetter- setter for valuesubscriber- subscribers to changesunsubscriber- unsubscribers to changes
-
-
Method Detail
-
makeBuilder
protected CompletableFuture<javax.json.JsonObjectBuilder> makeBuilder(int iid)
Creates the JSON serialized form of the accessory for use over the HomeKit Accessory Protocol.- Overrides:
makeBuilderin classBaseCharacteristic<Integer>- Parameters:
iid- the static id of the accessory.- Returns:
- a future that will complete with the JSON builder for the object.
-
getValue
protected CompletableFuture<Integer> getValue()
Description copied from class:BaseCharacteristicRetrieves the current value of the characteristic.- Specified by:
getValuein classBaseCharacteristic<Integer>- Returns:
- a future that will complete with the current value.
-
setValue
protected void setValue(Integer value) throws Exception
Description copied from class:BaseCharacteristicUpdate the characteristic value using a new value supplied by the connected client.- Specified by:
setValuein classBaseCharacteristic<Integer>- Parameters:
value- the new value to set.- Throws:
Exception- if the value cannot be set.
-
getDefault
public Integer getDefault()
Supplies a default value for the characteristic to send to connected clients when the real value. cannot be retrieved.- Specified by:
getDefaultin classBaseCharacteristic<Integer>- Returns:
- a sensible default value.
-
convert
protected Integer convert(javax.json.JsonValue jsonValue)
Converts from the JSON value to a Java object of the type T- Specified by:
convertin classBaseCharacteristic<Integer>- Parameters:
jsonValue- the JSON value to convert from.- Returns:
- the converted Java object.
-
-