@Test public void validateHashCode() { EntityReference reference1 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI))); EntityReference reference2 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI))); EntityReference reference3 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki2", EntityType.WIKI))); EntityReference reference4 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space2", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI))); EntityReference reference5 = new EntityReference("page2", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI))); EntityReference reference6 = new EntityReference("page", EntityType.DOCUMENT); Map<String, Serializable> map = getParamMap(3); EntityReference reference7 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI)), map); EntityReference reference8 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI)), map); EntityReference reference9 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI), map)); EntityReference reference10 = new EntityReference("page", EntityType.DOCUMENT, new EntityReference("space", EntityType.SPACE, new EntityReference("wiki", EntityType.WIKI, null, map))); assertEquals(reference1.hashCode(), reference1.hashCode()); assertEquals(reference1.hashCode(), reference2.hashCode()); assertFalse(reference1.hashCode() == reference3.hashCode()); assertFalse(reference1.hashCode() == reference4.hashCode()); assertFalse(reference1.hashCode() == reference5.hashCode()); assertFalse(reference1.hashCode() == reference6.hashCode()); assertEquals(reference6.hashCode(), new EntityReference("page", EntityType.DOCUMENT).hashCode()); assertFalse(reference1.hashCode() == reference7.hashCode()); assertEquals(reference7.hashCode(), reference8.hashCode()); assertFalse(reference1.hashCode() == reference9.hashCode()); assertFalse(reference7.hashCode() == reference9.hashCode()); assertFalse(reference1.hashCode() == reference10.hashCode()); assertFalse(reference7.hashCode() == reference10.hashCode()); }
@Override public int hashCode() { return new HashCodeBuilder(3, 17).append(getName()).append(getType()).append(getParent()) .append(this.parameters).toHashCode(); }
EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { @Override public int hashCode() { return new HashCodeBuilder(3, 17).append(getName()).append(getType()).append(getParent()) .append(this.parameters).toHashCode(); } }
EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { @Override public int hashCode() { return new HashCodeBuilder(3, 17).append(getName()).append(getType()).append(getParent()) .append(this.parameters).toHashCode(); } EntityReference(EntityReference reference);  EntityReference(EntityReference reference, EntityReference parent); protected  EntityReference(EntityReference reference, EntityReference oldReference, EntityReference newReference);  EntityReference(String name, EntityType type);  EntityReference(String name, EntityType type, EntityReference parent); @Unstable  EntityReference(String name, EntityType type, Map<String, Serializable> parameters);  EntityReference(String name, EntityType type, EntityReference parent, Map<String, Serializable> parameters); @Unstable  EntityReference(EntityReference reference, Map<String, Serializable> parameters); }
EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { @Override public int hashCode() { return new HashCodeBuilder(3, 17).append(getName()).append(getType()).append(getParent()) .append(this.parameters).toHashCode(); } EntityReference(EntityReference reference);  EntityReference(EntityReference reference, EntityReference parent); protected  EntityReference(EntityReference reference, EntityReference oldReference, EntityReference newReference);  EntityReference(String name, EntityType type);  EntityReference(String name, EntityType type, EntityReference parent); @Unstable  EntityReference(String name, EntityType type, Map<String, Serializable> parameters);  EntityReference(String name, EntityType type, EntityReference parent, Map<String, Serializable> parameters); @Unstable  EntityReference(EntityReference reference, Map<String, Serializable> parameters); final String getName(); final EntityReference getParent(); final EntityType getType(); final Map<String, Serializable> getParameters(); @Transient EntityReference getRoot(); @Transient List<EntityReference> getReversedReferenceChain(); int size(); EntityReference extractReference(EntityType type); EntityReference extractFirstReference(EntityType type); EntityReference replaceParent(EntityReference oldParent, EntityReference newParent); EntityReference replaceParent(EntityReference newParent); EntityReference appendParent(EntityReference newParent); EntityReference removeParent(EntityReference oldParent); boolean hasParent(EntityReference expectedParent); @Override String toString(); @Override boolean equals(Object obj); boolean equals(EntityReference otherReference, EntityType to); boolean equals(EntityReference otherReference, EntityType from, EntityType to); boolean equalsNonRecursive(EntityReference otherReference); @Override int hashCode(); @Override int compareTo(EntityReference reference); }
EntityReference implements Serializable, Cloneable, Comparable<EntityReference> { @Override public int hashCode() { return new HashCodeBuilder(3, 17).append(getName()).append(getType()).append(getParent()) .append(this.parameters).toHashCode(); } EntityReference(EntityReference reference);  EntityReference(EntityReference reference, EntityReference parent); protected  EntityReference(EntityReference reference, EntityReference oldReference, EntityReference newReference);  EntityReference(String name, EntityType type);  EntityReference(String name, EntityType type, EntityReference parent); @Unstable  EntityReference(String name, EntityType type, Map<String, Serializable> parameters);  EntityReference(String name, EntityType type, EntityReference parent, Map<String, Serializable> parameters); @Unstable  EntityReference(EntityReference reference, Map<String, Serializable> parameters); final String getName(); final EntityReference getParent(); final EntityType getType(); final Map<String, Serializable> getParameters(); @Transient EntityReference getRoot(); @Transient List<EntityReference> getReversedReferenceChain(); int size(); EntityReference extractReference(EntityType type); EntityReference extractFirstReference(EntityType type); EntityReference replaceParent(EntityReference oldParent, EntityReference newParent); EntityReference replaceParent(EntityReference newParent); EntityReference appendParent(EntityReference newParent); EntityReference removeParent(EntityReference oldParent); boolean hasParent(EntityReference expectedParent); @Override String toString(); @Override boolean equals(Object obj); boolean equals(EntityReference otherReference, EntityType to); boolean equals(EntityReference otherReference, EntityType from, EntityType to); boolean equalsNonRecursive(EntityReference otherReference); @Override int hashCode(); @Override int compareTo(EntityReference reference);  }