Examples of JAnnotationUse


Examples of com.sun.codemodel.JAnnotationUse

    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

Examples of com.sun.codemodel.JAnnotationUse

            }
        }
    }

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

Examples of com.sun.codemodel.JAnnotationUse

    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

Examples of com.sun.codemodel.JAnnotationUse

    @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

Examples of com.sun.codemodel.JAnnotationUse

    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

Examples of com.sun.codemodel.JAnnotationUse

      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

Examples of com.sun.codemodel.JAnnotationUse

      JFieldVar field = clazz.field(JMod.PRIVATE, javaType, 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
View Full Code Here

Examples of com.sun.codemodel.JAnnotationUse

   }

   private static void addClassAnnotations(JDefinedClass clazz, QName xmlName, QName xmlType, String[] propertyOrder)
   {
      // define XmlRootElement class annotation
      JAnnotationUse xmlRootElementAnnotation = clazz.annotate(XmlRootElement.class);
      xmlRootElementAnnotation.param("name", xmlName.getLocalPart());
      String xmlNameNS = xmlName.getNamespaceURI();
      if (xmlNameNS != null && xmlNameNS.length() > 0)
      {
         xmlRootElementAnnotation.param("namespace", xmlNameNS);
      }

      // define XmlType class annotation
      JAnnotationUse xmlTypeAnnotation = clazz.annotate(XmlType.class);
      xmlTypeAnnotation.param("name", xmlType.getLocalPart());
      String xmlTypeNS = xmlType.getNamespaceURI();
      if (xmlTypeNS != null && xmlTypeNS.length() > 0)
      {
         xmlTypeAnnotation.param("namespace", xmlTypeNS);
      }
      if (propertyOrder != null)
      {
         JAnnotationArrayMember paramArray = xmlTypeAnnotation.paramArray("propOrder");
         for (String property : propertyOrder)
         {
            paramArray.param(property);
         }
      }

      // define XmlAccessorType class annotation
      JAnnotationUse xmlAccessorTypeAnnotation = clazz.annotate(XmlAccessorType.class);
      xmlAccessorTypeAnnotation.param("value", XmlAccessType.FIELD);
   }
View Full Code Here

Examples of com.sun.codemodel.JAnnotationUse

        }

        List<XSFacet> patternList = simpleType.getFacets(FACET_PATTERN);
        if (patternList.size() > 1) {
            if (notAnnotated(fieldVar, patternListAnn)) {
                JAnnotationUse list = fieldVar.annotate(patternListAnn);
                JAnnotationArrayMember listValue = list.paramArray("value");

                for (XSFacet xsFacet : patternList)
                    // If corresponds to <xsd:restriction base="xsd:string">.
                    if ("String".equals(fieldType.name()))
                        a.put(listValue.annotate(patternAnn).param("regexp", eliminateShorthands(xsFacet.getValue().value)), FacetType.pattern);
View Full Code Here

Examples of com.sun.codemodel.JAnnotationUse

                case assertTrue: customizeAnnotation(fieldVar.annotate(assertTrueAnn), c); continue;
                case future: customizeAnnotation(fieldVar.annotate(futureAnn), c); continue;
                case past: customizeAnnotation(fieldVar.annotate(pastAnn), c); continue;
                }
            } catch (IllegalArgumentException programmingByException) {
                JAnnotationUse annotationUse = fieldVar.annotate(codeModel.ref(c.type));
                if (!c.value.equals("")) annotationUse.param("value", c.value);
                customizeAnnotation(annotationUse, c); continue;
            }
            customizeRegularAnnotations(a, c);
        }
    }
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.