public static FastMessage convert(Group group, FastMessage groupMsg, ConversionContext context) { setNameAndId(group, groupMsg); if (group.getTypeReference() != null && !FastConstants.ANY_TYPE.equals(group.getTypeReference())) { GroupValue typeRef = new GroupValue( (Group) SessionControlProtocol_1_1.TYPE_REF.getField( new QName("TypeRef", SessionControlProtocol_1_1.NAMESPACE))); setName(typeRef, group.getTypeReference()); groupMsg.setFieldValue("TypeRef", typeRef); } SequenceValue instructions = new SequenceValue( SessionControlProtocol_1_1.TEMPLATE_DEFINITION.getSequence("Instructions")); int i = group instanceof MessageTemplate ? 1 : 0; Field[] fields = group.getFieldDefinitions(); for (; i < fields.length; i++) { Field field = fields[i]; FieldInstructionConverter converter = context.getConverter(field); if (converter == null) throw new IllegalStateException("No converter found for type " + field.getClass()); FieldValue value = converter.convert(field, context); instructions.add(new FieldValue[] {value}); } groupMsg.setFieldValue("Instructions", instructions); return groupMsg; }
public GroupValue convert(Field field, ConversionContext context) { Group group = (Group) field; FastMessage groupMsg = convert(group, new FastMessage(SessionControlProtocol_1_1.GROUP_INSTR), context); groupMsg.setBool("Optional", field.isOptional()); return groupMsg; }