Class BooleanCharacteristic
- java.lang.Object
-
- io.github.hapjava.characteristics.impl.base.BaseCharacteristic<java.lang.Boolean>
-
- io.github.hapjava.characteristics.impl.base.BooleanCharacteristic
-
- All Implemented Interfaces:
Characteristic,EventableCharacteristic
- Direct Known Subclasses:
HoldPositionCharacteristic,IdentifyCharacteristic,MotionDetectedCharacteristic,MuteCharacteristic,ObstructionDetectedCharacteristic,OnCharacteristic,OutletInUseCharacteristic,StatusActiveCharacteristic
public abstract class BooleanCharacteristic extends BaseCharacteristic<java.lang.Boolean>
Characteristic that exposes a Boolean value.- Author:
- Andy Lintner
-
-
Constructor Summary
Constructors Constructor Description BooleanCharacteristic(java.lang.String type, java.lang.String description, java.util.Optional<java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.lang.Boolean>>> getter, java.util.Optional<ExceptionalConsumer<java.lang.Boolean>> setter, java.util.Optional<java.util.function.Consumer<HomekitCharacteristicChangeCallback>> subscriber, java.util.Optional<java.lang.Runnable> unsubscriber)Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Booleanconvert(javax.json.JsonValue jsonValue)Converts from the JSON value to a Java object of the type Tjava.lang.BooleangetDefault()Supplies a default value for the characteristic to send to connected clients when the real value.java.util.concurrent.CompletableFuture<java.lang.Boolean>getValue()Retrieves the current value of the characteristic.voidsetValue(java.lang.Boolean 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
getType, makeBuilder, setJsonValue, setValue, subscribe, supplyValue, toJson, unsubscribe
-
-
-
-
Constructor Detail
-
BooleanCharacteristic
public BooleanCharacteristic(java.lang.String type, java.lang.String description, java.util.Optional<java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.lang.Boolean>>> getter, java.util.Optional<ExceptionalConsumer<java.lang.Boolean>> setter, java.util.Optional<java.util.function.Consumer<HomekitCharacteristicChangeCallback>> subscriber, java.util.Optional<java.lang.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.getter- getter to retrieve the valuesetter- setter to set valuesubscriber- subscriber to subscribe to changesunsubscriber- unsubscriber to unsubscribe from chnages
-
-
Method Detail
-
convert
protected java.lang.Boolean convert(javax.json.JsonValue jsonValue)
Converts from the JSON value to a Java object of the type T- Specified by:
convertin classBaseCharacteristic<java.lang.Boolean>- Parameters:
jsonValue- the JSON value to convert from.- Returns:
- the converted Java object.
-
getValue
public java.util.concurrent.CompletableFuture<java.lang.Boolean> getValue()
Description copied from class:BaseCharacteristicRetrieves the current value of the characteristic.- Specified by:
getValuein classBaseCharacteristic<java.lang.Boolean>- Returns:
- a future that will complete with the current value.
-
setValue
public void setValue(java.lang.Boolean value) throws java.lang.ExceptionDescription copied from class:BaseCharacteristicUpdate the characteristic value using a new value supplied by the connected client.- Specified by:
setValuein classBaseCharacteristic<java.lang.Boolean>- Parameters:
value- the new value to set.- Throws:
java.lang.Exception- if the value cannot be set.
-
getDefault
public java.lang.Boolean getDefault()
Supplies a default value for the characteristic to send to connected clients when the real value. cannot be retrieved.- Specified by:
getDefaultin classBaseCharacteristic<java.lang.Boolean>- Returns:
- a sensible default value.
-
-