Interface ThingAttributeChangeRegistration

    • Method Detail

      • registerForAttributesChanges

        void registerForAttributesChanges​(java.lang.String registrationId,
                                          java.util.function.Consumer<Change> handler)
        Registers a Consumer which is notified about all attribute changes.

        If registered for a specific Thing, it will be notified of all attribute changes of that Thing. Otherwise, it will receive all attribute changes of all Things.

        Example:
         DittoClient client = ...
         ThingHandle myThing = client.twin().forId("myThing");
        
         myThing.registerForAttributeChanges(HANDLER_ID, change -> LOGGER.info("attributeChange received: {}",
         change));
         
        Parameters:
        registrationId - an arbitrary ID provided by the user which can be used to cancel the registration later on. It is required to be unique per DittoClient instance.
        handler - the Consumer to handle attribute change notifications.
        Throws:
        DuplicateRegistrationIdException - if a handler is already registered for the given registrationId.
      • registerForAttributeChanges

        default void registerForAttributeChanges​(java.lang.String registrationId,
                                                 java.lang.CharSequence path,
                                                 java.util.function.Consumer<Change> handler)
        Registers a Consumer which is notified about specific attribute changes.

        If registered for a specific Thing, it will be notified of attribute changes of that Thing. Otherwise, it will receive attribute changes of all Things.

        Example:
         DittoClient client = ...
         ThingHandle myThing = client.twin().forId("myThing");
        
         myThing.registerForAttributeChanges(HANDLER_ID, "address/city",
                  change -> LOGGER.info("attributeChange received: {}", change));
         
        Parameters:
        registrationId - an arbitrary ID provided by the user which can be used to cancel the registration later on. It is required to be unique per DittoClient instance.
        path - the path to the attribute entry of interest - may contain "/" for addressing nested paths in a hierarchy.
        handler - the Consumer to handle attribute change notifications.
        Throws:
        java.lang.IllegalArgumentException - if path is null or empty.
        DuplicateRegistrationIdException - if a handler is already registered for the given registrationId.
      • registerForAttributeChanges

        void registerForAttributeChanges​(java.lang.String registrationId,
                                         org.eclipse.ditto.json.JsonPointer path,
                                         java.util.function.Consumer<Change> handler)
        Registers a Consumer which is notified about specific attribute changes.

        If registered for a specific Thing, it will be notified of attribute changes of that Thing. Otherwise, it will receive attribute changes of all Things.

        Example:
         DittoClient client = ...
         ThingHandle myThing = client.twin().forId("myThing");
        
         myThing.registerForAttributeChanges(HANDLER_ID, JsonFactory.newPointer("address/city"),
                  change -> LOGGER.info("attributeChange received: {}", change));
         
        Parameters:
        registrationId - an arbitrary ID provided by the user which can be used to cancel the registration later on. It is required to be unique per DittoClient instance.
        path - the path to the attribute of interested.
        handler - the Consumer to handle attribute change notifications.
        Throws:
        java.lang.IllegalArgumentException - if path is null or empty.
        DuplicateRegistrationIdException - if a handler is already registered for the given registrationId.