Java Code Examples for com.sun.codemodel.JAnnotationArrayMember#param()
The following examples show how to use
com.sun.codemodel.JAnnotationArrayMember#param() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImplementationBuilder.java From aem-component-generator with Apache License 2.0 | 6 votes |
private void addSlingAnnotations(JDefinedClass jDefinedClass, JClass adapterClass, String resourceType) { JAnnotationUse jAUse = jDefinedClass.annotate(codeModel.ref(Model.class)); JAnnotationArrayMember adaptablesArray = jAUse.paramArray("adaptables"); for (String adaptable : adaptables) { if ("resource".equalsIgnoreCase(adaptable)) { adaptablesArray.param(codeModel.ref(Resource.class)); } if ("request".equalsIgnoreCase(adaptable)) { adaptablesArray.param(codeModel.ref(SlingHttpServletRequest.class)); } } if (this.isAllowExporting) { jAUse.paramArray("adapters").param(adapterClass).param(codeModel.ref(ComponentExporter.class)); } else { jAUse.param("adapters", adapterClass); } if (StringUtils.isNotBlank(resourceType)) { jAUse.param("resourceType", resourceType); } if (this.isAllowExporting) { jAUse = jDefinedClass.annotate(codeModel.ref(Exporter.class)); jAUse.param("name", codeModel.ref(ExporterConstants.class).staticRef(SLING_MODEL_EXPORTER_NAME)); jAUse.param("extensions", codeModel.ref(ExporterConstants.class).staticRef(SLING_MODEL_EXTENSION)); } }
Example 2
Source File: ImmutableJaxbGenerator.java From rice with Educational Community License v2.0 | 5 votes |
private void renderClassLevelAnnotations(JDefinedClass classModel, List<FieldModel> fields) throws Exception { JFieldRef constantsClass = classModel.staticRef(Util.CONSTANTS_CLASS_NAME); JFieldRef elementsClass = classModel.staticRef(Util.ELEMENTS_CLASS_NAME); JClass coreConstants = codeModel.ref(CoreConstants.class); JFieldRef commonElementsRef = coreConstants.staticRef("CommonElements"); // XmlRootElement JAnnotationUse rootElementAnnotation = classModel.annotate(XmlRootElement.class); rootElementAnnotation.param("name", constantsClass.ref(Util.ROOT_ELEMENT_NAME_FIELD)); // XmlAccessorType JAnnotationUse xmlAccessorTypeAnnotation = classModel.annotate(XmlAccessorType.class); xmlAccessorTypeAnnotation.param("value", XmlAccessType.NONE); // XmlType JAnnotationUse xmlTypeAnnotation = classModel.annotate(XmlType.class); xmlTypeAnnotation.param("name", constantsClass.ref(Util.TYPE_NAME_FIELD)); JAnnotationArrayMember propOrderMember = xmlTypeAnnotation.paramArray("propOrder"); for (FieldModel field : fields) { if (Util.isCommonElement(field.fieldName)) { propOrderMember.param(commonElementsRef.ref(Util.toConstantsVariable(field.fieldName))); } else { propOrderMember.param(elementsClass.ref(Util.toConstantsVariable(field.fieldName))); } } propOrderMember.param(commonElementsRef.ref("FUTURE_ELEMENTS")); }
Example 3
Source File: KubernetesCoreTypeAnnotator.java From kubernetes-client with Apache License 2.0 | 4 votes |
@Override public void propertyOrder(JDefinedClass clazz, JsonNode propertiesNode) { JAnnotationArrayMember annotationValue = clazz.annotate(JsonPropertyOrder.class).paramArray(ANNOTATION_VALUE); annotationValue.param(API_VERSION); annotationValue.param(KIND); annotationValue.param(METADATA); for (Iterator<String> properties = propertiesNode.fieldNames(); properties.hasNext();) { String next = properties.next(); if (!next.equals(API_VERSION) && !next.equals(KIND) && !next.equals(METADATA)) { annotationValue.param(next); } } clazz.annotate(ToString.class); clazz.annotate(EqualsAndHashCode.class); processBuildable(clazz); if (clazz.fields().containsKey(KIND) && clazz.fields().containsKey(METADATA)) { String resourceName; if (clazz.name().endsWith("List")) { resourceName = clazz.name().substring(0, clazz.name().length() - 4); pendingLists.put(resourceName, clazz); } else { resourceName = clazz.name(); pendingResources.put(clazz.name(), clazz); } if (pendingResources.containsKey(resourceName) && pendingLists.containsKey(resourceName)) { JDefinedClass resourceClass = pendingResources.get(resourceName); JDefinedClass resourceListClass = pendingLists.get(resourceName); String apiVersion = propertiesNode.get(API_VERSION).get("default").toString().replaceAll(Pattern.quote("\""), ""); String apiGroup = ""; if (apiVersion.contains("/")) { apiGroup = apiVersion.substring(0, apiVersion.lastIndexOf('/')); apiVersion = apiVersion.substring(apiGroup.length() + 1); } String packageSuffix = getPackageSuffix(apiVersion); resourceClass.annotate(ApiVersion.class).param(ANNOTATION_VALUE, apiVersion); resourceClass.annotate(ApiGroup.class).param(ANNOTATION_VALUE, apiGroup); resourceClass.annotate(PackageSuffix.class).param(ANNOTATION_VALUE, packageSuffix); resourceListClass.annotate(ApiVersion.class).param(ANNOTATION_VALUE, apiVersion); resourceListClass.annotate(ApiGroup.class).param(ANNOTATION_VALUE, apiGroup); resourceListClass.annotate(PackageSuffix.class).param(ANNOTATION_VALUE, packageSuffix); pendingLists.remove(resourceName); pendingResources.remove(resourceName); addClassesToPropertyFiles(resourceClass); } } }