1919package ubic .basecode .ontology .jena ;
2020
2121import com .hp .hpl .jena .ontology .OntResource ;
22- import com .hp .hpl .jena .rdf .model .Resource ;
2322import com .hp .hpl .jena .vocabulary .OWL2 ;
2423import org .slf4j .Logger ;
2524import org .slf4j .LoggerFactory ;
2625import ubic .basecode .ontology .model .OntologyResource ;
2726
27+ import javax .annotation .Nullable ;
2828import java .util .Comparator ;
2929import java .util .Objects ;
3030
31+ import static java .util .Comparator .*;
32+
3133/**
3234 * @author pavlidis
3335 */
@@ -37,10 +39,22 @@ public abstract class AbstractOntologyResource implements OntologyResource {
3739
3840 private static final long serialVersionUID = 1L ;
3941
42+ private static final Comparator <OntologyResource > comparator = Comparator
43+ .comparing ( OntologyResource ::getScore , nullsLast ( reverseOrder () ) )
44+ .thenComparing ( OntologyResource ::getUri , nullsLast ( naturalOrder () ) );
45+
4046 private transient final OntResource res ;
47+ @ Nullable
48+ private final Double score ;
4149
4250 protected AbstractOntologyResource ( OntResource resource ) {
4351 this .res = resource ;
52+ this .score = null ;
53+ }
54+
55+ public AbstractOntologyResource ( OntResource resource , double score ) {
56+ this .res = resource ;
57+ this .score = score ;
4458 }
4559
4660 @ Override
@@ -67,9 +81,15 @@ public boolean isObsolete() {
6781 return res .hasLiteral ( OWL2 .deprecated , true );
6882 }
6983
84+ @ Override
85+ @ Nullable
86+ public Double getScore () {
87+ return score ;
88+ }
89+
7090 @ Override
7191 public int compareTo ( OntologyResource other ) {
72- return Objects .compare ( getUri () , other . getUri (), Comparator . nullsLast ( Comparator . naturalOrder () ) );
92+ return Objects .compare ( this , other , comparator );
7393 }
7494
7595 @ Override
0 commit comments