private MethodCode getWriteToMethodCode() {
        MethodCode mc = new MethodCode();
        mc.setName("writeTo");
        mc.setReturnType("void");
        mc.setScope(ClassCode.SCOPE_PUBLIC);
        mc.addParameter(ClassHelper.getInternalName(cls.getCanonicalName()), "t");
        mc.addParameter("CodedOutputStream", "output");
        mc.addException("IOException");

        Set<Integer> orders = new HashSet<Integer>();
        for (FieldInfo field : fields) {

            boolean isList = field.isList();

            // check type
            if (!isList) {
                checkType(field.getFieldType(), field.getField());
            }

            if (orders.contains(field.getOrder())) {
                throw new IllegalArgumentException("Field order '" + field.getOrder() + "' on field"
                        + field.getField().getName() + " already exsit.");
            }
            // define field
            mc.appendLineCode0(CodedConstant.getMappedTypeDefined(field.getOrder(), field.getFieldType(),
                    getAccessByField("t", field.getField(), cls), isList));
            if (field.isRequired()) {
                mc.appendLineCode0(CodedConstant.getRequiredCheck(field.getOrder(), field.getField()));
            }
        }

        for (FieldInfo field : fields) {
            boolean isList = field.isList();
            // set write to byte
            mc.appendLineCode0(
                    CodedConstant.getMappedWriteCode(field, "output", field.getOrder(), field.getFieldType(), isList));
        }
        
        mc.appendLineCode1("output.flush()");

        return mc;
    }
private MethodCode getWriteToMethodCode ( ) { MethodCode mc = new MethodCode ( ) ; mc . setName ( "writeTo" ) ; mc . setReturnType ( "void" ) ; mc . setScope ( ClassCode . SCOPE_PUBLIC ) ; mc . addParameter ( ClassHelper . getInternalName ( cls . getCanonicalName ( ) ) , "t" ) ; mc . addParameter ( "CodedOutputStream" , "output" ) ; mc . addException ( "IOException" ) ; Set < Integer > orders = new HashSet < Integer > ( ) ; for ( FieldInfo field : fields ) { boolean isList = field . isList ( ) ; if ( ! isList ) { checkType ( field . getFieldType ( ) , field . getField ( ) ) ; } if ( orders . contains ( field . getOrder ( ) ) ) { throw new IllegalArgumentException ( "Field order '" + field . getOrder ( ) + "' on field" + field . getField ( ) . getName ( ) + " already exsit." ) ; } mc . appendLineCode0 ( CodedConstant . getMappedTypeDefined ( field . getOrder ( ) , field . getFieldType ( ) , getAccessByField ( "t" , field . getField ( ) , cls ) , isList ) ) ; if ( field . isRequired ( ) ) { mc . appendLineCode0 ( CodedConstant . getRequiredCheck ( field . getOrder ( ) , field . getField ( ) ) ) ; } } for ( FieldInfo field : fields ) { boolean isList = field . isList ( ) ; mc . appendLineCode0 ( CodedConstant . getMappedWriteCode ( field , "output" , field . getOrder ( ) , field . getFieldType ( ) , isList ) ) ; } mc . appendLineCode1 ( "output.flush()" ) ; return mc ; }
Gets the write to method code.

@return the write to method code