Package com.sun.codemodel

Examples of com.sun.codemodel.JAnnotationUse


            constructor6.varParam(WebServiceFeature.class, "features");
            constructor6.body().directStatement("super(wsdlLocation, serviceName, features);");
        }

        //@WebService
        JAnnotationUse webServiceClientAnn = cls.annotate(cm.ref(WebServiceClient.class));
        writeWebServiceClientAnnotation(service, webServiceClientAnn);

        //@HandlerChain
        writeHandlerConfig(Names.customJavaTypeClassName(service.getJavaInterface()), cls, options);
View Full Code Here


      this.valueObjectFactoryClass = valueObjectFactoryClass;

      String dotClazz = candidateClass.fullName() + ".class";

      for (JMethod method : valueObjectFactoryClass.methods()) {
        JAnnotationUse xmlElementDeclAnnotation = getAnnotation(method, xmlElementDeclModelClass);
        JExpression scope = getAnnotationMemberExpression(xmlElementDeclAnnotation, "scope");

        if (scope == null || !dotClazz.equals(generableToString(scope))) {
          continue;
        }
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) {
          xmlElementWrapperAnnotation.param("name", wrapperXmlName);
        }
        else if (fieldConfiguration.isApplyPluralForm()) {
          xmlElementWrapperAnnotation.param("name", getXsdDeclaration(fieldPropertyInfo).getName());
        }

        JExpression wrapperXmlRequired = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "required");
        if (wrapperXmlRequired != null) {
          xmlElementWrapperAnnotation.param("required", wrapperXmlRequired);
        }

        JExpression wrapperXmlNillable = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "nillable");
        if (wrapperXmlNillable != null) {
          xmlElementWrapperAnnotation.param("nillable", wrapperXmlNillable);
        }

        // Namespace of the wrapper element
        JExpression wrapperXmlNamespace = getAnnotationMemberExpression(xmlElementOriginalAnnotation,
                    "namespace");
        if (wrapperXmlNamespace != null) {
          xmlElementWrapperAnnotation.param("namespace", wrapperXmlNamespace);
        }

        if (xmlElementOriginalAnnotation != null) {
          removeAnnotation(originalImplField, xmlElementOriginalAnnotation);
        }

        boolean xmlElementInfoWasTransferred = false;

        // Transfer @XmlAnyElement, @XmlElementRefs, @XmlElements:
        for (JClass annotationModelClass : new JClass[] { xmlAnyElementModelClass, xmlMixedModelClass,
                xmlElementRefModelClass, xmlElementRefsModelClass, xmlElementsModelClass }) {
          JAnnotationUse annotation = getAnnotation(candidate.getField(), annotationModelClass);

          if (annotation != null) {
            if (candidate.getFieldTargetNamespace() != null) {
              JAnnotationArrayMember annotationArrayMember = (JAnnotationArrayMember) getAnnotationMember(
                          annotation, "value");

              if (annotationArrayMember != null) {
                for (JAnnotationUse subAnnotation : annotationArrayMember.annotations()) {
                  if (getAnnotationMemberExpression(subAnnotation, "namespace") == null) {
                    subAnnotation.param("namespace", candidate.getFieldTargetNamespace());
                  }
                }
              }
            }

            xmlElementInfoWasTransferred = true;

            addAnnotation(originalImplField, annotation);
          }
        }

        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) {
            xmlElementAnnotation.param("name", xmlName);
          }
          else {
            xmlElementAnnotation.param("name", candidate.getFieldName());
          }

          JExpression xmlNamespace = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "namespace");
          if (xmlNamespace != null) {
            xmlElementAnnotation.param("namespace", xmlNamespace);
          }
          else if (candidate.getFieldTargetNamespace() != null) {
            xmlElementAnnotation.param("namespace", candidate.getFieldTargetNamespace());
          }

          JExpression type = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "type");
          if (type != null) {
            xmlElementAnnotation.param("type", type);
          }
        }

        JAnnotationUse adapterAnnotation = getAnnotation(candidate.getField(), xmlJavaTypeAdapterModelClass);

        if (adapterAnnotation != null) {
          addAnnotation(originalImplField, adapterAnnotation);
        }
