1   package ixa.kaflib;
2   
3   import java.io.Serializable;
4   import java.util.Objects;
5   
6   
7   public class ExternalRef implements Serializable {
8       private String resource;
9       private String reference;
10      private float confidence = -1.0f;
11      private String source = null;
12      private ExternalRef externalRef;
13  
14      public ExternalRef(String resource, String reference) {
15  	this.resource = resource;
16  	this.reference = reference;
17      }
18  
19      public ExternalRef(ExternalRef externalReference) {
20  	this.resource = externalReference.resource;
21  	this.reference = externalReference.reference;
22  	this.confidence = externalReference.confidence;
23          this.source = externalReference.source;
24  	if (externalReference.externalRef != null) {
25  	    this.externalRef = new ExternalRef(externalReference.externalRef);
26  	}
27      }
28  
29      public String getSource() {
30          return source;
31      }
32  
33      public void setSource(String source) {
34          this.source = source;
35      }
36  
37      public String getResource() {
38  	return resource;
39      }
40  
41      public void setResource(String val) {
42  	resource = val;
43      }
44  
45      public String getReference() {
46  	return reference;
47      }
48  
49      public void setReference(String val) {
50  	reference = val;
51      }
52  
53      public boolean hasConfidence() {
54  	return confidence != -1.0;
55      }
56  
57      public float getConfidence() {
58  	return confidence;
59      }
60  
61      public void setConfidence(float val) {
62  	confidence = val;
63      }
64  
65      public boolean hasExternalRef() {
66  	return this.externalRef != null;
67      }
68  
69      public ExternalRef getExternalRef() {
70  	return externalRef;
71      }
72  
73      public void setExternalRef(ExternalRef externalRef) {
74  	this.externalRef = externalRef;
75      }
76      
77      @Override
78      public boolean equals(Object object) {
79          if (object == this) {
80              return true;
81          }
82          if (!(object instanceof ExternalRef)) {
83              return false;
84          }
85          ExternalRef other = (ExternalRef) object;
86          return Objects.equals(resource, other.resource)
87                  && Objects.equals(reference, other.reference) && confidence == other.confidence
88                  && Objects.equals(source, other.source)
89                  && Objects.equals(externalRef, other.externalRef);
90      }
91      
92      @Override
93      public int hashCode() {
94          return Objects.hash(resource, reference, confidence, source, externalRef);
95      }
96  
97      @Override
98      public String toString() {
99          return resource + "=" + reference + " (conf: " + confidence + ", source: " + source + ")";
100     }
101     
102 }