1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package ubic.basecode.ontology.model;
16
17 import javax.annotation.Nullable;
18 import java.io.Serializable;
19 import java.util.Collection;
20 import java.util.Comparator;
21 import java.util.Objects;
22
23
24
25
26
27
28
29 @SuppressWarnings("unused")
30 public class OntologyTermSimple implements OntologyTerm, Serializable {
31
32
33
34
35 private static final long serialVersionUID = -2589717267279872909L;
36
37 private final String description;
38 private final boolean obsolete;
39 private final String term;
40 private final String uri;
41
42 public OntologyTermSimple( String uri, String term ) {
43 this( uri, term, "", false );
44 }
45
46 public OntologyTermSimple( String uri, String term, String description, boolean isObsolete ) {
47 this.uri = uri;
48 this.term = term;
49 this.description = description;
50 this.obsolete = isObsolete;
51 }
52
53 @Override
54 public Collection<String> getAlternativeIds() {
55 throw new UnsupportedOperationException( "Use a OntologyTermImpl" );
56 }
57
58 @Override
59 public Collection<AnnotationProperty> getAnnotations() {
60 throw new UnsupportedOperationException( "Use a OntologyTermImpl" );
61 }
62
63 @Override
64 public Collection<AnnotationProperty> getAnnotations( String propertyUri ) {
65 throw new UnsupportedOperationException( "Use a OntologyTermImpl" );
66 }
67
68 @Nullable
69 @Override
70 public AnnotationProperty getAnnotation( String propertyUri ) {
71 throw new UnsupportedOperationException( "Use a OntologyTermImpl" );
72 }
73
74 @Override
75 public Collection<OntologyTerm> getChildren( boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes ) {
76 throw new UnsupportedOperationException( "Use a OntologyTermImpl" );
77 }
78
79 @Override
80 public String getComment() {
81 return this.description;
82 }
83
84 @Override
85 public Collection<OntologyIndividual> getIndividuals( boolean direct ) {
86 throw new UnsupportedOperationException( "Use a OntologyTermImpl" );
87 }
88
89 @Override
90 public String getLabel() {
91 return term;
92 }
93
94 @Override
95 public String getLocalName() {
96 return term;
97 }
98
99 @Override
100 public Collection<OntologyTerm> getParents( boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes ) {
101 throw new UnsupportedOperationException( "Use a OntologyTermImpl" );
102 }
103
104 @Override
105 public Collection<OntologyRestriction> getRestrictions() {
106 throw new UnsupportedOperationException( "Use a OntologyTermImpl" );
107 }
108
109 @Override
110 public boolean isRoot() {
111 throw new UnsupportedOperationException( "Use a OntologyTermImpl" );
112 }
113
114 @Override
115 public boolean isTermObsolete() {
116 return obsolete;
117 }
118
119 @Override
120 public String getTerm() {
121 return this.term;
122 }
123
124 @Override
125 public String getUri() {
126 return this.uri;
127 }
128
129 @Override
130 public boolean isObsolete() {
131 return obsolete;
132 }
133
134 @Nullable
135 @Override
136 public Double getScore() {
137 return null;
138 }
139
140 @Override
141 public int compareTo( OntologyResource other ) {
142 return Objects.compare( getUri(), other.getUri(), Comparator.nullsLast( Comparator.naturalOrder() ) );
143 }
144
145 @Override
146 public boolean equals( Object obj ) {
147 if ( this == obj ) return true;
148 if ( obj == null ) return false;
149 if ( getClass() != obj.getClass() ) return false;
150 final OntologyResource./ubic/basecode/ontology/model/OntologyResource.html#OntologyResource">OntologyResource other = ( OntologyResource ) obj;
151 if ( getLabel() == null ) {
152 if ( other.getLabel() != null ) return false;
153 } else if ( !getLabel().equals( other.getLabel() ) ) return false;
154 if ( getUri() == null ) {
155 if ( other.getUri() != null ) return false;
156 } else if ( !getUri().equals( other.getUri() ) ) return false;
157 return true;
158 }
159
160 @Override
161 public int hashCode() {
162 return Objects.hash( getLabel(), getUri() );
163 }
164 }