Package com.sun.codemodel

Examples of com.sun.codemodel.JFieldVar


  }

  private void coordinateAddtoCase(final ClassOutlineImpl cc, final JFieldVar field, final CPropertyInfo propertyInfo) {

    final Collection<JFieldVar> coordinateCreateMethods = new ArrayList<JFieldVar>();
    final JFieldVar longitude = classCoordinates.fields().get("longitude");
    final JFieldVar latitude = classCoordinates.fields().get("latitude");

    coordinateCreateMethods.add(longitude);
    coordinateCreateMethods.add(latitude);
    createArgFactoryMethod(cc, coordinateCreateMethods);

    final JFieldVar altitude = classCoordinates.fields().get("altitude");
    coordinateCreateMethods.add(altitude);
    createArgFactoryMethod(cc, coordinateCreateMethods);

    coordinateCreateMethods.clear();
View Full Code Here


    return testClass;
  }

  protected void createVersionsDataPoint( @Nonnull JDefinedClass testClass, @Nonnull JClass serializerClass, @Nonnull JClass domainType, @Nonnull DomainObjectDescriptor domainObjectDescriptor ) {
    JFieldVar field = testClass.field( JMod.STATIC | JMod.PUBLIC | JMod.FINAL, codeGenerator.ref( VersionEntry.class ), DATA_POINT_FIELD_NAME );
    field.annotate( codeGenerator.ref( "org.junit.experimental.theories.DataPoint" ) );

    JInvocation versionInvocation = codeGenerator.ref( Version.class ).staticInvoke( METHOD_NAME_VALUE_OF ).arg( JExpr.lit( 1 ) ).arg( JExpr.lit( 0 ) ).arg( JExpr.lit( 0 ) );
    JExpression expected = createExpectedExpression( testClass, domainType );

    field.init( testClass.staticInvoke( METHOD_NAME_CREATE ).arg( versionInvocation ).arg( expected ) );
  }
View Full Code Here

    return testClass;
  }

  protected void createDataPoint( @Nonnull JDefinedClass testClass, @Nonnull JClass serializerClass, @Nonnull JClass domainType, @Nonnull DomainObjectDescriptor domainObjectDescriptor ) {
    JFieldVar field = testClass.field( JMod.STATIC | JMod.PUBLIC | JMod.FINAL, codeGenerator.ref( Entry.class ).narrow( domainType.wildcard() ), DATA_POINT_FIELD_NAME );
    field.annotate( codeModel.ref( "org.junit.experimental.theories.DataPoint" ) );

    JInvocation domainObjectCreation = createDomainObjectCreationExpression( domainObjectDescriptor );
    JExpression expected = createExpectedExpression( testClass, domainType );

    field.init( testClass.staticInvoke( METHOD_NAME_CREATE ).arg( domainObjectCreation ).arg( expected ) );
  }
View Full Code Here

  }

  @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 );

    JExpression objectAsString = codeGenerator.getParseExpressionFactory().createToStringExpression( codeGenerator.createGetterInvocation( object, fieldInfo ), fieldInfo );
    return serializeTo.invoke( METHOD_NAME_ADD_ATTRIBUTE )
      .arg( constant )
      .arg( objectAsString );
View Full Code Here

  }

  @Nonnull
  @Override
  public JExpression createReadExpression( @Nonnull JDefinedClass serializerClass, @Nonnull JExpression deserializeFrom, @Nonnull JVar formatVersion, @Nonnull FieldDeclarationInfo fieldInfo ) {
    JFieldVar constant = getConstant( serializerClass, fieldInfo );
    return deserializeFrom.invoke( METHOD_NAME_GET_ATTRIBUTE_VALUE ).arg( JExpr._null() ).arg( constant );
  }
View Full Code Here

  @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_COLLECTION )
      .arg( getterInvocation )
View Full Code Here

  @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

  }

  @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 );

    JExpression objectAsString = codeGenerator.getParseExpressionFactory().createToStringExpression( codeGenerator.createGetterInvocation( object, fieldInfo ), fieldInfo );

    return serializeTo.invoke( METHOD_NAME_ADD_ELEMENT_WITH_CHARACTERS )
      .arg( serializeTo.invoke( METHOD_NAME_GET_NAMESPACE ) )
View Full Code Here

  }

  @Nonnull
  @Override
  public JExpression createReadExpression( @Nonnull JDefinedClass serializerClass, @Nonnull JExpression deserializeFrom, @Nonnull JVar formatVersion, @Nonnull FieldDeclarationInfo fieldInfo ) {
    JFieldVar constant = getConstant( serializerClass, fieldInfo );
    return JExpr.invoke( METHOD_NAME_GET_CHILD_TEXT ).arg( deserializeFrom ).arg( constant );
  }
View Full Code Here

    {
        final char[] chars = name.toCharArray();
        chars[0] = Character.toUpperCase( chars[0] );
        final String publicName = String.valueOf( chars );
        final String getterName = ( type == Boolean.TYPE || type == Boolean.class ? "is" : "get" ) + publicName;
        final JFieldVar field = c.implClass.field( JMod.PROTECTED, type, name );
        field.annotate( XmlTransient.class );

        final JMethod getter = c.implClass.method( JMod.PUBLIC, type, getterName );
        getter.body().directStatement( "// " + getMessage( "title" ) );
        getter.body()._return( field );
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JFieldVar

Copyright © 2018 www.massapicom. 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.