PdxType implements DataSerializable { public void addField(PdxField ft) { if (this.fieldsMap.put(ft.getFieldName(), ft) != null) { throw new PdxFieldAlreadyExistsException( "The field \"" + ft.getFieldName() + "\" already exists."); } this.fields.add(ft); } 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 testAddField() { final PdxType type = new PdxType(TYPE_NAME, EXPECT_DOMAIN_CLASS); assertEquals(0, type.getFieldCount()); type.addField(FIELD_4); type.addField(FIELD_0); type.addField(FIELD_1); assertEquals(3, type.getFieldCount()); final List<PdxField> fields = type.getFields(); assertTrue(fields.contains(FIELD_0)); assertTrue(fields.contains(FIELD_1)); assertFalse(fields.contains(FIELD_2)); assertFalse(fields.contains(FIELD_3)); assertTrue(fields.contains(FIELD_4)); }