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

org.bidib.wizard.dmx.client.model.DmxChannelValue Maven / Gradle / Ivy

The newest version!
package org.bidib.wizard.dmx.client.model;

import java.util.Objects;

import org.apache.commons.lang3.StringUtils;
import org.bidib.jbidibc.core.node.ConfigurationVariable;

public class DmxChannelValue {

    private Integer newValue;

    private final ConfigurationVariable configVar;

    public DmxChannelValue(final ConfigurationVariable configVar) {
        this.configVar = configVar;
    }

    public ConfigurationVariable getConfigVar() {
        return configVar;
    }

    public Integer getValue() {
        return StringUtils.isNotBlank(configVar.getValue()) ? Integer.parseInt(configVar.getValue()) : null;
    }

    public void setNewValue(Integer newValue) {
        this.newValue = newValue;
        // TODO
        // this.configVar.setValueIfDifferent(newValue != null ? Integer.toString(newValue.intValue()) : null);
    }

    public Integer getNewValue() {
        return newValue;
    }

    public Integer getCurrentValue() {
        return newValue != null ? newValue : getValue();
    }

    @Override
    public int hashCode() {
        return Objects.hash(configVar, newValue);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        DmxChannelValue other = (DmxChannelValue) obj;
        return Objects.equals(configVar, other.configVar) && Objects.equals(newValue, other.newValue);
    }

    @Override
    public String toString() {
        // return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
        return "DmxChannelValue, newValue: " + newValue + ", configVar.name: " + configVar.getName()
            + ", configVar.value: " + configVar.getValue();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy