RuleAttribute.java

package com.tradecloud.domain.model.organisationalunit;

import com.tradecloud.common.base.PersistenceBase;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;

/**
 * Rule attribute.
 * Example: rate_source - STANDARD_RATES
 */

@Entity
@Table(name = "ruleattribute")
@XmlAccessorType(XmlAccessType.FIELD)
public class RuleAttribute extends PersistenceBase {

    @XmlAttribute
    String code;
    @XmlAttribute
    String value;

    private static final long serialVersionUID = 1L;

    public RuleAttribute() {

    }

    public RuleAttribute(String code, String value) {
        this.code = code;
        this.value = value;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String name) {
        this.code = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("code=").append(code).append(",value=").append(value);
        return sb.toString();
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result + ((code == null) ? 0 : code.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (!super.equals(obj))
            return false;
        if (getClass() != obj.getClass())
            return false;
        RuleAttribute other = (RuleAttribute) obj;
        if (code == null) {
            if (other.code != null)
                return false;
        } else if (!code.equals(other.code))
            return false;
        return true;
    }
}