Examples of JFieldVar


Examples of com.sun.codemodel.JFieldVar

    );
    jaxbCollection.annotate( XmlAccessorType.class ).param( VALUE, XmlAccessType.FIELD );


    JClass stubsListType = codeGenerator.ref( List.class ).narrow( jaxbStub );
    JFieldVar stubsField = jaxbCollection.field( JMod.PRIVATE, stubsListType, pluralName );
    stubsField.annotate( XmlElementRef.class );

    addGetter( jaxbCollection, stubsListType, stubsField, stubsField.name() );
    addSetter( jaxbCollection, stubsListType, stubsField, stubsField.name() );

    //Add constructors
    jaxbCollection.constructor( JMod.PUBLIC );

    {
      JMethod constructor = jaxbCollection.constructor( JMod.PUBLIC );
      JVar stubsParam = constructor.param( stubsListType, stubsField.name() );
      constructor.body().invoke( "this" ).arg( stubsParam ).arg( JExpr.lit( 0 ) ).arg( JExpr.lit( 0 ) );
    }

    {
      JMethod constructor = jaxbCollection.constructor( JMod.PUBLIC );
      JVar stubsParam = constructor.param( stubsListType, stubsField.name() );
      JVar startIndex = constructor.param( Integer.TYPE, "startIndex" );
      JVar maxLength = constructor.param( Integer.TYPE, "maxLength" );
      constructor.body().invoke( "super" ).arg( startIndex ).arg( maxLength );

      constructor.body().assign( JExpr.refthis( stubsField.name() ), stubsParam );
    }
  }
View Full Code Here

Examples of com.sun.codemodel.JFieldVar

      boolean isCollectionType = TypeUtils.isCollectionType( fieldInfo.getType() );

      //If it is a collection --> always create a stub
      //And for stubs also create stubs, otherwise create a "real" object
      JClass fieldType = getJaxbModelType( fieldInfo.getType(), isCollectionType || type == Scope.STUB );
      JFieldVar field = addField( currentClass, fieldType, fieldInfo );

      if ( isCollectionType ) {
        JAnnotationUse annotation = field.annotate( XmlElement.class );
        annotation.param( "name", NamingSupport.createSingular( field.name() ) );
      }

      addGetter( currentClass, fieldType, field, fieldInfo.getSimpleName() );
      addSetter( currentClass, fieldType, field, fieldInfo.getSimpleName() );
    }
View Full Code Here

Examples of com.sun.codemodel.JFieldVar

  @Override
  @Nonnull
  public JInvocation createAddToSerializeToExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression serializeTo, @Nonnull FieldDeclarationInfo fieldInfo, @Nonnull JVar object, JVar formatVersion ) {
    generator.addDelegatingSerializerToConstructor( serializerClass, codeGenerator.ref( TypeUtils.getErasure( fieldInfo.getCollectionParam() ).toString() ) );

    JFieldVar constant = getConstant( serializerClass, fieldInfo );

    JInvocation getterInvocation = codeGenerator.createGetterInvocation( object, fieldInfo );

    return JExpr.invoke( METHOD_NAME_SERIALIZE )
      .arg( getterInvocation )
View Full Code Here

Examples of com.sun.codemodel.JFieldVar

  @Override
  @Nonnull
  public Expressions createReadFromDeserializeFromExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression deserializeFrom, JVar wrapper, @Nonnull JVar formatVersion, @Nonnull FieldDeclarationInfo fieldInfo ) {
    JClass collectionParamType = codeGenerator.ref( fieldInfo.getCollectionParam().toString() );
    JFieldVar constant = getConstant( serializerClass, fieldInfo );

    JInvocation expression = JExpr.invoke( METHOD_NAME_DESERIALIZE ).arg( JExpr.dotclass( collectionParamType ) ).arg( constant ).arg( deserializeFrom ).arg( formatVersion );
    return new Expressions( expression );
  }
View Full Code Here

