Package com.sun.codemodel

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


        if(ei.getDefaultValue()!=null)
            xemw.defaultValue(ei.getDefaultValue());

        if(ei.getProperty().inlineBinaryData())
            m.annotate(XmlInlineBinaryData.class);

                    // if the element is adapter, put that annotation on the factory method
        outline.generateAdapterIfNecessary(ei.getProperty(),m);
    }
View Full Code Here


  }

  private static void overrideCopierMethod(JDefinedClass templateClass, String methodName)
  {
    JMethod copierMethod = templateClass.method(JMod.PUBLIC, templateClass, methodName);
    copierMethod.annotate(Override.class);
    copierMethod._throws(CloneNotSupportedException.class);
    copierMethod.body()._return(JExpr.cast(templateClass, JExpr._super().invoke(methodName)));
  }

  /**
 
View Full Code Here

                JMethod getFooEndpoint = servCls.method(JMod.PUBLIC, serviceIntf, javify("get" + endpoint.getName().getLocalPart()));
                JBlock geBody = getFooEndpoint.body();
   
                geBody._return(JExpr.cast(serviceIntf, JExpr.direct("this").invoke("getPort").arg(newQN).arg(intfClass)));
               
                JAnnotationUse weAnn = getFooEndpoint.annotate(WebEndpoint.class);
                weAnn.param("name", endpoint.getName().getLocalPart());
               
                staticBlock.add(portsVar.invoke("put").arg(newQN).arg(intfClass));
            }
        }
View Full Code Here

      JClass wrapperType = codeModel.ref(JAXBElement.class).narrow(info.type);

      JMethod method = factoryClass.method(JMod.PUBLIC, wrapperType, methodName.toString());

      method.annotate(xmlElementDeclModelClass).param("namespace", info.namespace).param("name", info.name)
                  .param("scope", targetClass);

      // FIXME: Make a try to load constants and (a) rename it appropriately (b) use it?
      JInvocation qname = JExpr._new(codeModel.ref(QName.class)).arg(info.namespace).arg(info.name);
View Full Code Here

        JBlock body = toString.body();

        body._return(JExpr._this().ref(valueField));

        ruleFactory.getAnnotator().enumValueMethod(toString);
        toString.annotate(Override.class);
    }

    private void addEnumConstants(JsonNode node, JDefinedClass _enum) {
        for (Iterator<JsonNode> values = node.elements(); values.hasNext();) {
            JsonNode value = values.next();
View Full Code Here

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

  @Nonnull
  protected JMethod createSerializeMethodStub( @Nonnull JType domainType, @Nonnull 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( ( Class ) getExceptionType() );
View Full Code Here

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

    deserializeMethod.body().invoke( "verifyVersionReadable" ).arg( formatVersion );

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

  protected void createVersionVerifyMethod( @Nonnull JDefinedClass testClass, @Nonnull JClass serializerClass, @Nonnull 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( CLASS_NAME_ASSERT );
View Full Code Here

  @Nonnull
  protected JMethod createGetSerializerMethod( @Nonnull JDefinedClass serializerTestClass, @Nonnull JClass serializerClass, @Nonnull JClass domainType ) {
    JType returnType = codeGenerator.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

  private static void processFields(String packetName, List<PacketFieldType> fields, JDefinedClass packetClass, JCodeModel codeModel, boolean fromClient) throws JClassAlreadyExistsException {
    AtomicInteger numberOfUnknowns = new AtomicInteger();
    JClass arrays = codeModel.ref(Arrays.class);
    JClass stringBuilder = codeModel.ref(StringBuilder.class);
    JMethod toStringMethod = packetClass.method(JMod.PUBLIC, String.class, "toString");
    toStringMethod.annotate(Override.class);
    JBlock toStringMethodBody = toStringMethod.body();
    JVar stringBuilderVar = toStringMethodBody.decl(stringBuilder, "sb");
    stringBuilderVar = stringBuilderVar.init(JExpr._new(stringBuilder).arg(packetName + "["));
    JInvocation appendChain = null;
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.