Package com.sun.codemodel

Examples of com.sun.codemodel.JFieldVar.annotate()


      if (field == null) {
        classOutline.implClass.annotate(Deprecated.class);
        LOG.info("       1YY>>" + string);
      } else {
        final JFieldVar jFieldVar = classOutline.implClass.fields().get(field);
        jFieldVar.annotate(Deprecated.class);
        LOG.info("       1YY>>" + string + "#" + field);
      }
    }
  }
}
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

        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

        // Getter.
        final String lineSeparator = System.getProperty( "line.separator" );
        final JFieldVar field = f.parent().implClass.field( JMod.PROTECTED, f.parent().parent().getCodeModel().ref(
            "java.util.Calendar" ), "jpa" + f.getPropertyInfo().getName( true ) );

        field.annotate( XmlTransient.class );

        final JMethod getter =
            f.parent().implClass.method( JMod.PUBLIC, f.parent().parent().getCodeModel().ref( Calendar.class ),
                                         "getJpa" + f.getPropertyInfo().getName( true ) );
View Full Code Here

    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
View Full Code Here

      //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

          // GENERATED CODE: ... fieldName = new C<T>();
          originalImplField.init(JExpr._new(collectionImplClass));
        }

        // Annotate the field with the @XmlElementWrapper annotation using the original field name.
        JAnnotationUse xmlElementWrapperAnnotation = originalImplField.annotate(xmlElementWrapperModelClass);
        JAnnotationUse xmlElementOriginalAnnotation = getAnnotation(originalImplField, xmlElementModelClass);

        // xmlElementOriginalAnnotation can be null:
        JExpression wrapperXmlName = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "name");
        if (wrapperXmlName != null) {
View Full Code Here

        if (!xmlElementInfoWasTransferred) {
          // Annotate the field with the @XmlElement annotation using the field name from the wrapped type as name.
          // We cannot just re-use the same annotation object instance, as for example, we need to set XML name and this
          // will impact the candidate field annotation in case candidate is unmarked from removal.
          JAnnotationUse xmlElementAnnotation = originalImplField.annotate(xmlElementModelClass);
          xmlElementOriginalAnnotation = getAnnotation(candidate.getField(), xmlElementModelClass);

          // xmlElementOriginalAnnotation can be null:
          JExpression xmlName = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "name");
          if (xmlName != null) {
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

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.