Examples of com.sun.codemodel.JFieldVar

  }

  @Override
  @Nonnull
  public JInvocation createAddToSerializeToExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression serializeTo, @Nonnull FieldDeclarationInfo fieldInfo, @Nonnull JVar object, JVar formatVersion ) {
    JFieldVar constant = getConstant( serializerClass, fieldInfo );

    JInvocation getter = codeGenerator.createGetterInvocation( object, fieldInfo );

    if ( fieldInfo.isType( String.class ) ) {
      return serializeTo.invoke( "writeStringField" )
View Full Code Here

Examples of com.sun.codemodel.JFieldVar

  @Nonnull
  @Override
  public Expressions createReadFromDeserializeFromExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression deserializeFrom, @Nullable JVar wrapper, @Nonnull JVar formatVersion, @Nonnull FieldDeclarationInfo fieldInfo ) {
    assert wrapper != null;

    JFieldVar constant = getConstant( serializerClass, fieldInfo );
    JStatement nextFieldStatement = wrapper.invoke( "nextFieldValue" ).arg( constant );

    JExpression readExpression = createReadExpression( serializerClass, deserializeFrom, formatVersion, fieldInfo );
    return new Expressions( readExpression, nextFieldStatement );
  }
View Full Code Here

Examples of com.sun.codemodel.JFieldVar

  @Override
  public JStatement createAddToSerializeToExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression serializeTo, @Nonnull FieldDeclarationInfo fieldInfo, @Nonnull JVar object, JVar formatVersion ) {
    //Add serializer to constructor
    generator.addDelegatingSerializerToConstructor( serializerClass, codeGenerator.ref( TypeUtils.getErasure( fieldInfo.getType() ).toString() ) );

    JFieldVar constant = getConstant( serializerClass, fieldInfo );

    JExpression getterInvocation = codeGenerator.createGetterInvocation( object, fieldInfo );

    return JExpr.invoke( METHOD_NAME_SERIALIZE )
      .arg( getterInvocation )
View Full Code Here

Examples of com.sun.codemodel.JFieldVar

  }

  @Nonnull
  @Override
  public Expressions createReadFromDeserializeFromExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression deserializeFrom, JVar wrapper, @Nonnull JVar formatVersion, @Nonnull FieldDeclarationInfo fieldInfo ) {
    JFieldVar constant = getConstant( serializerClass, fieldInfo );

    JClass type = codeGenerator.ref( TypeUtils.getErasure( fieldInfo.getType() ).toString() );
    JInvocation expression = JExpr.invoke( METHOD_NAME_DESERIALIZE ).arg( JExpr.dotclass( type ) ).arg( constant ).arg( formatVersion ).arg( deserializeFrom );
    return new Expressions( expression );
  }
View Full Code Here

Examples of com.sun.codemodel.JFieldVar

  @Override
  @Nonnull
  public JInvocation createAddToSerializeToExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression serializeTo, @Nonnull FieldDeclarationInfo fieldInfo, @Nonnull JVar object, JVar formatVersion ) {
    generator.addDelegatingSerializerToConstructor( serializerClass, codeGenerator.ref( TypeUtils.getErasure( fieldInfo.getCollectionParam() ).toString() ) );

    JFieldVar constant = getConstant( serializerClass, fieldInfo );

    JInvocation getterInvocation = codeGenerator.createGetterInvocation( object, fieldInfo );

    return JExpr.invoke( METHOD_NAME_SERIALIZE )
      .arg( getterInvocation )
View Full Code Here

Examples of com.sun.codemodel.JFieldVar

  @Override
  @Nonnull
  public Expressions createReadFromDeserializeFromExpression( @Nonnull AbstractGenerator<?> generator, @Nonnull JDefinedClass serializerClass, @Nonnull JExpression deserializeFrom, JVar wrapper, @Nonnull JVar formatVersion, @Nonnull FieldDeclarationInfo fieldInfo ) {
    JClass collectionParamType = codeGenerator.ref( fieldInfo.getCollectionParam().toString() );
    JFieldVar constant = getConstant( serializerClass, fieldInfo );

    JInvocation expression = JExpr.invoke( METHOD_NAME_DESERIALIZE ).arg( JExpr.dotclass( collectionParamType ) ).arg( constant ).arg( deserializeFrom ).arg( formatVersion );
    return new Expressions( expression );
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.