Package com.sun.codemodel

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


            }
            if ( !m.getJoinColumn().isEmpty() )
            {
                for ( JoinColumn jc : m.getJoinColumn() )
                {
                    final JAnnotationUse jca = getter.annotate( cm.ref( javax.persistence.JoinColumn.class ) );
                    this.annotate( jca, jc );
                }
            }
            if ( m.getJoinTable() != null )
            {
View Full Code Here


                    this.annotate( jca, jc );
                }
            }
            if ( m.getJoinTable() != null )
            {
                final JAnnotationUse jt = getter.annotate( cm.ref( javax.persistence.JoinTable.class ) );
                this.annotate( cm, jt, m.getJoinTable() );
            }
            if ( m.getMapKey() != null )
            {
                final JAnnotationUse mk = getter.annotate( cm.ref( javax.persistence.MapKey.class ) );
View Full Code Here

    createMappingDataPoint();
  }

  private void createMappingDataPoint() {
    JMethod method = mappingTestClass.method( JMod.STATIC | JMod.PUBLIC, codeGenerator.ref( Entry.class ).narrow( modelType.wildcard() ), DEFAULT_DATA_POINT_NAME );
    method.annotate( codeGenerator.ref( "org.junit.experimental.theories.DataPoint" ) );

    JVar field = method.body().decl( modelType, OBJECT, createDomainObjectCreationExpression() );

    method.body()._return( codeGenerator.ref( AbstractJaxbTest.class ).staticInvoke( METHOD_NAME_CREATE )
      .arg( field )
View Full Code Here

    return invocation;
  }

  private void createCreateMapping() {
    JMethod method = mappingTestClass.method( JMod.PROTECTED, codeGenerator.ref( JaxbMapping.class ).narrow( modelType, jaxbObject, jaxbStub ), "createMapping" );
    method.annotate( Override.class );
    method.body()._return( JExpr._new( mappingType ) );
  }

  private void createJaxbTest() throws JClassAlreadyExistsException {
    jaxbTestClass = codeGenerator.getModel()._class( getJaxbTestClassName() )._extends( codeGenerator.ref( SimpleJaxbTest.class )
View Full Code Here

    createTestResource( jaxbTestClass, identifier );
  }

  private JMethod createDataPointMethod( @NotNull @NonNls String identifier, @NotNull JClass objectType ) {
    JMethod method = jaxbTestClass.method( JMod.STATIC | JMod.PUBLIC, codeGenerator.ref( Entry.class ).narrow( objectType.wildcard() ), identifier );
    method.annotate( codeGenerator.ref( "org.junit.experimental.theories.DataPoint" ) );
    return method;
  }

  @NotNull
  private JVar addJaxbObjectCreation( @NotNull JBlock block, @NotNull JClass objectType ) {
View Full Code Here

    createCopyMethod( "copyFieldsToStub", jaxbStub, true );
  }

  private void createCreateJaxbMethod( @NotNull JClass jaxbType, @NotNull @NonNls String methodName ) {
    JMethod method = mappingClass.method( JMod.PROTECTED, jaxbType, methodName );
    method.annotate( Override.class );

    JVar object = method.param( codeGenerator.ref( descriptor.getQualifiedName() ), OBJECT );
    method.body()._return( JExpr._new( jaxbType ).arg( object.invoke( METHOD_NAME_GET_ID ) ) );
  }
View Full Code Here

    method.body()._return( JExpr._new( jaxbType ).arg( object.invoke( METHOD_NAME_GET_ID ) ) );
  }

  private void createCopyMethod( String methodName, JDefinedClass targetType, boolean stub ) {
    JMethod method = mappingClass.method( JMod.PROTECTED, Void.TYPE, methodName );
    method.annotate( Override.class );

    JVar source = method.param( codeGenerator.ref( descriptor.getQualifiedName() ), "source" );
    JVar target = method.param( targetType, "target" );
    JVar context = method.param( codeGenerator.ref( UriContext.class ), CONTEXT );
View Full Code Here

    assert mappingClass != null;

    JMethod method = mappingClass.method( JMod.PROTECTED, UriBuilder.class, METHOD_NAME_GET_URIS );
    JVar object = method.param( JaxbObject.class, OBJECT );
    JVar context = method.param( UriContext.class, CONTEXT );
    method.annotate( Override.class );

    JFieldVar pathConst = mappingClass.field( JMod.PUBLIC | JMod.STATIC | JMod.FINAL, String.class, CONST_PATH,
                                              JExpr.lit( NamingSupport.plural( NamingSupport.createXmlElementName( getDescriptor().getClassDeclaration().getSimpleName() ) ) ) );
    method.body()._return( context.invoke( METHOD_GET_BASE_URI_BUILDER ).invoke( METHOD_NAME_PATH ).arg( pathConst ).invoke( METHOD_NAME_PATH ).arg( object.invoke( METHOD_NAME_GET_ID ) ) );
  }
View Full Code Here

  private void addGetJaxbType() {
    assert jaxbStub != null;
    assert jaxbObject != null;

    JMethod method = jaxbStub.method( JMod.PUBLIC, codeGenerator.ref( Class.class ).narrow( jaxbObject ), "getJaxbType" );
    method.annotate( Override.class );
    method.body()._return( jaxbObject.dotclass() );
  }

  /**
   * Adds all fields
View Full Code Here

  protected abstract JMethod createConstructor( @NotNull JDefinedClass serializerClass, @NotNull DomainObjectDescriptor domainObjectDescriptor );

  @NotNull
  protected JMethod createSerializeMethodStub( @NotNull JType domainType, @NotNull JDefinedClass serializerClass ) {
    JMethod serializeMethod = serializerClass.method( JMod.PUBLIC, Void.TYPE, METHOD_NAME_SERIALIZE );
    serializeMethod.annotate( Override.class );
    serializeMethod.param( getSerializeToType(), PARAM_NAME_SERIALIZE_TO );
    serializeMethod.param( domainType, VAR_NAME_OBJECT );
    JVar formatVersion = serializeMethod.param( codeGenerator.ref( Version.class ), PARAM_NAME_FORMAT_VERSION );
    serializeMethod._throws( IOException.class )._throws( getExceptionType() );
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.