Java tutorial
/** * Copyright (C) 2008 University of Pittsburgh * * * This file is part of Open EpiCenter * * Open EpiCenter 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. * * Open EpiCenter 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 Open EpiCenter. If not, see <http://www.gnu.org/licenses/>. * * * */ package com.hmsinc.epicenter.webapp.dto; import java.io.Serializable; import org.apache.commons.lang.builder.CompareToBuilder; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import org.directwebremoting.annotations.DataTransferObject; /** * Container object for simple key -> value pairs. * * @author <a href="mailto:steve.kondik@hmsinc.com">Steve Kondik</a> * @version $Id:KeyValueDTO.java 205 2007-09-26 16:52:01Z steve.kondik $ */ @DataTransferObject public class KeyValueDTO implements Serializable, Comparable<KeyValueDTO> { /** * */ private static final long serialVersionUID = -9202080563956521140L; private String id; private String value; private String description; /** * */ public KeyValueDTO() { super(); } /** * @param id * @param value */ public KeyValueDTO(String id, String value) { super(); this.id = id; this.value = value; } /** * @param id * @param value * @param description */ public KeyValueDTO(String id, String value, String description) { super(); this.id = id; this.value = value; this.description = description; } /** * @return the id */ public String getId() { return id; } /** * @param id * the id to set */ public void setId(String id) { this.id = id; } /** * @return the value */ public String getValue() { return value; } /** * @param value * the value to set */ public void setValue(String value) { this.value = value; } /** * @return the description */ public String getDescription() { return description; } /** * @param description * the description to set */ public void setDescription(String description) { this.description = description; } /* * (non-Javadoc) * * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(KeyValueDTO g) { return new CompareToBuilder().append(value, g.getValue()).append(id, g.getId()).toComparison(); } /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return HashCodeBuilder.reflectionHashCode(this); } /* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object o) { return EqualsBuilder.reflectionEquals(this, o); } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { return ToStringBuilder.reflectionToString(this); } }