1 /* 2 * Copyright (C) 2008 ETH Zurich 3 * 4 * This file is part of Fosstrak (www.fosstrak.org). 5 * 6 * Fosstrak is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License version 2.1, as published by the Free Software Foundation. 9 * 10 * Fosstrak is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with Fosstrak; if not, write to the Free 17 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301 USA 19 */ 20 21 package org.fosstrak.epcis.repository.model; 22 23 import static org.fosstrak.epcis.repository.Utils.eq; 24 import static org.fosstrak.epcis.repository.Utils.hc; 25 26 /** 27 * A base class for vocabulary elements as described in section 6 of the spec. 28 * 29 * @author Sean Wellington 30 */ 31 public abstract class VocabularyElement { 32 33 private Long id; 34 35 private String uri; 36 37 /** 38 * The database id of this vocabulary element. 39 */ 40 public Long getId() { 41 return id; 42 } 43 44 public void setId(Long id) { 45 this.id = id; 46 } 47 48 /** 49 * The URI representation of this vocabulary element. 50 */ 51 public String getUri() { 52 return uri; 53 } 54 55 public void setUri(String uri) { 56 this.uri = uri; 57 } 58 59 @Override 60 public int hashCode() { 61 return hc(uri); 62 } 63 64 @Override 65 public boolean equals(Object o) { 66 if (o instanceof VocabularyElement) { 67 VocabularyElement that = (VocabularyElement) o; 68 return eq(this.uri, that.uri); 69 } else { 70 return false; 71 } 72 } 73 74 /** 75 * The formal name of the vocabulary to which this element belongs. 76 */ 77 public abstract String getVocabularyType(); 78 79 }