RelationConstraint { @Override public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + (source == null ? 0 : source.hashCode()); result = PRIME * result + (target == null ? 0 : target.hashCode()); result = PRIME * result + (type == null ? 0 : type.hashCode()); result = PRIME * result + (subType == null ? 0 : subType.hashCode()); result = PRIME * result + (pos == null ? 0 : pos.hashCode()); return result; } RelationConstraint(
      final String type,
      final String subType,
      final String pos,
      final String source,
      final String target); String getSource(); String getTarget(); String getPos(); String getSubType(); String getType(); boolean isValid(); boolean matches(final Relation relation, final boolean symmetric); boolean matches(Interaction interaction, Collection<WordToken> words); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testHashCodeAndEquals() { assertEquals( new RelationConstraint(null, null, null, null, null).hashCode(), new RelationConstraint(null, null, null, null, null).hashCode()); assertEquals( new RelationConstraint("type", "subType", "pos", "source", "target").hashCode(), new RelationConstraint("type", "subType", "pos", "source", "target").hashCode()); assertNotEquals( new RelationConstraint("type", "subType", "pos", "source", "t2").hashCode(), new RelationConstraint("type", "subType", "pos", "source", "target").hashCode()); assertEquals( new RelationConstraint("type", "subType", "pos", "source", "target"), new RelationConstraint("type", "subType", "pos", "source", "target")); assertNotEquals( new RelationConstraint("type", "subType", "pos", "source", "target"), new RelationConstraint("type", "subType2", "pos", "source", "target")); RelationConstraint rc = new RelationConstraint("type", "subType", "pos", "source", "target"); assertEquals(rc, rc); assertNotEquals(rc, null); assertNotEquals(rc, "Hello World"); RelationConstraint rc2 = new RelationConstraint(null, null, null, null, null); assertNotEquals(rc, rc2); assertNotEquals(rc2, rc); rc2 = new RelationConstraint("type", null, null, null, null); assertNotEquals(rc, rc2); assertNotEquals(rc2, rc); rc2 = new RelationConstraint("type", "subType", null, null, null); assertNotEquals(rc, rc2); assertNotEquals(rc2, rc); rc2 = new RelationConstraint("type", "subType", "pos", null, null); assertNotEquals(rc, rc2); assertNotEquals(rc2, rc); rc2 = new RelationConstraint("type", "subType", "pos", "source", null); assertNotEquals(rc, rc2); assertNotEquals(rc2, rc); rc2 = new RelationConstraint("type", "subType", "pos", "source", "target"); assertEquals(rc, rc2); assertEquals(rc2, rc); }