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