PdxType implements DataSerializable { public boolean compatible(PdxType other) { if (other == null) return false; if (!getClassName().equals(other.getClassName())) { return false; } Collection<PdxField> myFields = getSortedFields(); Collection<PdxField> otherFields = other.getSortedFields(); return myFields.equals(otherFields); } PdxType();  PdxType(String name, boolean expectDomainClass);  PdxType(PdxType copy); @Override void fromData(DataInput in); @Override void toData(DataOutput out); @Override int hashCode(); @Override boolean equals(Object other); boolean compatible(PdxType other); int getVariableLengthFieldCount(); String getClassName(); boolean getNoDomainClass(); void setNoDomainClass(boolean noDomainClass); int getTypeId(); int getDSId(); int getTypeNum(); void setTypeId(int tId); void setClassName(String className); void addField(PdxField ft); void initialize(PdxWriterImpl writer); PdxField getPdxField(String fieldName); List<PdxField> getFields(); PdxField getPdxFieldByIndex(int index); int getFieldCount(); int getUndeletedFieldCount(); String toFormattedString(); String toString(); List<Integer> getUnreadFieldIndexes(List<String> readFields); boolean hasExtraFields(PdxType other); SortedSet<PdxField> getSortedIdentityFields(); Collection<PdxField> getSortedFields(); List<String> getFieldNames(); void setAutoInfo(AutoClassInfo autoClassInfo); AutoClassInfo getAutoInfo(Class<?> c); void toStream(PrintStream printStream, boolean printFields); boolean getHasDeletedField(); void setHasDeletedField(boolean b);  }
@Test public void testCompatible() { final PdxType type = new PdxType(TYPE_NAME, EXPECT_DOMAIN_CLASS); type.addField(FIELD_4); type.addField(FIELD_0); type.addField(FIELD_1); assertTrue(type.compatible(type)); assertFalse(type.compatible(null)); final PdxType sameTypeNameAndFields = new PdxType(TYPE_NAME, EXPECT_DOMAIN_CLASS); sameTypeNameAndFields.addField(FIELD_4); sameTypeNameAndFields.addField(FIELD_0); sameTypeNameAndFields.addField(FIELD_1); assertTrue(type.compatible(sameTypeNameAndFields)); final PdxType sameTypeNameAndFieldsDifferentDomain = new PdxType(TYPE_NAME, !EXPECT_DOMAIN_CLASS); sameTypeNameAndFieldsDifferentDomain.addField(FIELD_4); sameTypeNameAndFieldsDifferentDomain.addField(FIELD_0); sameTypeNameAndFieldsDifferentDomain.addField(FIELD_1); assertTrue(type.compatible(sameTypeNameAndFieldsDifferentDomain)); final PdxType sameTypeNameAndDifferentFields = new PdxType(TYPE_NAME, EXPECT_DOMAIN_CLASS); sameTypeNameAndDifferentFields.addField(FIELD_3); sameTypeNameAndDifferentFields.addField(FIELD_2); sameTypeNameAndDifferentFields.addField(FIELD_1); assertFalse(type.compatible(sameTypeNameAndDifferentFields)); final PdxType sameTypeNameAndFieldsInDifferentOrder = new PdxType(TYPE_NAME, EXPECT_DOMAIN_CLASS); sameTypeNameAndFieldsInDifferentOrder.addField(FIELD_1); sameTypeNameAndFieldsInDifferentOrder.addField(FIELD_0); sameTypeNameAndFieldsInDifferentOrder.addField(FIELD_4); assertTrue(type.compatible(sameTypeNameAndFieldsInDifferentOrder)); }