Refine search
@Override public void propertyOrder(JDefinedClass clazz, JsonNode propertiesNode) { JAnnotationArrayMember annotationValue = clazz.annotate(JsonPropertyOrder.class).paramArray("value"); for (Iterator<String> properties = propertiesNode.fieldNames(); properties.hasNext();) { annotationValue.param(properties.next()); } }
private void addIndexAnnotations(final BusinessObject businessObject, final JDefinedClass entityClass) { final List<Index> indexes = businessObject.getIndexes(); if (indexes != null && !indexes.isEmpty()) { final JAnnotationUse hibTabAnnotation = codeGenerator.addAnnotation(entityClass, org.hibernate.annotations.Table.class); hibTabAnnotation.param("appliesTo", entityClass.name().toUpperCase()); final JAnnotationArrayMember indexesArray = hibTabAnnotation.paramArray("indexes"); for (final Index index : indexes) { final JAnnotationUse indexAnnotation = indexesArray.annotate(org.hibernate.annotations.Index.class); indexAnnotation.param("name", index.getName().toUpperCase()); final JAnnotationArrayMember columnParamArray = indexAnnotation.paramArray("columnNames"); for (final String fieldName : index.getFieldNames()) { columnParamArray.param(getFieldRealColumnName(businessObject, fieldName).toUpperCase()); } } } }
private void writeXmlTypeDeclaration(JDefinedClass cls, String typeName, String namespaceUri, Collection<MemberInfo> members) { if (cls == null) return; JAnnotationUse xmlTypeAnn = cls.annotate(cm.ref(XmlType.class)); xmlTypeAnn.param("name", typeName); xmlTypeAnn.param("namespace", namespaceUri); if (members.size() > 1) { JAnnotationArrayMember paramArray = xmlTypeAnn.paramArray("propOrder"); for (MemberInfo memInfo : members) { paramArray.param(memInfo.getParamName()); } } }
@Override public void propertyOrder(JDefinedClass clazz, JsonNode propertiesNode) { JAnnotationArrayMember annotationValue = clazz.annotate(JsonPropertyOrder.class).paramArray("value"); annotationValue.param("apiVersion"); annotationValue.param("kind"); annotationValue.param("metadata"); for (Iterator<String> properties = propertiesNode.fieldNames(); properties.hasNext();) { String next = properties.next(); if (!next.equals("apiVersion") && !next.equals("kind") && !next.equals("metadata")) { annotationValue.param(next); JAnnotationArrayMember arrayMember = resourceClass.annotate(VelocityTransformations.class) .paramArray("value"); arrayMember.annotate(VelocityTransformation.class).param("value", "/manifest.vm") .param("outputPath", "kubernetes.properties").param("gather", true); } else if (resourceClass.getPackage().name().startsWith("io.fabric8.openshift")) { JAnnotationArrayMember arrayMember = resourceClass.annotate(VelocityTransformations.class) .paramArray("value"); arrayMember.annotate(VelocityTransformation.class).param("value", "/manifest.vm") .param("outputPath", "openshift.properties").param("gather", true);
if ((facet = simpleType.getFacet(FACET_LENGTH)) != null) { int length = Integer.valueOf(facet.getValue().value); a.put(fieldVar.annotate(sizeAnn).param("min", length).param("max", length), FacetType.length); } else { Integer minLength = (facet = simpleType.getFacet(FACET_MINLENGTH)) != null ? Integer.valueOf(facet.getValue().value) : null; a.put(fieldVar.annotate(sizeAnn).param("min", minLength).param("max", maxLength), FacetType.minLength); else if (minLength != null) a.put(fieldVar.annotate(sizeAnn).param("min", minLength), FacetType.minLength); a.put(listValue.annotate(patternAnn).param("regexp", eliminateShorthands(xsFacet.getValue().value)), FacetType.pattern); else Logger.getLogger(this.getClass().getName()).log(Level.WARNING, PATTERN_ANNOTATION_NOT_APPLICABLE);
@Override public void propertyOrder(JDefinedClass clazz, JsonNode propertiesNode) { JAnnotationArrayMember annotationValue = clazz.annotate(JsonPropertyOrder.class).paramArray("value"); annotationValue.param("apiVersion"); annotationValue.param("kind"); annotationValue.param("metadata"); String key = entry.getKey(); if (!"apiVersion".equals(key) && !"kind".equals(key) && !"metadata".equals(key)) { annotationValue.param(key); final Optional<String> kind = IstioSpecRegistry.getIstioKind(clazz.name()); if (kind.isPresent()) { clazz._implements(IstioSpec.class); final String plural = IstioSpecRegistry.getIstioKindPlural(clazz.name()).orElse(kind + "s"); clazz.annotate(IstioKind.class).param("name", kind.get()).param("plural", plural); buildable.paramArray("inline").annotate(Inline.class) buildable.paramArray("refs").annotate(BuildableReference.class) arrayMember.annotate(VelocityTransformation.class).param("value", "/istio-resource.vm"); arrayMember.annotate(VelocityTransformation.class).param("value", "/istio-resource-list.vm"); arrayMember.annotate(VelocityTransformation.class).param("value", "/istio-manifest.vm") .param("outputPath", "crd.properties").param("gather", true); arrayMember.annotate(VelocityTransformation.class).param("value", "/istio-mappings-provider.vm")
JAnnotationUse annUse = impl.annotate(Generated.class); JAnnotationArrayMember array = annUse.paramArray("value"); array.param("wadl|" + rootResource.toString()); array.param("customization|" + packagePath.relativize(customization)); annUse.param("comments", "wadl2java, http://wadl.java.net"); annUse.param("date", DatatypeConverter.printDateTime( gc)); JFieldVar $base_uri = impl.field( Modifier.PUBLIC | Modifier.STATIC JBlock staticInit = impl.init();
public void withJsonDiscriminator(List<RamlDataType> childTypes, String discriminator) { this.pojo.annotate(JsonTypeInfo.class).param("property", discriminator).param("use", JsonTypeInfo.Id.NAME) .param("include", As.EXISTING_PROPERTY).param("visible", true); JAnnotationUse param = this.pojo.annotate(JsonSubTypes.class).param("value", discriminator); JAnnotationArrayMember jAnnotationArrayMember = param.paramArray("value"); for (RamlDataType childType : childTypes) { String discriminatorValue = childType.getDiscriminatorValue(); if (StringUtils.isEmpty(discriminatorValue)) { // default value for discriminator is the name of the type discriminatorValue = childType.getType().name(); } jAnnotationArrayMember.annotate(JsonSubTypes.Type.class).param("value", resolveType(childType.getType().name())).param("name", discriminatorValue); } }
JDefinedClass beanClazz = classOutline.implClass; JAnnotationUse jsonAutoDetect = beanClazz.annotate(JsonAutoDetect.class) .param("fieldVisibility", JsonAutoDetect.Visibility.ANY) .param("getterVisibility", JsonAutoDetect.Visibility.NONE) .param("isGetterVisibility", JsonAutoDetect.Visibility.NONE) .param("setterVisibility", JsonAutoDetect.Visibility.NONE); JAnnotationUse jsonInclude = beanClazz.annotate(JsonInclude.class) .param("value", JsonInclude.Include.NON_EMPTY); Map<String, JFieldVar> fieldVars = beanClazz.fields(); JAnnotationUse jsonPropertyOrder = beanClazz.annotate(JsonPropertyOrder.class); fieldNameArray.param(propertyName); .param("value", JExpr.dotclass(complexNodeClass)); valueArray.param(jsonSubTypesType); } else .param("value", JExpr.dotclass(clazz)); valueArray.param(jsonSubTypesType);
JAnnotationArrayMember m = arrays.get(name); if(m==null) { m = use.paramArray(name); arrays.put(name,m); if(!JAnnotationWriter.class.isAssignableFrom(expectedReturnType)) throw new IllegalArgumentException("Unexpected return type "+expectedReturnType); return new TypedAnnotationWriter(r,expectedReturnType,m.annotate(r)).createProxy(); m.param((JType)arg); return proxy; m.param((String)arg); return proxy; m.param((Boolean)arg); return proxy; m.param((Integer)arg); return proxy; m.param((Class)arg); return proxy;
private void addNamedQuery(final JDefinedClass entityClass, final JAnnotationArrayMember valueArray, final String name, final String content) { final JAnnotationUse nameQueryAnnotation = valueArray.annotate(NamedQuery.class); nameQueryAnnotation.param("name", entityClass.name() + "." + name); nameQueryAnnotation.param("query", content); }
public static void suppressWarnings(JMethod method, String... values) { JAnnotationUse annotation = method.annotate(SuppressWarnings.class); JAnnotationArrayMember member = annotation.paramArray("value"); for( String value : values ) { member.param(value); } }
JAnnotationArrayMember jAnnotationArrayMember = requestMappingAnnotation.paramArray("value"); boolean paramSet = false; jAnnotationArrayMember.param(url); jAnnotationArrayMember.param(urlWithoutParam); requestMappingAnnotation.param("value", url); requestMappingAnnotation.param("method", RequestMethod.valueOf(endpointMetadata.getActionType().name())); return requestMappingAnnotation;
JDefinedClass testme = codeModel._class("Testme"); JAnnotationUse patternListAnnotation = testme.annotate(Pattern.List.class); JAnnotationArrayMember list = patternListAnnotation.paramArray("value"); list.annotate(Pattern.class).param("regexp", "first_expression").param("message", "first.Pattern.message"); list.annotate(Pattern.class).param("regexp", "second_expression").param("message", "second.Pattern.message"); list.annotate(Pattern.class).param("regexp", "third_expression").param("message", "third.Pattern.message");
public static void annotateFieldWithFindBysAnnotation(JFieldVar field, AnnotationMirror findBys) { JAnnotationUse findBysAnnotation = field.annotate(FindBys.class); JAnnotationArrayMember findBysAnnotationValues = findBysAnnotation.paramArray("value"); for (AnnotationMirror findBy : (List<AnnotationMirror>) findBys.getElementValues().values().iterator().next().getValue() ) { JAnnotationUse findByAnnotation = findBysAnnotationValues.annotate(FindBy.class); setFindByAnnotationValues(findByAnnotation, findBy); } }
/** * Adds a new annotation to the array. */ public JAnnotationUse annotate(Class<? extends Annotation> clazz){ return annotate(owner.ref(clazz)); }
/** * Adds a member value pair which is of type array to this annotation * @param name * The simple name for this annotation * * @return * The JAnnotationArrayMember. For adding array values * @see JAnnotationArrayMember * */ public JAnnotationArrayMember paramArray(String name){ JAnnotationArrayMember arrayMember = new JAnnotationArrayMember(owner()); addValue(name, arrayMember); return arrayMember; }