public Hypothesis subsume(Hypothesis otherHypothesis) { LinkedList<Literal> newLiterals = new LinkedList<Literal>(); for (Literal otherLiteral : otherHypothesis.literalMap.values()) { Literal correspondingLiteral = literalMap.get(otherLiteral.getAttribute()); if (correspondingLiteral == null) { continue; } if (otherLiteral.equals(correspondingLiteral)) { newLiterals.add(otherLiteral); continue; } if (otherLiteral.contradicts(literalMap.get(otherLiteral.getAttribute()))) { return null; } } return new Hypothesis(newLiterals); }
@Override public boolean equals(Object object) { if (object == null) { return false; } if (getClass() != object.getClass()) { return false; } Hypothesis otherHypothesis = (Hypothesis) object; for (Literal literal : getLiterals()) { if (!literal.equals(otherHypothesis.getLiteral(literal.getAttribute()))) { return false; } } return true; }
public Hypothesis(Collection<Literal> literals) { this(); for (Literal literal : literals) { literalMap.put(literal.getAttribute(), literal); } }