Refine search
@Override public void decorateAnnotationsList(final List<AnnotationMetadataBuilder> annotations) { super.decorateAnnotationsList(annotations); if (assertTrue) { annotations.add(new AnnotationMetadataBuilder(ASSERT_TRUE)); } if (assertFalse) { annotations.add(new AnnotationMetadataBuilder(ASSERT_FALSE)); } }
@Override public void decorateAnnotationsList(final List<AnnotationMetadataBuilder> annotations) { super.decorateAnnotationsList(annotations); final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>(); attrs.add(new StringAttributeValue(new JavaSymbolName("contentType"), contentType .getContentType())); if (autoUpload) { attrs.add(new BooleanAttributeValue(new JavaSymbolName("autoUpload"), autoUpload)); } annotations.add(new AnnotationMetadataBuilder(ROO_UPLOADED_FILE, attrs)); annotations.add(new AnnotationMetadataBuilder(LOB)); }
/** * Builds and returns the entity service field, annotated with @MockBean * * @param the service {@link JavaType} * @return {@link FieldMetadataBuilder} */ private FieldMetadataBuilder getEntityServiceField(JavaType service) { JavaSymbolName fieldName = new JavaSymbolName(String.format("%sService", StringUtils.uncapitalize(service.getSimpleTypeName()))); FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(this.getId(), Modifier.PUBLIC, fieldName, service, null); // Add @Autowired fieldBuilder.addAnnotation(new AnnotationMetadataBuilder(SpringJavaType.MOCK_BEAN)); return fieldBuilder; }
parameterTypes.add(new AnnotatedJavaType(removeFromMethod.getParameterTypes().get(0) .getJavaType(), AnnotationMetadataBuilder.getInstance(SpringJavaType.MODEL_ATTRIBUTE))); AnnotationMetadataBuilder pathVariableAnnotation = new AnnotationMetadataBuilder(SpringJavaType.PATH_VARIABLE); pathVariableAnnotation.addStringAttribute("value", itemsName.getSymbolName()); parameterTypes.add(new AnnotatedJavaType(JavaType.collectionOf(removeFromMethod .getParameterTypes().get(1).getJavaType().getParameters().get(0)), pathVariableAnnotation .build())); getGovernorMethod(new JavaSymbolName(methodName), AnnotatedJavaType.convertFromAnnotatedJavaTypes(parameterTypes)); if (existingMethod != null) { new AnnotationMetadataBuilder(SpringJavaType.DELETE_MAPPING); postMappingAnnotation.addStringAttribute("name", methodName); postMappingAnnotation.addStringAttribute("value", "/batch/{" + itemsName.getSymbolName() + "}"); annotations.add(postMappingAnnotation); this.mvcMethodNames.put(methodName, methodName); annotations.add(new AnnotationMetadataBuilder(SpringJavaType.RESPONSE_BODY)); new MethodMetadataBuilder(getId(), Modifier.PUBLIC, new JavaSymbolName(methodName), JavaType.wrapperWilcard(RESPONSE_ENTITY), parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations);
parameterTypes.add(new AnnotatedJavaType(addToMethod.getParameterTypes().get(0).getJavaType(), ANN_MODEL_ATTRIBUTE)); AnnotationMetadataBuilder pathVariableAnnotation = new AnnotationMetadataBuilder(SpringJavaType.PATH_VARIABLE); pathVariableAnnotation.addStringAttribute("value", itemsName.getSymbolName()); parameterTypes.add(new AnnotatedJavaType(addToMethod.getParameterTypes().get(1).getJavaType() .getParameters().get(0), pathVariableAnnotation.build())); AnnotationMetadataBuilder postMappingAnnotation = new AnnotationMetadataBuilder(POST_MAPPING); postMappingAnnotation.addStringAttribute("name", methodName.getSymbolName()); annotations.add(postMappingAnnotation);
@Override public void decorateAnnotationsList(final List<AnnotationMetadataBuilder> annotations) { super.decorateAnnotationsList(annotations); if (decimalMin != null) { final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>(); attrs.add(new StringAttributeValue(new JavaSymbolName("value"), decimalMin)); annotations.add(new AnnotationMetadataBuilder(DECIMAL_MIN, attrs)); } if (decimalMax != null) { final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>(); attrs.add(new StringAttributeValue(new JavaSymbolName("value"), decimalMax)); annotations.add(new AnnotationMetadataBuilder(DECIMAL_MAX, attrs)); } }
@Override public void decorateAnnotationsList(final List<AnnotationMetadataBuilder> annotations) { super.decorateAnnotationsList(annotations); annotations.add(new AnnotationMetadataBuilder(EMBEDDED)); } }
new JavaSymbolName(addToMethod.getMethodName().getSymbolName() + "Batch"); parameterTypes.add(new AnnotatedJavaType(addToMethod.getParameterTypes().get(0).getJavaType(), ANN_MODEL_ATTRIBUTE)); parameterTypes.add(new AnnotatedJavaType(addToMethod.getParameterTypes().get(1).getJavaType(), ANN_REQUEST_BODY)); AnnotationMetadataBuilder postMappingAnnotation = new AnnotationMetadataBuilder(POST_MAPPING); postMappingAnnotation.addStringAttribute("name", methodName.getSymbolName()); postMappingAnnotation.addStringAttribute("value", "/batch"); annotations.add(postMappingAnnotation);
/** * This method obtains the service field that will be used in some different * methods. * * @param service JavaType with the information about the service related with the new Service field * * @return FieldMetadata with the necessary information about the service */ private FieldMetadata getServiceField(JavaType service) { // Check if already exists if (serviceFields.get(service) != null) { return serviceFields.get(service); } // Create the field FieldMetadataBuilder serviceField = new FieldMetadataBuilder(getId(), Modifier.PRIVATE, new JavaSymbolName( StringUtils.uncapitalize(service.getSimpleTypeName())), service, null); serviceField.addAnnotation(new AnnotationMetadataBuilder(SpringJavaType.AUTOWIRED)); serviceFields.put(service, serviceField.build()); return serviceField.build(); }
@Override public void decorateAnnotationsList(final List<AnnotationMetadataBuilder> annotations) { super.decorateAnnotationsList(annotations); if (sizeMin != null || sizeMax != null) { final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>(); if (sizeMin != null) { attrs.add(new IntegerAttributeValue(new JavaSymbolName("min"), sizeMin)); } if (sizeMax != null) { attrs.add(new IntegerAttributeValue(new JavaSymbolName("max"), sizeMax)); } annotations.add(new AnnotationMetadataBuilder(SIZE, attrs)); } }
public final void setAnnotations(final Collection<AnnotationMetadata> annotations) { final List<AnnotationMetadataBuilder> annotationBuilders = new ArrayList<AnnotationMetadataBuilder>(); for (final AnnotationMetadata annotationMetadata : annotations) { annotationBuilders.add(new AnnotationMetadataBuilder(annotationMetadata)); } setAnnotations(annotationBuilders); }
new JavaSymbolName(removeFromDetailsMethod.getMethodName().getSymbolName() + "Batch"); parameterTypes.add(new AnnotatedJavaType(removeFromDetailsMethod.getParameterTypes().get(0) .getJavaType(), ANN_MODEL_ATTRIBUTE)); parameterTypes.add(new AnnotatedJavaType(removeFromDetailsMethod.getParameterTypes().get(1) .getJavaType(), ANN_REQUEST_BODY)); AnnotationMetadataBuilder postMappingAnnotation = new AnnotationMetadataBuilder(DELETE_MAPPING); postMappingAnnotation.addStringAttribute("name", methodName.getSymbolName()); postMappingAnnotation.addStringAttribute("value", "/batch"); annotations.add(postMappingAnnotation);
/** * Returns the JPA @Inheritance annotation to be applied to the entity, if * applicable * * @param annotationValues the values of the {@link RooJpaEntity} annotation * (required) * @return <code>null</code> if it's already present or not required */ private AnnotationMetadata getInheritanceAnnotation() { if (governorTypeDetails.getAnnotation(INHERITANCE) != null) { return null; } if (StringUtils.isNotBlank(annotationValues.getInheritanceType())) { final AnnotationMetadataBuilder inheritanceBuilder = new AnnotationMetadataBuilder(INHERITANCE); inheritanceBuilder.addEnumAttribute("strategy", new EnumDetails(INHERITANCE_TYPE, new JavaSymbolName(annotationValues.getInheritanceType()))); return inheritanceBuilder.build(); } return null; }
@Override public void decorateAnnotationsList(final List<AnnotationMetadataBuilder> annotations) { super.decorateAnnotationsList(annotations); if (sizeMin != null || sizeMax != null) { final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>(); if (sizeMin != null) { attrs.add(new IntegerAttributeValue(new JavaSymbolName("min"), sizeMin)); } if (sizeMax != null) { attrs.add(new IntegerAttributeValue(new JavaSymbolName("max"), sizeMax)); } annotations.add(new AnnotationMetadataBuilder(SIZE, attrs)); } if (regexp != null) { final List<AnnotationAttributeValue<?>> attrs = new ArrayList<AnnotationAttributeValue<?>>(); attrs.add(new StringAttributeValue(new JavaSymbolName("regexp"), regexp)); annotations.add(new AnnotationMetadataBuilder(PATTERN, attrs)); } }
private void init(final IdentifiableAnnotatedJavaStructure existing) { for (final AnnotationMetadata element : existing.getAnnotations()) { this.annotations.add(new AnnotationMetadataBuilder(element)); } }
/** * This method obtains the servlet field that will be used in some different methods * * @return FieldMetadata that contains all the necessary information * about the servlet field */ private FieldMetadata getServletField() { // Check if already exists if (this.servletField != null) { return this.servletField; } // Create the field FieldMetadataBuilder servlet = new FieldMetadataBuilder(getId(), Modifier.PRIVATE, new JavaSymbolName("cxfServletPath"), JavaType.STRING, null); AnnotationMetadataBuilder valueAnnotation = new AnnotationMetadataBuilder(SpringJavaType.VALUE); valueAnnotation.addStringAttribute("value", "${cxf.path}"); servlet.addAnnotation(valueAnnotation); servletField = servlet.build(); return servletField; }
/** * Creates MockitoRule field for validating and initialize mocks. * * @return {@link FieldMetadataBuilder} for building field into ITD. */ private FieldMetadataBuilder getMockitoRuleField() { // Create field @Rule List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); AnnotationMetadataBuilder ruleAnnotation = new AnnotationMetadataBuilder(RULE); annotations.add(ruleAnnotation); // Create field FieldMetadataBuilder ruleField = new FieldMetadataBuilder(getId(), Modifier.PUBLIC, annotations, new JavaSymbolName( "mockito"), MOCKITO_RULE); // ruleField.setFieldInitializer(String.format("%s.rule()", // new JavaType(MOCKITO_JUNIT.getNameIncludingTypeParameters(false, importResolver)))); return ruleField; }
@Override public void newEmbeddableClass(final JavaType name, final boolean serializable) { Validate.notNull(name, "Embeddable name required"); final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(name, getPathResolver().getFocusedPath(Path.SRC_MAIN_JAVA)); final List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(Arrays.asList(new AnnotationMetadataBuilder( ROO_JAVA_BEAN), new AnnotationMetadataBuilder(ROO_TO_STRING), new AnnotationMetadataBuilder(EMBEDDABLE))); if (serializable) { annotations.add(new AnnotationMetadataBuilder(ROO_SERIALIZABLE)); } final int modifier = Modifier.PUBLIC; final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(declaredByMetadataId, modifier, name, PhysicalTypeCategory.CLASS); cidBuilder.setAnnotations(annotations); getTypeManagementService().createOrUpdateTypeOnDisk(cidBuilder.build()); getProjectOperations().addDependency(name.getModule(), new Dependency("org.springframework.boot", "spring-boot-starter-data-jpa", null)); }
/** * This method obtains the bus field that will be used in some different methods * * @return FieldMetadata that contains all the necessary information * about the bus field */ private FieldMetadata getBusField() { // Check if already exists if (this.busField != null) { return this.busField; } // Create the field FieldMetadataBuilder bus = new FieldMetadataBuilder(getId(), Modifier.PRIVATE, new JavaSymbolName("bus"), new JavaType("org.apache.cxf.Bus"), null); bus.addAnnotation(new AnnotationMetadataBuilder(SpringJavaType.AUTOWIRED)); busField = bus.build(); return busField; }
/** * This method provides @RooWsClient annotation with all the necessary attributes * * @param endpoint * @param targetNamespace * @param bindingType * @return */ private AnnotationMetadataBuilder getWsClientAnnotation(final String endpoint, final String targetNamespace, final EnumDetails bindingType) { final List<AnnotationAttributeValue<?>> wsClientAttributes = new ArrayList<AnnotationAttributeValue<?>>(); wsClientAttributes.add(new StringAttributeValue(new JavaSymbolName("endpoint"), endpoint)); wsClientAttributes.add(new StringAttributeValue(new JavaSymbolName("targetNamespace"), targetNamespace)); wsClientAttributes.add(new EnumAttributeValue(new JavaSymbolName("binding"), bindingType)); return new AnnotationMetadataBuilder(RooJavaType.ROO_WS_CLIENT, wsClientAttributes); }