View Full Code Here

      // First check that such factory method has not yet been created. It can be the case if target class
      // is substituted with e.g. two candidates, each candidate having a field with the same name.
      // FIXME: Could it be the case that these two fields have different namespaces?
      for (JMethod method : factoryClass.methods()) {
        JAnnotationUse xmlElementDeclAnnotation = getAnnotation(method, xmlElementDeclModelClass);

        JExpression scope = getAnnotationMemberExpression(xmlElementDeclAnnotation, "scope");
        JExpression name = getAnnotationMemberExpression(xmlElementDeclAnnotation, "name");

        if (scope != null && dotClazz.equals(generableToString(scope))
View Full Code Here

    public JFieldVar apply(String nodeName, JsonNode node, JFieldVar field, Schema currentSchema) {

        if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations()) {

            if (node.has("minimum")) {
                JAnnotationUse annotation = field.annotate(DecimalMin.class);
                annotation.param("value", node.get("minimum").asText());
            }

            if (node.has("maximum")) {
                JAnnotationUse annotation = field.annotate(DecimalMax.class);
                annotation.param("value", node.get("maximum").asText());
            }

        }

        return field;
View Full Code Here

            }
        }
    }

    private void addGeneratedAnnotation(JDefinedClass jclass) {
        JAnnotationUse generated = jclass.annotate(Generated.class);
        generated.param("value", SchemaMapper.class.getPackage().getName());
    }
View Full Code Here

    public JFieldVar apply(String nodeName, JsonNode node, JFieldVar field, Schema currentSchema) {

        if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations()
                && (node.has("minItems") || node.has("maxItems"))) {

            JAnnotationUse annotation = field.annotate(Size.class);

            if (node.has("minItems")) {
                annotation.param("min", node.get("minItems").asInt());
            }

            if (node.has("maxItems")) {
                annotation.param("max", node.get("maxItems").asInt());
            }
        }

        return field;
    }
View Full Code Here

    @Override
    public JFieldVar apply(String nodeName, JsonNode node, JFieldVar field, Schema currentSchema) {

        if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations()) {
            JAnnotationUse annotation = field.annotate(Pattern.class);
            annotation.param("regexp", node.asText());
        }

        return field;
    }
View Full Code Here

    public JFieldVar apply(String nodeName, JsonNode node, JFieldVar field, Schema currentSchema) {
       
        if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations()
                && (node.has("minLength") || node.has("maxLength"))) {

            JAnnotationUse annotation = field.annotate(Size.class);

            if (node.has("minLength")) {
                annotation.param("min", node.get("minLength").asInt());
            }

            if (node.has("maxLength")) {
                annotation.param("max", node.get("maxLength").asInt());
            }
        }

        return field;
    }
View Full Code Here

      JFieldVar field = clazz.field(JMod.PRIVATE, type, realVariableName);
     
      if (xmlTransient == false)
      {
         // define XmlElement annotation for variable
         JAnnotationUse annotation = field.annotate(XmlElement.class);
         annotation.param("name", name.getLocalPart());
         if (name.getNamespaceURI() != null)
         {
            annotation.param("namespace", name.getNamespaceURI());
         }
      }
      else
      {
         //XmlTransient
         field.annotate(XmlTransient.class);
      }
     
      if (xmlList)
      {
         field.annotate(XmlList.class);
      }
     
      if (adapter != null)
      {
         JAnnotationUse xmlJavaTypeAdapter = field.annotate(XmlJavaTypeAdapter.class);
         xmlJavaTypeAdapter.param("value", codeModel.ref(adapter));
      }

      // generate acessor get method for variable
      JMethod method = clazz.method(JMod.PUBLIC, type, getterPrefix(javaType) + JavaUtils.capitalize(variable));
      method.body()._return(JExpr._this().ref(realVariableName));
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JAnnotationUse

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.