if (!_type.equals(other._type)) return false; if (_upper == null)
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (_inclusiveLower ? 1231 : 1237); result = prime * result + (_inclusiveUpper ? 1231 : 1237); result = prime * result + (_lower == null ? 0 : _lower.hashCode()); result = prime * result + (_type == null ? 0 : _type.hashCode()); result = prime * result + (_upper == null ? 0 : _upper.hashCode()); return result; }
if (LineType.CONTINUOUS.equals(t1) || t1.equals(t2)) return Collections.singletonList(this); if (LineType.CONTINUOUS.equals(t2)) during = other; else if (LineType.CONTINUOUS.equals(t2) || t1.equals(t2)) return Collections.singletonList(other); if (LineType.CONTINUOUS.equals(t1)) during = this; else if (LineType.CONTINUOUS.equals(t1) || t1.equals(t2)) return Collections.singletonList(this); if (LineType.CONTINUOUS.equals(t2)) return Collections.singletonList(other); if (LineType.CONTINUOUS.equals(t1) || t1.equals(t2)) return Collections.singletonList(this); if (LineType.CONTINUOUS.equals(t2)) during = other; else if (LineType.CONTINUOUS.equals(t2) || t1.equals(t2)) return Collections.singletonList(other);
if (LineType.CONTINUOUS.equals(t1) || t1.equals(t2)) return Collections.singletonList(this); if (LineType.CONTINUOUS.equals(t2)) during = other; else if (LineType.CONTINUOUS.equals(t2) || t1.equals(t2)) return Collections.singletonList(other); if (LineType.CONTINUOUS.equals(t1)) during = this; else if (LineType.CONTINUOUS.equals(t1) || t1.equals(t2)) return Collections.singletonList(this); if (LineType.CONTINUOUS.equals(t2)) return Collections.singletonList(other); if (LineType.CONTINUOUS.equals(t1) || t1.equals(t2)) return Collections.singletonList(this); if (LineType.CONTINUOUS.equals(t2)) during = other; else if (LineType.CONTINUOUS.equals(t2) || t1.equals(t2)) return Collections.singletonList(other);
boolean inclusiveUpper, inclusiveLower; final LineType intersectionType = _type.intersect(that._type); if (intersectionType == null) return null; case STARTED_BY: if (intersectionType.equals(that._type)) return that; if (intersectionType.equals(_type)) return this; if (intersectionType.equals(_type)) return that; case STARTS: if (intersectionType.equals(_type)) return this; if (LineType.INTEGER_ONLY.equals(intersectionType)) if (LineType.INTEGER_EXCLUDED.equals(intersectionType)) if (lower != null && upper != null && lower.equals(upper) && OWLRealUtils.isInteger(lower)) return null;
boolean inclusiveUpper, inclusiveLower; final LineType intersectionType = _type.intersect(that._type); if (intersectionType == null) return null; case STARTED_BY: if (intersectionType.equals(that._type)) return that; if (intersectionType.equals(_type)) return this; if (intersectionType.equals(_type)) return that; case STARTS: if (intersectionType.equals(_type)) return this; if (LineType.INTEGER_ONLY.equals(intersectionType)) if (LineType.INTEGER_EXCLUDED.equals(intersectionType)) if (lower != null && upper != null && lower.equals(upper) && OWLRealUtils.isInteger(lower)) return null;
if (LineType.INTEGER_ONLY.equals(t1)) if (LineType.INTEGER_EXCLUDED.equals(t2)) return Collections.singletonList(this); if (LineType.INTEGER_EXCLUDED.equals(t1)) if (LineType.INTEGER_ONLY.equals(t2)) return Collections.singletonList(this); if (t1.equals(t2) || LineType.CONTINUOUS.equals(t2)) during = null; else during = new OWLRealInterval(other.getLower(), other.getUpper(), false, false, LineType.INTEGER_EXCLUDED.equals(t2) ? LineType.INTEGER_ONLY : LineType.INTEGER_EXCLUDED); after = new OWLRealInterval(other.getUpper(), getUpper(), !other.inclusiveUpper(), inclusiveUpper(), t1); break; case STARTS: before = null; if (t1.equals(t2) || LineType.CONTINUOUS.equals(t2)) during = null; else during = new OWLRealInterval(getLower(), getUpper(), false, false, LineType.INTEGER_EXCLUDED.equals(t2) ? LineType.INTEGER_ONLY : LineType.INTEGER_EXCLUDED); after = null; break; if (t1.equals(t2) || LineType.CONTINUOUS.equals(t2)) during = null; else during = new OWLRealInterval(other.getLower(), getUpper(), false, false, LineType.INTEGER_EXCLUDED.equals(t2) ? LineType.INTEGER_ONLY : LineType.INTEGER_EXCLUDED);
if (LineType.INTEGER_ONLY.equals(t1)) if (LineType.INTEGER_EXCLUDED.equals(t2)) return Collections.singletonList(this); if (LineType.INTEGER_EXCLUDED.equals(t1)) if (LineType.INTEGER_ONLY.equals(t2)) return Collections.singletonList(this); if (t1.equals(t2) || LineType.CONTINUOUS.equals(t2)) during = null; else during = new OWLRealInterval(other.getLower(), other.getUpper(), false, false, LineType.INTEGER_EXCLUDED.equals(t2) ? LineType.INTEGER_ONLY : LineType.INTEGER_EXCLUDED); after = new OWLRealInterval(other.getUpper(), getUpper(), !other.inclusiveUpper(), inclusiveUpper(), t1); break; case STARTS: before = null; if (t1.equals(t2) || LineType.CONTINUOUS.equals(t2)) during = null; else during = new OWLRealInterval(getLower(), getUpper(), false, false, LineType.INTEGER_EXCLUDED.equals(t2) ? LineType.INTEGER_ONLY : LineType.INTEGER_EXCLUDED); after = null; break; if (t1.equals(t2) || LineType.CONTINUOUS.equals(t2)) during = null; else during = new OWLRealInterval(other.getLower(), getUpper(), false, false, LineType.INTEGER_EXCLUDED.equals(t2) ? LineType.INTEGER_ONLY : LineType.INTEGER_EXCLUDED);
if (!_type.equals(other._type)) return false; if (_upper == null)
if (!i.isPoint() && !i.getType().equals(OWLRealInterval.LineType.INTEGER_ONLY))
if (!i.isPoint() && !i.getType().equals(OWLRealInterval.LineType.INTEGER_ONLY))
return Collections.singletonList(getUpper()).iterator(); else if (LineType.INTEGER_ONLY.equals(getType()))
public boolean contains(final Number n) { if (_type.equals(LineType.INTEGER_ONLY)) { if (!isInteger(n)) return false; } else if (_type.equals(LineType.INTEGER_EXCLUDED)) if (isInteger(n)) return false; int comp; if (boundLower()) { comp = OWLRealUtils.compare(getLower(), n); if (comp > 0) return false; if (comp == 0 && !inclusiveLower()) return false; } if (boundUpper()) { comp = OWLRealUtils.compare(getUpper(), n); if (comp < 0) return false; if (comp == 0 && !inclusiveUpper()) return false; } return true; }
return Collections.singletonList(getUpper()).iterator(); else if (LineType.INTEGER_ONLY.equals(getType()))
public boolean contains(final Number n) { if (_type.equals(LineType.INTEGER_ONLY)) { if (!isInteger(n)) return false; } else if (_type.equals(LineType.INTEGER_EXCLUDED)) if (isInteger(n)) return false; int comp; if (boundLower()) { comp = OWLRealUtils.compare(getLower(), n); if (comp > 0) return false; if (comp == 0 && !inclusiveLower()) return false; } if (boundUpper()) { comp = OWLRealUtils.compare(getUpper(), n); if (comp < 0) return false; if (comp == 0 && !inclusiveUpper()) return false; } return true; }
public LineType intersect(final LineType other) { if (other == null) throw new NullPointerException(); switch (this) { case CONTINUOUS: return other; case INTEGER_ONLY: if (other.equals(INTEGER_EXCLUDED)) return null; else return INTEGER_ONLY; case INTEGER_EXCLUDED: if (other.equals(INTEGER_ONLY)) return null; else return INTEGER_EXCLUDED; default: throw new IllegalArgumentException(); } } }
public LineType intersect(final LineType other) { if (other == null) throw new NullPointerException(); switch (this) { case CONTINUOUS: return other; case INTEGER_ONLY: if (other.equals(INTEGER_EXCLUDED)) return null; else return INTEGER_ONLY; case INTEGER_EXCLUDED: if (other.equals(INTEGER_ONLY)) return null; else return INTEGER_EXCLUDED; default: throw new IllegalArgumentException(); } } }
/** * Verify that for all interval types, if no overlap exists between the bounds an empty intersection is identified */ @Test public void intersectionEmpty() { for (final LineType t : LineType.values()) { final OWLRealInterval a = interval(null, 0, false, true, t); final OWLRealInterval b = interval(1, null, true, false, t); assertNull(a.intersection(b)); assertNull(b.intersection(a)); assertEquals(IntervalRelations.PRECEDES, a.compare(b)); assertEquals(IntervalRelations.PRECEDED_BY, b.compare(a)); } }