4e6bad912beb58079031797f8139ded8a12148ae
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / ref / EntityReference.java
1 /**
2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.cdm.ref;
10
11 import java.util.UUID;
12
13 import org.apache.commons.lang.builder.HashCodeBuilder;
14
15 /**
16 * @author a.kohlbecker
17 */
18 public class EntityReference {
19 UUID uuid;
20 String label;
21
22 public EntityReference(UUID uuid, String label) {
23 this.uuid = uuid;
24 this.label = label;
25 }
26
27
28 public UUID getUuid() {
29 return uuid;
30 }
31
32 public String getLabel() {
33 return label;
34 }
35
36 /**
37 * {@inheritDoc}
38 */
39 @Override
40 public int hashCode() {
41 return new HashCodeBuilder(17, 31)
42 .append(label)
43 .append(uuid)
44 .toHashCode();
45 }
46
47 /**
48 * {@inheritDoc}
49 */
50 @Override
51 public boolean equals(Object obj) {
52 try {
53 EntityReference other = (EntityReference) obj;
54 return uuid.equals(other.uuid) && label.equals(other.label);
55
56 } catch (Exception e) {
57 return false;
58 }
59 }
60
61 }