Package com.sun.codemodel

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


  @NotNull
  protected JMethod createDeserializeMethodStub( @NotNull JType domainType, @NotNull JDefinedClass serializerClass ) {
    JMethod deserializeMethod = serializerClass.method( JMod.PUBLIC, domainType, METHOD_NAME_DESERIALIZE );
    deserializeMethod.param( getSerializeFromType(), METHOD_NAME_DESERIALIZE_FROM );
    deserializeMethod.param( Version.class, PARAM_NAME_FORMAT_VERSION );
    deserializeMethod.annotate( Override.class );
    deserializeMethod._throws( IOException.class )._throws( VersionException.class )._throws( getExceptionType() );

    for ( Decorator decorator : codeGenerator.getDecorators() ) {
      if ( decorator instanceof GeneratorDecorator ) {
        ( ( GeneratorDecorator ) decorator ).decorateDeserializeMethod( codeGenerator, domainType, serializerClass, deserializeMethod );
View Full Code Here


    JClass versionRef = codeModel.ref( Version.class );

    JClass returnType = codeModel.ref( Map.class ).narrow( versionRef.wildcard(), codeModel.ref( String.class ).wildcard() );

    JMethod method = testClass.method( JMod.PROTECTED, returnType, METHOD_NAME_GET_SERIALIZED_XML );
    method.annotate( Override.class );

    JClass mapType = codeModel.ref( Map.class ).narrow( Version.class, String.class );
    JClass hashMapType = codeModel.ref( HashMap.class ).narrow( Version.class, String.class );

    JVar map = method.body().decl( mapType, "map", JExpr._new( hashMapType ) );
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 );
    serializeMethod._throws( IOException.class )._throws( getExceptionType() );

    for ( Decorator decorator : codeGenerator.getMethodDecorators() ) {
View Full Code Here

  @Override
  @NotNull
  protected JMethod createVerifyMethod( @NotNull JDefinedClass serializerTestClass, @NotNull JClass serializerClass, @NotNull JClass domainType ) {
    JClass returnType = codeModel.ref( List.class ).narrow( codeModel.ref( String.class ).wildcard() );
    JMethod method = serializerTestClass.method( JMod.PROTECTED, returnType, METHOD_NAME_GET_EXPECTED_SERIALIZED );
    method.annotate( Override.class );


    JInvocation asListInvocation = codeModel.ref( Arrays.class ).staticInvoke( "asList" );
    for ( int i = 0; i < NUMBER_OF_OBJECTS; i++ ) {
      asListInvocation.arg( JExpr.lit( "<implementMe/>" ) );
View Full Code Here

  @NotNull
  protected JMethod createDeserializeMethodStub( @NotNull JType domainType, @NotNull JDefinedClass serializerClass ) {
    JMethod deserializeMethod = serializerClass.method( JMod.PUBLIC, domainType, METHOD_NAME_DESERIALIZE );
    deserializeMethod.param( getSerializeFromType(), METHOD_NAME_DESERIALIZE_FROM );
    deserializeMethod.param( Version.class, PARAM_NAME_FORMAT_VERSION );
    deserializeMethod.annotate( Override.class );
    deserializeMethod._throws( IOException.class )._throws( VersionException.class )._throws( getExceptionType() );

    for ( Decorator decorator : codeGenerator.getMethodDecorators() ) {
      if ( decorator instanceof GeneratorDecorator ) {
        ( ( GeneratorDecorator ) decorator ).decorateDeserializeMethod( codeGenerator, domainType, serializerClass, deserializeMethod );
View Full Code Here

  protected void createVersionVerifyMethod( @NotNull JDefinedClass testClass, @NotNull JClass serializerClass, @NotNull DomainObjectDescriptor domainObjectDescriptor ) {
    JClass domainType = codeGenerator.ref( domainObjectDescriptor.getQualifiedName() );

    JMethod method = testClass.method( JMod.PROTECTED, Void.TYPE, METHOD_NAME_VERIFY_DESERIALIZED )._throws( Exception.class );
    method.annotate( Override.class );
    JVar deserialized = method.param( domainType, PARAM_NAME_DESERIALIZED );
    method.param( Version.class, PARAM_NAME_VERSION );

    JClass assertClass = codeGenerator.ref( "org.testng.Assert" );
View Full Code Here

  @NotNull
  protected JMethod createCreateObjectsToSerializeMethod( @NotNull DomainObjectDescriptor domainObjectDescriptor, @NotNull JDefinedClass serializerTestClass, @NotNull JClass serializerClass, @NotNull JClass domainType ) {
    JClass returnType = codeModel.ref( Iterable.class ).narrow( domainType.wildcard() );

    JMethod method = serializerTestClass.method( JMod.PROTECTED, returnType, METHOD_NAME_CREATE_OBJECT_TO_SERIALIZE )._throws( Exception.class );
    method.annotate( Override.class );

    JInvocation asListInvocation = codeModel.ref( Arrays.class ).staticInvoke( "asList" );
    for ( int i = 0; i < NUMBER_OF_OBJECTS; i++ ) {
      asListInvocation.arg( createDomainObjectCreationExpression( domainObjectDescriptor ) );
    }
View Full Code Here

  @NotNull
  protected JMethod createGetSerializerMethod( @NotNull JDefinedClass serializerTestClass, @NotNull JClass serializerClass, @NotNull JClass domainType ) {
    JType returnType = codeModel.ref( Serializer.class ).narrow( domainType );
    JMethod createSerializerMethod = serializerTestClass.method( JMod.PROTECTED, returnType, METHOD_NAME_GET_SERIALIZER )._throws( Exception.class );
    createSerializerMethod.annotate( Override.class );

    //Return the serializer
    createSerializerMethod.body()._return( JExpr._new( serializerClass ) );

    return createSerializerMethod;
View Full Code Here

        toStringMethod.body()._return(invoke);
       
        JDocComment doc = toStringMethod.javadoc();
        doc.add("Generates a String representation of the contents of this type.");
        doc.add("\nThis is an extension method, produced by the 'ts' xjc plugin");
        toStringMethod.annotate(Override.class);
    }
}
View Full Code Here

        toStringMethod.body()._return(invoke);
       
        JDocComment doc = toStringMethod.javadoc();
        doc.add("Generates a String representation of the contents of this type.");
        doc.add("\nThis is an extension method, produced by the 'ts' xjc plugin");
        toStringMethod.annotate(Override.class);
    }
}
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.