ValueComparator implements Comparator<Value> { @Override public int compare(Value o1, Value o2) { if (o1 == o2) { return 0; } if (o1 == null) { return -1; } if (o2 == null) { return 1; } boolean b1 = o1 instanceof BNode; boolean b2 = o2 instanceof BNode; if (b1 && b2) { return compareBNodes((BNode) o1, (BNode) o2); } if (b1) { return -1; } if (b2) { return 1; } boolean iri1 = o1 instanceof IRI; boolean iri2 = o2 instanceof IRI; if (iri1 && iri2) { return compareURIs((IRI) o1, (IRI) o2); } if (iri1) { return -1; } if (iri2) { return 1; } boolean l1 = o1 instanceof Literal; boolean l2 = o2 instanceof Literal; if (l1 && l2) { return compareLiterals((Literal) o1, (Literal) o2); } if (l1) { return -1; } if (l2) { return 1; } return compareTriples((Triple) o1, (Triple) o2); }  @Override int compare(Value o1, Value o2); void setStrict(boolean flag); boolean isStrict();  }
@Test public void testBothNull() throws Exception { assertTrue(cmp.compare(null, null) == 0); }
@Test public void testLeftNull() throws Exception { assertTrue(cmp.compare(null, typed1) < 0); }
@Test public void testRightNull() throws Exception { assertTrue(cmp.compare(typed1, null) > 0); }
@Test public void testBothBnode() throws Exception { assertTrue(cmp.compare(bnode1, bnode1) == 0); assertTrue(cmp.compare(bnode2, bnode2) == 0); assertTrue(cmp.compare(bnode1, bnode2) != cmp.compare(bnode2, bnode1)); assertTrue(cmp.compare(bnode1, bnode2) == -1 * cmp.compare(bnode2, bnode1)); }
@Test public void testLeftBnode() throws Exception { assertTrue(cmp.compare(bnode1, typed1) < 0); }
@Test public void testRightBnode() throws Exception { assertTrue(cmp.compare(typed1, bnode1) > 0); }
@Test public void testBothURI() throws Exception { assertTrue(cmp.compare(uri1, uri1) == 0); assertTrue(cmp.compare(uri1, uri2) < 0); assertTrue(cmp.compare(uri1, uri3) < 0); assertTrue(cmp.compare(uri2, uri1) > 0); assertTrue(cmp.compare(uri2, uri2) == 0); assertTrue(cmp.compare(uri2, uri3) < 0); assertTrue(cmp.compare(uri3, uri1) > 0); assertTrue(cmp.compare(uri3, uri2) > 0); assertTrue(cmp.compare(uri3, uri3) == 0); }
@Test public void testLeftURI() throws Exception { assertTrue(cmp.compare(uri1, typed1) < 0); }
@Test public void testRightURI() throws Exception { assertTrue(cmp.compare(typed1, uri1) > 0); }