private void defineConstructor ( ) { // // declare the constructor MethodDefinition constructor = new MethodDefinition ( a ( PUBLIC ) , "<init>" , type ( void . class ) , parameters . getParameters ( ) ) ; // invoke super (Object) constructor constructor . loadThis ( ) . invokeConstructor ( type ( Object . class ) ) ; // this.foo = foo; for ( FieldDefinition fieldDefinition : parameters . getFields ( ) ) { constructor . loadThis ( ) . loadVariable ( fieldDefinition . getName ( ) ) . putField ( codecType , fieldDefinition ) ; } // return; (implicit) constructor . ret ( ) ; classDefinition . addMethod ( constructor ) ; }
Defines the constructor with a parameter for the ThriftType and the delegate codecs . The constructor simply assigns these parameters to the class fields .