View Javadoc

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  
25  import java.io.Serializable;
26  
27  /**
28   * A base class for vocabulary attribute elements.
29   * 
30   * @author Nikos Kefalakis (nkef)
31   */
32  public abstract class VocabularyAttributeElement implements Serializable {
33  
34  	/**
35  	 * 
36  	 */
37  	private static final long serialVersionUID = -3825662827697962041L;
38  	
39  	private String privateID;
40  	private String value;
41  	private VocabularyAttrCiD vocabularyAttrCiD;
42  
43  
44  	public VocabularyAttributeElement() {
45  		this.privateID = java.util.UUID.randomUUID().toString();
46  	}
47  
48  	public int hashCode() {
49  		return privateID.hashCode();
50  	}
51  
52  	public String getValue() {
53  		return value;
54  	}
55  
56  	public void setValue(String value) {
57  		this.value = value;
58  	}
59  
60  	public VocabularyAttrCiD getVocabularyAttrCiD() {
61  		return vocabularyAttrCiD;
62  	}
63  
64  	public void setVocabularyAttrCiD(VocabularyAttrCiD vocabularyAttrCiD) {
65  		this.vocabularyAttrCiD = vocabularyAttrCiD;
66  	}
67  
68  	@Override
69  	public boolean equals(Object o) {
70  		if (o instanceof VocabularyAttributeElement) {
71  			VocabularyAttributeElement that = (VocabularyAttributeElement) o;
72  			return eq(this.value, that.value) && eq(this.vocabularyAttrCiD, that.vocabularyAttrCiD);
73  		}
74  		else {
75  			return false;
76  		}
77  	}
78  
79  	/**
80  	 * The formal name of the vocabulary to which this element belongs.
81  	 */
82  	public abstract String getVocabularyType();
83  
84  }