All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bidib.wizard.api.model.event.NodeStatusEvent Maven / Gradle / Ivy

The newest version!
package org.bidib.wizard.api.model.event;

import org.bidib.jbidibc.messages.utils.ByteUtils;

public class NodeStatusEvent implements NodeEvent {

    public enum StatusIdentifier {
        InitialLoadPending, InitialLoadRegistered, InitialLoadPartiallyFinished, InitialLoadFinished;
    }

    private final String connectionId;

    private final String nodeAddress;

    private final long uniqueId;

    private final StatusIdentifier statusIdentifier;

    public NodeStatusEvent(String connectionId, long uniqueId, final String nodeAddress,
        StatusIdentifier statusIdentifier) {
        this.connectionId = connectionId;
        this.uniqueId = uniqueId;
        this.nodeAddress = nodeAddress;
        this.statusIdentifier = statusIdentifier;
    }

    @Override
    public String getConnectionId() {
        return connectionId;
    }

    @Override
    public long getUniqueId() {
        return uniqueId;
    }

    /**
     * @return the node address
     */
    public String getNodeAddress() {
        return nodeAddress;
    }

    /**
     * @return the statusIdentifier
     */
    public StatusIdentifier getStatusIdentifier() {
        return statusIdentifier;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("NodeStatusEvent[");
        sb.append("connectionId=").append(connectionId);
        sb.append(",uniqueId=").append(ByteUtils.getUniqueIdAsString(uniqueId));
        sb.append(",nodeAddress=").append(nodeAddress);
        sb.append(",statusIdentifier=").append(statusIdentifier);

        return sb.toString();
    }

    public static boolean isConfigNotLoadedStatus(StatusIdentifier statusIdentifier) {
        if (StatusIdentifier.InitialLoadPending == statusIdentifier
            || StatusIdentifier.InitialLoadRegistered == statusIdentifier) {
            return true;
        }
        return false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy