PdxField implements DataSerializable, Comparable<PdxField> { @Override public int hashCode() { int hash = 1; if (fieldName != null) { hash = hash * 31 + fieldName.hashCode(); } if (type != null) { hash = hash * 31 + type.hashCode(); } return hash; } PdxField();  PdxField(String fieldName, int index, int varId, FieldType type, boolean identityField); protected  PdxField(PdxField other); String getFieldName(); int getFieldIndex(); int getVarLenFieldSeqId(); boolean isVariableLengthType(); FieldType getFieldType(); int getRelativeOffset(); void setRelativeOffset(int relativeOffset); int getVlfOffsetIndex(); void setVlfOffsetIndex(int vlfOffsetIndex); void setIdentityField(boolean identityField); boolean isIdentityField(); void setDeleted(boolean v); boolean isDeleted(); @Override void fromData(DataInput in); @Override void toData(DataOutput out); @Override int hashCode(); @Override boolean equals(Object other); @Override String toString(); String getTypeIdString(); @Override int compareTo(PdxField o); void toStream(PrintStream printStream);  }
@Test public void testHashCode() { final PdxField field = new PdxField(FIELD_NAME, FIELD_INDEX, VAR_LEN_FIELD_SEQ_ID, FIELD_TYPE, IDENTITY_FIELD); final PdxField sameFieldNameAndFieldType = new PdxField(FIELD_NAME, FIELD_INDEX + 1, VAR_LEN_FIELD_SEQ_ID + 1, FIELD_TYPE, !IDENTITY_FIELD); assertEquals(field.hashCode(), sameFieldNameAndFieldType.hashCode()); final PdxField differentFieldName = new PdxField("Not " + FIELD_NAME, FIELD_INDEX + 1, VAR_LEN_FIELD_SEQ_ID + 1, FIELD_TYPE, !IDENTITY_FIELD); assertNotEquals(field.hashCode(), differentFieldName.hashCode()); final PdxField differentFieldType = new PdxField(FIELD_NAME, FIELD_INDEX + 1, VAR_LEN_FIELD_SEQ_ID + 1, getAnotherFieldType(FIELD_TYPE), !IDENTITY_FIELD); assertNotEquals(field.hashCode(), differentFieldType.hashCode()); }