@Test public void testPositiveComparison() { Literal lhs; Literal rhs; lhs = new Literal(42); rhs = new Literal(42); assertTrue(compare(lhs, rhs, Comparator.EQ)); assertTrue(compare(lhs, rhs, Comparator.GTE)); assertTrue(compare(lhs, rhs, Comparator.LTE)); lhs = new Literal(23); rhs = new Literal(42); assertTrue(compare(lhs, rhs, Comparator.NEQ)); assertTrue(compare(lhs, rhs, Comparator.LT)); assertTrue(compare(lhs, rhs, Comparator.LTE)); lhs = new Literal(42); rhs = new Literal(23); assertTrue(compare(lhs, rhs, Comparator.NEQ)); assertTrue(compare(lhs, rhs, Comparator.GT)); assertTrue(compare(lhs, rhs, Comparator.GTE)); }
private boolean compare(PropertyValue lhsValue, PropertyValue rhsValue) { try { int result = lhsValue.compareTo(rhsValue); return comparison.getComparator() == Comparator.EQ && result == 0 || comparison.getComparator() == Comparator.NEQ && result != 0 || comparison.getComparator() == Comparator.LT && result == -1 || comparison.getComparator() == Comparator.GT && result == 1 || comparison.getComparator() == Comparator.LTE && result <= 0 || comparison.getComparator() == Comparator.GTE && result >= 0; } catch (IllegalArgumentException e) { return comparison.getComparator() == Comparator.NEQ; } }
ComparisonExpression extends QueryPredicate { private boolean compare(PropertyValue lhsValue, PropertyValue rhsValue) { try { int result = lhsValue.compareTo(rhsValue); return comparison.getComparator() == Comparator.EQ && result == 0 || comparison.getComparator() == Comparator.NEQ && result != 0 || comparison.getComparator() == Comparator.LT && result == -1 || comparison.getComparator() == Comparator.GT && result == 1 || comparison.getComparator() == Comparator.LTE && result <= 0 || comparison.getComparator() == Comparator.GTE && result >= 0; } catch (IllegalArgumentException e) { return comparison.getComparator() == Comparator.NEQ; } } }
ComparisonExpression extends QueryPredicate { private boolean compare(PropertyValue lhsValue, PropertyValue rhsValue) { try { int result = lhsValue.compareTo(rhsValue); return comparison.getComparator() == Comparator.EQ && result == 0 || comparison.getComparator() == Comparator.NEQ && result != 0 || comparison.getComparator() == Comparator.LT && result == -1 || comparison.getComparator() == Comparator.GT && result == 1 || comparison.getComparator() == Comparator.LTE && result <= 0 || comparison.getComparator() == Comparator.GTE && result >= 0; } catch (IllegalArgumentException e) { return comparison.getComparator() == Comparator.NEQ; } } ComparisonExpression(Comparison comparison); }
ComparisonExpression extends QueryPredicate { private boolean compare(PropertyValue lhsValue, PropertyValue rhsValue) { try { int result = lhsValue.compareTo(rhsValue); return comparison.getComparator() == Comparator.EQ && result == 0 || comparison.getComparator() == Comparator.NEQ && result != 0 || comparison.getComparator() == Comparator.LT && result == -1 || comparison.getComparator() == Comparator.GT && result == 1 || comparison.getComparator() == Comparator.LTE && result <= 0 || comparison.getComparator() == Comparator.GTE && result >= 0; } catch (IllegalArgumentException e) { return comparison.getComparator() == Comparator.NEQ; } } ComparisonExpression(Comparison comparison); QueryComparable getLhs(); QueryComparable getRhs(); Comparator getComparator(); boolean evaluate(Embedding embedding, EmbeddingMetaData metaData); boolean evaluate(GraphElement element); Set<String> getVariables(); Set<String> getPropertyKeys(String variable); @Override CNF asCNF(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
ComparisonExpression extends QueryPredicate { private boolean compare(PropertyValue lhsValue, PropertyValue rhsValue) { try { int result = lhsValue.compareTo(rhsValue); return comparison.getComparator() == Comparator.EQ && result == 0 || comparison.getComparator() == Comparator.NEQ && result != 0 || comparison.getComparator() == Comparator.LT && result == -1 || comparison.getComparator() == Comparator.GT && result == 1 || comparison.getComparator() == Comparator.LTE && result <= 0 || comparison.getComparator() == Comparator.GTE && result >= 0; } catch (IllegalArgumentException e) { return comparison.getComparator() == Comparator.NEQ; } } ComparisonExpression(Comparison comparison); QueryComparable getLhs(); QueryComparable getRhs(); Comparator getComparator(); boolean evaluate(Embedding embedding, EmbeddingMetaData metaData); boolean evaluate(GraphElement element); Set<String> getVariables(); Set<String> getPropertyKeys(String variable); @Override CNF asCNF(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }