public void addPredecessor(Relationship relationship) { if (relationship.getSuccessor().equals(this)) { relationships.add(relationship); } else { throw new RuntimeException("Relationship is not a predecessor of this task"); } }