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

org.bidib.wizard.api.notification.NodePropertyUpdate Maven / Gradle / Ivy

There is a newer version: 2.0.25
Show newest version
package org.bidib.wizard.api.notification;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.bidib.wizard.api.model.NodeInterface;

public class NodePropertyUpdate {

    private String connectionId;

    private String property;

    private NodeInterface node;

    private final Object value;

    public NodePropertyUpdate(String connectionId, NodeInterface node, String property, Object value) {
        this.connectionId = connectionId;
        this.node = node;
        this.property = property;
        this.value = value;
    }

    public String getConnectionId() {
        return connectionId;
    }

    public String getProperty() {
        return property;
    }

    public void setProperty(String property) {
        this.property = property;
    }

    public NodeInterface getNode() {
        return node;
    }

    public void setNode(NodeInterface node) {
        this.node = node;
    }

    public  T getValue(Class type) {
        // if same type
        if (type.isInstance(value)) {
            return type.cast(value);
        }
        return null;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((connectionId == null) ? 0 : connectionId.hashCode());
        result = prime * result + ((node == null) ? 0 : node.hashCode());
        result = prime * result + ((property == null) ? 0 : property.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        NodePropertyUpdate other = (NodePropertyUpdate) obj;
        if (connectionId == null) {
            if (other.connectionId != null)
                return false;
        }
        else if (!connectionId.equals(other.connectionId))
            return false;
        if (node == null) {
            if (other.node != null)
                return false;
        }
        else if (!node.equals(other.node))
            return false;
        if (!property.equals(other.property))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy