Package com.sun.codemodel

Examples of com.sun.codemodel.JClass


            }
        }
        public void fillInFields(Writer writer, String indent,
                                      String path, String varName,
                                      JDefinedClass tp) throws IOException {
            JClass sp = tp._extends();
            if (sp instanceof JDefinedClass) {
                fillInFields(writer, indent, path, varName, (JDefinedClass)sp);
            }

            Collection<JMethod> methods = tp.methods();
View Full Code Here


    //Sets the href
    addHrefSet( block, targetObject );

    //Sets the values
    for ( FieldWithInitializationInfo fieldInfo : descriptor.getFieldInfos() ) {
      JClass fieldType = getJaxbModelType( fieldInfo.getType() );

      if ( fieldInfo.getSimpleName().equals( ID ) ) {
        continue;
      }

      if ( shallSkip( fieldInfo, objectType ) ) {
        continue;
      }

      JExpression value;
      if ( isProbablyOwnType( fieldInfo.getType() ) ) {
        JClass fieldStubType = getJaxbType( fieldInfo, true );
        JClass fieldJaxbType = getJaxbType( fieldInfo, false );

        if ( TypeUtils.isCollectionType( fieldInfo.getType() ) ) {
          value = codeGenerator.getNewInstanceFactory().createCollectionInvocation( fieldStubType, fieldInfo.getSimpleName(), TypeUtils.isSetType( fieldInfo.getType() ) );
        } else {
          JClass fieldTypeToInstantiate = objectType == this.jaxbStub ? fieldStubType : fieldJaxbType;
          value = codeGenerator.getNewInstanceFactory().create( fieldTypeToInstantiate, fieldInfo.getSimpleName() );
        }
      } else {
        value = codeGenerator.getNewInstanceFactory().create( fieldType, fieldInfo.getSimpleName() );
      }
View Full Code Here

      return codeGenerator.ref( type );
    }

    if ( TypeUtils.isCollectionType( type ) ) {
      TypeMirror collectionParam = TypeUtils.getCollectionParam( type );
      JClass collection = codeGenerator.ref( TypeUtils.getErasure( type ) );

      if ( collectionParam instanceof WildcardType ) {
        return collection.narrow( codeGenerator.ref( getJaxbTypeName( TypeUtils.getErasure( collectionParam ), stub ) ).wildcard() );
      } else {
        return collection.narrow( codeGenerator.ref( getJaxbTypeName( collectionParam, stub ) ) );
      }
    }

    return codeGenerator.ref( getJaxbTypeName( type, stub ) );
  }
View Full Code Here

  private void createJaxbMapping() throws JClassAlreadyExistsException {
    assert jaxbObject != null;
    assert jaxbStub != null;

    JClass objectType = codeGenerator.ref( descriptor.getQualifiedName() );
    JClass superType = codeGenerator.ref( JaxbMapping.class ).narrow( objectType ).narrow( jaxbObject ).narrow( jaxbStub );

    mappingClass = codeGenerator.getModel()._class( getJaxbMappingTypeName() )._extends( superType );

    createHrefMethod();
    createCreateJaxbMethod( jaxbObject, METHOD_NAME_CREATE_JAXB_OBJECT );
View Full Code Here

        continue;
      }

      JInvocation value;
      if ( isProbablyOwnType( fieldInfo.getType() ) ) {
        JClass fieldJaxbType = getJaxbType( fieldInfo, false );
        JClass fieldStubType = getJaxbType( fieldInfo, true );

        if ( isStub || TypeUtils.isCollectionType( fieldInfo.getType() ) ) {
          value = JExpr.invoke( METHOD_NAME_GET_STUB )
            .arg( fieldStubType.dotclass() )
            .arg( getterInvocation )
            .arg( context )
            ;
        } else {
          value = JExpr.invoke( METHOD_NAME_GET )
View Full Code Here

  private void ensureDelegateAvailable( @NotNull JClass fieldJaxbObject, @NotNull JClass fieldJaxbStub ) {
    JMethod constructor = getOrCreateConstructor();

    String paramName = NamingSupport.createVarName( fieldJaxbObject.outer().name() + MAPPING_SUFFIX );

    JClass mappingType = codeGenerator.ref( getMappingNameFor( fieldJaxbObject ) );

    //Check whether the mapping still exists
    for ( JVar param : constructor.listParams() ) {
      if ( param.type().equals( mappingType ) ) {
        return;
View Full Code Here

      NAMESPACE, nsCollection
    );
    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() );
View Full Code Here

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

  }

  @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

  }

  @Nonnull
  @Override
  public JClass generateFieldType( @Nonnull FieldDeclarationInfo fieldInfo ) {
    JClass collectionType = codeGenerator.ref( fieldInfo.getCollectionParam().toString() );
    JClass list = codeGenerator.getModel().ref( List.class );
    return list.narrow( collectionType.wildcard() );
  }
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JClass

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.