
org.bidib.wizard.api.model.NodeProvider Maven / Gradle / Ivy
package org.bidib.wizard.api.model;
import java.util.Collection;
import java.util.List;
import java.util.function.Predicate;
import org.bidib.jbidibc.messages.enums.ClassIdEnum;
import org.bidib.wizard.api.event.FirmwareRepoRefreshedEvent;
import org.bidib.wizard.api.notification.NodePropertyUpdate;
import org.bidib.wizard.api.notification.NodeUpdate;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
/**
* The {@code NodeProvider} contains the registry of nodes of the connection.
*/
public interface NodeProvider {
/**
* Subscribe to changes of node list.
*
* @param observer
* observer
*/
void subscribeNodeListChanges(Observer observer);
/**
* Subscribe to changes of node list.
*
* @param consumer
* consumer
*/
Disposable subscribeNodeListChanges(Consumer consumer, Consumer onError);
/**
* Subscribe to changes of node list and provide a consumer that receives the registered nodes when the observer is
* subscribed.
*
* @param observer
* observer
* @param doOnSubcribe
* the consumer called during subscribe of the onserver
*/
void subscribeNodeListChanges(Observer observer, Consumer> doOnSubcribe);
/**
* Subscribe to changes of properties of the nodes.
*
* @param onNext
* the data consumer
* @param onError
* the error consumer
* @return the disposable
*/
Disposable subscribeNodePropertyChanges(Consumer onNext, Consumer onError);
/**
* Get the nodes.
*
* @return the nodes
*/
Collection getNodes();
/**
* Clear the cached nodes.
*/
void clearNodes();
/**
* Clear the cached nodes of the rootNode.
*/
void clearSubNodesOfRootNode();
/**
* Add a node to the list of nodes.
*
* @param node
* the new node to add
*/
void nodeAdded(final NodeInterface node);
/**
* Remove a node from the list of nodes.
*
* @param removedNodes
* the removed nodes
*/
void nodesRemoved(final List removedNodes);
/**
* Check if the node is registered
*
* @param node
* the node
* @return {@code true} if node is registered, {@code false} otherwise
*/
boolean isNodeRegistered(final NodeInterface node);
/**
* Check if the node is registered
*
* @param node
* the node
* @param predicate
* the predicate to compare the nodes
* @return {@code true} if node is registered, {@code false} otherwise
*/
boolean isNodeRegistered(final NodeInterface node, final Predicate predicate);
/**
* Find a node by the uniqueId.
*
* @param uniqueId
* the unique id
* @return the node of {@code null} if no matching node found
*/
NodeInterface findNodeByUniqueId(long uniqueId);
/**
* Find a node by the uniqueId without the class (first 2 bytes).
*
* @param uniqueId
* the unique id without the class (first 2 bytes)
* @return the node of {@code null} if no matching node found
*/
NodeInterface findNodeByUniqueIdWithoutClass(byte[] uniqueId);
/**
* Find a node by the current address.
*
* @param address
* the address
* @return the node of {@code null} if no matching node found
*/
NodeInterface findNodeByAddress(byte[] address);
/**
* Find a subnodes by the node.
*
* @param node
* the node
* @return the subNodes of the node
*/
List findSubNodes(NodeInterface node);
/**
* Find nodes in system that have the provided class bits set.
*
* @param classId
* the classId
* @return the list of nodes
*/
List findNodesByClass(ClassIdEnum classId);
/**
* Handle the firmware repo refreshed event. This is used to notify the nodes that new firmware might be available.
*
* @param event
* the event
*/
void handleFirmwareRepoRefreshedEvent(final FirmwareRepoRefreshedEvent event);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy