/******************************************************************************* * This file is part of Goko. * * Goko is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Goko is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Goko. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ package org.goko.common.elements.combo; /** * A standard value/label item * * @author PsyKo * */ public class LabeledValue<T> implements ILabelledValue<T>{ /** The value */ private T value; /** The label */ private String label; /** * Constructor * @param value * @param label */ public LabeledValue(T value, String label) { this.value = value; this.label = label; } /** * @return the value */ @Override public T getValue() { return value; } /** * @param value the value to set */ public void setValue(T value) { this.value = value; } /** * @return the label */ @Override public String getLabel() { return label; } /** * @param label the label to set */ public void setLabel(String label) { this.label = label; } @Override public String toString() { return label; } /** (inheritDoc) * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((label == null) ? 0 : label.hashCode()); result = prime * result + ((value == null) ? 0 : value.hashCode()); return result; } /** (inheritDoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } LabeledValue other = (LabeledValue) obj; if (label == null) { if (other.label != null) { return false; } } else if (!label.equals(other.label)) { return false; } if (value == null) { if (other.value != null) { return false; } } else if (!value.equals(other.value)) { return false; } return true; } }