protected void implementsInterfaceMethods(List<? extends MethodMetadata> interfaceMethods) { if (interfaceMethods != null) { for (MethodMetadata interfaceMethod : interfaceMethods) { MethodMetadataBuilder methodBuilder = getInterfaceMethod(interfaceMethod); // ROO-3584: JavaBean implementing Interface defining getters and setters // ROO-3585: If interface method already exists on type is not necessary // to add on ITD. Method builder will be NULL. if (methodBuilder != null && !checkIfInterfaceMethodWasImplemented(methodBuilder)) { builder.addMethod(methodBuilder); } } } }
/** * Constructor * * @param identifier * @param aspectName * @param governorPhysicalTypeMetadata * @param annotationValues * @param fields * @param hasJavaBeanAnnotation */ public ToStringMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final ToStringAnnotationValues annotationValues, List<FieldMetadata> fields, boolean hasJavaBeanAnnotation) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate.isTrue(isValid(identifier), "Metadata identification string '%s' does not appear to be a valid", identifier); Validate.notNull(annotationValues, "Annotation values required"); this.annotationValues = annotationValues; this.fields = fields; if (!hasJavaBeanAnnotation && !fields.isEmpty()) { // Generate the toString() method builder.addMethod(getToStringMethod()); } // Create a representation of the desired output ITD itdTypeDetails = builder.build(); }
this.locatedFields = locatedFields; builder.addMethod(getCreateMethod()); builder.addMethod(getEmbeddedClassMutatorMethod(embeddedHolder)); addEmbeddedClassFieldMutatorMethodsToBuilder(embeddedHolder, entityFactoryClasses); builder.addMethod(fieldInitializerMethod); builder.addMethod(getEmbeddedIdMutatorMethod(entityFactoryClasses));
/** * Ensures that the governor has provided field. You could indicates if * is necessary to generate the accessor and the mutator methods for this new field manually. * * @param FieldMetadataBuilder the field to include(required) * @since 2.0 */ protected final void ensureGovernorHasField(final FieldMetadataBuilder fieldMetadata, boolean includeAccessor, boolean includeMutator) { if (governorTypeDetails.getField(fieldMetadata.getFieldName()) == null) { builder.addField(fieldMetadata); } if (includeAccessor) { MethodMetadata accessorMethod = getAccessorMethod(fieldMetadata.build()); if (accessorMethod != null && governorTypeDetails.getMethod(accessorMethod.getMethodName()) == null) { builder.addMethod(accessorMethod); } } if (includeMutator) { MethodMetadata mutatorMethod = getMutatorMethod(fieldMetadata.build()); if (mutatorMethod != null && governorTypeDetails.getMethod(mutatorMethod.getMethodName()) == null) { builder.addMethod(mutatorMethod); } } }
/** * Ensures that the governor has provided method * * @param MethodMetadataBuilder the method to include(required) * @since 2.0 */ protected final void ensureGovernorHasMethod(final MethodMetadataBuilder methodMetadata) { if (!hasToExcludeMethod(methodMetadata) && governorTypeDetails.getMethod(methodMetadata.getMethodName(), AnnotatedJavaType.convertFromAnnotatedJavaTypes(methodMetadata.getParameterTypes())) == null && methodMetadata.getDeclaredByMetadataId().equals(getId()) && MemberFindingUtils.getDeclaredMethod(builder.build(), methodMetadata.getMethodName(), AnnotatedJavaType.convertFromAnnotatedJavaTypes(methodMetadata.getParameterTypes())) == null) { builder.addMethod(methodMetadata); } }
private void addEmbeddedClassFieldMutatorMethodsToBuilder(final EmbeddedHolder embeddedHolder, final Set<ClassOrInterfaceTypeDetails> dataOnDemandClasses) { final JavaType embeddedFieldType = embeddedHolder.getEmbeddedField().getFieldType(); final JavaType[] parameterTypes = {embeddedFieldType, JavaType.INT_PRIMITIVE}; final List<JavaSymbolName> parameterNames = Arrays.asList(OBJ_SYMBOL, INDEX_SYMBOL); for (final FieldMetadata field : embeddedHolder.getFields()) { final String initializer = getFieldInitializer(field, null, dataOnDemandClasses); final JavaSymbolName fieldMutatorMethodName = BeanInfoUtils.getMutatorMethodName(field.getFieldName()); final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); bodyBuilder.append(getFieldValidationBody(field, initializer, fieldMutatorMethodName, false)); final JavaSymbolName embeddedClassMethodName = getEmbeddedFieldMutatorMethodName(embeddedHolder.getEmbeddedField().getFieldName(), field.getFieldName()); if (governorHasMethod(embeddedClassMethodName, parameterTypes)) { // Method found in governor so do not create method in ITD continue; } builder.addMethod(new MethodMetadataBuilder(getId(), Modifier.PUBLIC, embeddedClassMethodName, JavaType.VOID_PRIMITIVE, AnnotatedJavaType .convertFromJavaTypes(parameterTypes), parameterNames, bodyBuilder)); } }
builder.addMethod(getInitMethod(annotationValues.getQuantity()));
protected void implementsInterfaceMethods(List<? extends MethodMetadata> interfaceMethods) { if (interfaceMethods != null) { for (MethodMetadata interfaceMethod : interfaceMethods) { MethodMetadataBuilder methodBuilder = getInterfaceMethod(interfaceMethod); // ROO-3584: JavaBean implementing Interface defining getters and setters // ROO-3585: If interface method already exists on type is not necessary // to add on ITD. Method builder will be NULL. if (methodBuilder != null && !checkIfInterfaceMethodWasImplemented(methodBuilder)) { builder.addMethod(methodBuilder); } } } }
public JsonMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String typeNamePlural, final JsonAnnotationValues annotationValues) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate.notNull(annotationValues, "Annotation values required"); Validate.notBlank(typeNamePlural, "Plural of the target type required"); Validate.isTrue( isValid(identifier), "Metadata identification string '%s' does not appear to be a valid", identifier); if (!isValid()) { return; } this.annotationValues = annotationValues; this.typeNamePlural = typeNamePlural; builder.addMethod(getToJsonMethod(false)); builder.addMethod(getToJsonMethod(true)); builder.addMethod(getFromJsonMethod()); builder.addMethod(getToJsonArrayMethod(false)); builder.addMethod(getToJsonArrayMethod(true)); builder.addMethod(getFromJsonArrayMethod()); // Create a representation of the desired output ITD itdTypeDetails = builder.build(); }
public StringTrimmerBinderMetadata(String identifier, JavaType aspectName, PhysicalTypeMetadata governorPhysicalTypeMetadata, boolean emptyAsNull) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate.isTrue(isValid(identifier), "Metadata identification string '" + identifier + "' does not appear to be a valid"); // Adding a new method definition builder.addMethod(getInitStringTrimmerBinderMethod(emptyAsNull)); // Create a representation of the desired output ITD itdTypeDetails = builder.build(); }
/** * {@inheritDoc} */ @Override public void addCustomArtifact(ItdTypeDetailsBuilder builder) { // Add @Audit if needed (includin in abstract class) if (governorTypeDetails.getAnnotation(AUDITED_ANNOTATION) == null) { builder.addAnnotation(new AnnotationMetadataBuilder( AUDITED_ANNOTATION)); } if (!context.isAbstractEntity()) { builder.addMethod(getAuditReaderStaticMethod()); builder.addMethod(getPropertyMethod()); builder.addMethod(getPropertyMethodWithWrapper()); } }
public ModalDialogMetadata(String identifier, JavaType aspectName, PhysicalTypeMetadata governorPhysicalTypeMetadata, MemberDetails memberDetails, List<String> definedModalDialogs, FileManager fileManager, PathResolver pathResolver) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate.isTrue(isValid(identifier), "Metadata identification string '" + identifier + "' does not appear to be a valid"); Validate.notNull(memberDetails, "MemberDetails must be not null"); this.memberDetails = memberDetails; this.fileManager = fileManager; this.pathResolver = pathResolver; for (String modalDialog : definedModalDialogs) { installModalDialogSample(modalDialog); builder.addMethod(getCustomModalDialogMethod(modalDialog)); } builder.addMethod(getModalDialogMethod()); itdTypeDetails = builder.build(); new ItdSourceFileComposer(itdTypeDetails); }
private void addToBuilder(final FieldMetadataBuilder fieldBuilder) { final JavaSymbolName fieldName = fieldBuilder.getFieldName(); if (hasField(fieldName, fieldBuilder.buildAnnotations()) || hasFieldInItd(fieldName)) { return; } builder.addField(fieldBuilder); // Check for an existing accessor in the governor final JavaType fieldType = fieldBuilder.getFieldType(); builder.addMethod(getAccessorMethod(fieldName, fieldType)); // Check for an existing mutator in the governor builder.addMethod(getMutatorMethod(fieldName, fieldType)); }
public GvNIXWebEntityMapLayerMetadata(String identifier, JavaType aspectName, PhysicalTypeMetadata governorPhysicalTypeMetadata, TypeLocationService typeLocationService, TypeManagementService typeManagementService, JavaType controller, JavaType entity, String entityPlural) { super(identifier, aspectName, governorPhysicalTypeMetadata); // Generate necessary methods // Helper itd generation this.helper = new ItdBuilderHelper(this, governorPhysicalTypeMetadata, builder.getImportRegistrationResolver()); // Adding list method builder.addMethod(getListGeoEntityOnMapViewerMethod(entity, entityPlural)); // Create a representation of the desired output ITD itdTypeDetails = builder.build(); }
/** * Add annotation and method to avoid cycles converting to XML. * * @param id Declared by metadata id */ protected void addCycleDetection(String id) { // Implements class and create method to avoid XML cycles builder.addImplementsType(new JavaType( "com.sun.xml.bind.CycleRecoverable")); // Create method executed when cycle detected JavaSymbolName methodName = new JavaSymbolName("onCycleDetected"); JavaType returnType = new JavaType(Object.class.getName()); List<AnnotatedJavaType> paramTypes = new ArrayList<AnnotatedJavaType>(1); paramTypes.add(new AnnotatedJavaType(new JavaType( "com.sun.xml.bind.CycleRecoverable.Context"), new ArrayList<AnnotationMetadata>())); List<JavaSymbolName> paramNames = new ArrayList<JavaSymbolName>(1); paramNames.add(new JavaSymbolName("context")); InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); bodyBuilder.appendFormalLine("return new " + governorTypeDetails.getName() + " ();"); builder.addMethod(new MethodMetadataBuilder(id, Modifier.PUBLIC, methodName, returnType, paramTypes, paramNames, bodyBuilder)); }
public GvNIXMapViewerMetadata(String identifier, JavaType aspectName, PhysicalTypeMetadata governorPhysicalTypeMetadata, ProjectOperations projectOperations, PropFileOperations propFileOperations, TypeLocationService typeLocationService, FileManager fileManager, List<JavaType> entities, String path, String mapId, String projection) { super(identifier, aspectName, governorPhysicalTypeMetadata); // Generating necessary methods // Helper itd generation this.helper = new ItdBuilderHelper(this, governorPhysicalTypeMetadata, builder.getImportRegistrationResolver()); // Adding Converter methods String finalPath = path.replaceAll("/", ""); builder.addMethod(getShowMapMethod(finalPath)); // Create a representation of the desired output ITD itdTypeDetails = builder.build(); // Updating show.jspx with entities to display updateJSPXFiles(entities, finalPath, typeLocationService, projectOperations, fileManager, mapId, projection, propFileOperations); }
/** * Ensures that the governor has provided method * * @param MethodMetadataBuilder the method to include(required) * @since 2.0 */ protected final void ensureGovernorHasMethod(final MethodMetadataBuilder methodMetadata) { if (!hasToExcludeMethod(methodMetadata) && governorTypeDetails.getMethod(methodMetadata.getMethodName(), AnnotatedJavaType.convertFromAnnotatedJavaTypes(methodMetadata.getParameterTypes())) == null && methodMetadata.getDeclaredByMetadataId().equals(getId()) && MemberFindingUtils.getDeclaredMethod(builder.build(), methodMetadata.getMethodName(), AnnotatedJavaType.convertFromAnnotatedJavaTypes(methodMetadata.getParameterTypes())) == null) { builder.addMethod(methodMetadata); } }
private void addEmbeddedClassFieldMutatorMethodsToBuilder(final EmbeddedHolder embeddedHolder, final Set<ClassOrInterfaceTypeDetails> dataOnDemandClasses) { final JavaType embeddedFieldType = embeddedHolder.getEmbeddedField().getFieldType(); final JavaType[] parameterTypes = {embeddedFieldType, JavaType.INT_PRIMITIVE}; final List<JavaSymbolName> parameterNames = Arrays.asList(OBJ_SYMBOL, INDEX_SYMBOL); for (final FieldMetadata field : embeddedHolder.getFields()) { final String initializer = getFieldInitializer(field, null, dataOnDemandClasses); final JavaSymbolName fieldMutatorMethodName = BeanInfoUtils.getMutatorMethodName(field.getFieldName()); final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); bodyBuilder.append(getFieldValidationBody(field, initializer, fieldMutatorMethodName, false)); final JavaSymbolName embeddedClassMethodName = getEmbeddedFieldMutatorMethodName(embeddedHolder.getEmbeddedField().getFieldName(), field.getFieldName()); if (governorHasMethod(embeddedClassMethodName, parameterTypes)) { // Method found in governor so do not create method in ITD continue; } builder.addMethod(new MethodMetadataBuilder(getId(), Modifier.PUBLIC, embeddedClassMethodName, JavaType.VOID_PRIMITIVE, AnnotatedJavaType .convertFromJavaTypes(parameterTypes), parameterNames, bodyBuilder)); } }