/* * Copyright (C) 2014 University of Dundee & Open Microscopy Environment. * All rights reserved. * * This program 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 2 of the License, or * (at your option) any later version. * * This program 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 this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package ome.model.internal; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Embeddable; /** * class to store a single value in an ordered list. */ @Embeddable public class NamedValue implements Serializable, Primitive { private static final long serialVersionUID = 1L; // ~ Constructors // ========================================================================= /** * no-arg constructor to keep Hibernate happy. */ @Deprecated public NamedValue() { // no-op } public NamedValue(String name, String value) { this.name = name; this.value = value; } // ~ Fields // ========================================================================= /** * Key of a map-like entry. */ private String name = null; /** * Value of a map-like entry. */ private String value = null; // ~ Property accessors : used primarily by Hibernate // ========================================================================= @Column(name = "name", nullable = false) public String getName() { return this.name; } @Column(name = "value", nullable = false) public String getValue() { return this.value; } public void setName(String name) { this.name = name; } public void setValue(String value) { this.value = value; } // ~ Java overrides // ========================================================================= @Override public int hashCode() { final int prime = 139; int result = 1; result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((value == null) ? 0 : value.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; NamedValue other = (NamedValue) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (value == null) { if (other.value != null) return false; } else if (!value.equals(other.value)) return false; return true; } @Override public String toString() { return "NamedValue<" + name+ ", " + value+ ">"; } }