@Test public void testCompareTo$differentInstancesSameVocabulary() throws Exception { V v=new V(); ImmutableTerm term1 = new ImmutableTerm(v,"termA"); V v2=new V(); ImmutableTerm term2 = new ImmutableTerm(v2,"termA"); try { term1.compareTo(term2); fail("Should not be able to compare between different instances of the same vocabulary"); } catch(ClassCastException e) { } }
@Override public int compareTo(Term other) { ImmutableTerm self = this; if(self.getDeclaringVocabulary() != other.getDeclaringVocabulary()) { throw new ClassCastException(); } return self.ordinal - other.ordinal(); }
ImmutableTerm implements Term { @Override public int compareTo(Term other) { ImmutableTerm self = this; if(self.getDeclaringVocabulary() != other.getDeclaringVocabulary()) { throw new ClassCastException(); } return self.ordinal - other.ordinal(); } }
ImmutableTerm implements Term { @Override public int compareTo(Term other) { ImmutableTerm self = this; if(self.getDeclaringVocabulary() != other.getDeclaringVocabulary()) { throw new ClassCastException(); } return self.ordinal - other.ordinal(); } ImmutableTerm(AbstractImmutableVocabulary<? extends ImmutableTerm> vocabulary, String entityName); }
ImmutableTerm implements Term { @Override public int compareTo(Term other) { ImmutableTerm self = this; if(self.getDeclaringVocabulary() != other.getDeclaringVocabulary()) { throw new ClassCastException(); } return self.ordinal - other.ordinal(); } ImmutableTerm(AbstractImmutableVocabulary<? extends ImmutableTerm> vocabulary, String entityName); @Override final int ordinal(); @Override final String name(); @Override final String entityName(); @Override final String qualifiedEntityName(); @Override final Vocabulary getDeclaringVocabulary(); @Override V as(Class<? extends V> valueClass); @Override final boolean equals(Object other); @Override final int hashCode(); @Override String toString(); @Override int compareTo(Term other); }
ImmutableTerm implements Term { @Override public int compareTo(Term other) { ImmutableTerm self = this; if(self.getDeclaringVocabulary() != other.getDeclaringVocabulary()) { throw new ClassCastException(); } return self.ordinal - other.ordinal(); } ImmutableTerm(AbstractImmutableVocabulary<? extends ImmutableTerm> vocabulary, String entityName); @Override final int ordinal(); @Override final String name(); @Override final String entityName(); @Override final String qualifiedEntityName(); @Override final Vocabulary getDeclaringVocabulary(); @Override V as(Class<? extends V> valueClass); @Override final boolean equals(Object other); @Override final int hashCode(); @Override String toString(); @Override int compareTo(Term other);  }