Class IntegerCharacteristic

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        IntegerCharacteristic​(java.lang.String type, java.lang.String description, int minValue, int maxValue, java.lang.String unit, java.util.Optional<java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.lang.Integer>>> getter, java.util.Optional<ExceptionalConsumer<java.lang.Integer>> setter, java.util.Optional<java.util.function.Consumer<HomekitCharacteristicChangeCallback>> subscriber, java.util.Optional<java.lang.Runnable> unsubscriber)
      Default constructor
      protected IntegerCharacteristic​(java.lang.String type, java.lang.String format, java.lang.String description, int minValue, int maxValue, java.lang.String unit, java.util.Optional<java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.lang.Integer>>> getter, java.util.Optional<ExceptionalConsumer<java.lang.Integer>> setter, java.util.Optional<java.util.function.Consumer<HomekitCharacteristicChangeCallback>> subscriber, java.util.Optional<java.lang.Runnable> unsubscriber)
      Constructor for characteristics whose HAP format differs from the default "int", e.g.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Integer convert​(javax.json.JsonValue jsonValue)
      Converts from the JSON value to a Java object of the type T
      java.lang.Integer getDefault()
      Supplies a default value for the characteristic to send to connected clients when the real value.
      java.util.concurrent.CompletableFuture<java.lang.Integer> getValue()
      Retrieves the current value of the characteristic.
      protected java.util.concurrent.CompletableFuture<javax.json.JsonObjectBuilder> makeBuilder​(int iid)
      Creates the JSON serialized form of the accessory for use over the HomeKit Accessory Protocol.
      void setValue​(java.lang.Integer value)
      Update the characteristic value using a new value supplied by the connected client.
      void setValue​(java.lang.Integer value, java.lang.String username)
      Update the characteristic value using a new value supplied by the connected client.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IntegerCharacteristic

        public IntegerCharacteristic​(java.lang.String type,
                                     java.lang.String description,
                                     int minValue,
                                     int maxValue,
                                     java.lang.String unit,
                                     java.util.Optional<java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.lang.Integer>>> getter,
                                     java.util.Optional<ExceptionalConsumer<java.lang.Integer>> 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.
        minValue - the minimum supported value.
        maxValue - the maximum supported value
        unit - a description of the unit this characteristic supports.
        getter - getter for value
        setter - setter for value
        subscriber - subscribers to changes
        unsubscriber - unsubscribers to changes
      • IntegerCharacteristic

        protected IntegerCharacteristic​(java.lang.String type,
                                        java.lang.String format,
                                        java.lang.String description,
                                        int minValue,
                                        int maxValue,
                                        java.lang.String unit,
                                        java.util.Optional<java.util.function.Supplier<java.util.concurrent.CompletableFuture<java.lang.Integer>>> getter,
                                        java.util.Optional<ExceptionalConsumer<java.lang.Integer>> setter,
                                        java.util.Optional<java.util.function.Consumer<HomekitCharacteristicChangeCallback>> subscriber,
                                        java.util.Optional<java.lang.Runnable> unsubscriber)
        Constructor for characteristics whose HAP format differs from the default "int", e.g. "uint8", "uint16" or "uint32". Values are still handled as Java Integer, so the supported range must fit into a signed 32-bit integer.
        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.
        format - the HAP format to advertise, e.g. "int" or "uint32".
        description - a description of the characteristic to be passed to the consuming device.
        minValue - the minimum supported value.
        maxValue - the maximum supported value
        unit - a description of the unit this characteristic supports.
        getter - getter for value
        setter - setter for value
        subscriber - subscribers to changes
        unsubscriber - unsubscribers to changes
    • Method Detail

      • makeBuilder

        protected java.util.concurrent.CompletableFuture<javax.json.JsonObjectBuilder> makeBuilder​(int iid)
        Creates the JSON serialized form of the accessory for use over the HomeKit Accessory Protocol.
        Overrides:
        makeBuilder in class BaseCharacteristic<java.lang.Integer>
        Parameters:
        iid - the static id of the accessory.
        Returns:
        a future that will complete with the JSON builder for the object.
      • getValue

        public java.util.concurrent.CompletableFuture<java.lang.Integer> getValue()
        Description copied from class: BaseCharacteristic
        Retrieves the current value of the characteristic.
        Specified by:
        getValue in class BaseCharacteristic<java.lang.Integer>
        Returns:
        a future that will complete with the current value.
      • setValue

        public void setValue​(java.lang.Integer value)
                      throws java.lang.Exception
        Description copied from class: BaseCharacteristic
        Update the characteristic value using a new value supplied by the connected client.
        Specified by:
        setValue in class BaseCharacteristic<java.lang.Integer>
        Parameters:
        value - the new value to set.
        Throws:
        java.lang.Exception - if the value cannot be set.
      • setValue

        public void setValue​(java.lang.Integer value,
                             java.lang.String username)
                      throws java.lang.Exception
        Description copied from class: BaseCharacteristic
        Update the characteristic value using a new value supplied by the connected client.
        Overrides:
        setValue in class BaseCharacteristic<java.lang.Integer>
        Parameters:
        value - the new value to set.
        username - the authenticated username making the request
        Throws:
        java.lang.Exception - if the value cannot be set.
      • getDefault

        public java.lang.Integer getDefault()
        Supplies a default value for the characteristic to send to connected clients when the real value. cannot be retrieved.
        Specified by:
        getDefault in class BaseCharacteristic<java.lang.Integer>
        Returns:
        a sensible default value.
      • convert

        protected java.lang.Integer convert​(javax.json.JsonValue jsonValue)
        Converts from the JSON value to a Java object of the type T
        Specified by:
        convert in class BaseCharacteristic<java.lang.Integer>
        Parameters:
        jsonValue - the JSON value to convert from.
        Returns:
        the converted Java object.