MessageComponent extends FieldMap { public void copyFrom(FieldMap fields) { try { for (int componentField : getFields()) { if (fields.isSetField(componentField)) { setField(componentField, fields.getField(componentField)); } } for (int groupField : getGroupFields()) { if (fields.isSetField(groupField)) { setField(groupField, fields.getField(groupField)); setGroups(groupField, fields.getGroups(groupField)); } } } catch (FieldNotFound e) { } } protected  MessageComponent(); protected  MessageComponent(int[] fieldOrder); void copyFrom(FieldMap fields); void copyTo(FieldMap fields);  }
@Test public void shouldNotCopyCustomTagsFromComponent() throws FieldNotFound { Instrument instrument1 = new Instrument(); instrument1.set(new Symbol("EURUSD")); instrument1.set(new Product(Product.CURRENCY)); instrument1.set(new SecurityType(SecurityType.FOREIGN_EXCHANGE_CONTRACT)); instrument1.setString(12345, "ABC"); instrument1.setInt(54321, 0xCAFE); assertEquals("EURUSD", instrument1.getSymbol().getValue()); assertEquals(Product.CURRENCY, instrument1.getProduct().getValue()); assertEquals(SecurityType.FOREIGN_EXCHANGE_CONTRACT, instrument1.getSecurityType().getValue()); assertEquals("ABC", instrument1.getString(12345)); assertEquals(0xCAFE, instrument1.getInt(54321)); Instrument instrument2 = new Instrument(); instrument2.copyFrom(instrument1); assertEquals("EURUSD", instrument2.getSymbol().getValue()); assertEquals(Product.CURRENCY, instrument2.getProduct().getValue()); assertEquals(SecurityType.FOREIGN_EXCHANGE_CONTRACT, instrument2.getSecurityType().getValue()); assertFalse(instrument2.isSetField(12345)); assertFalse(instrument2.isSetField(54321)); }