/** * Generates the {@link ItdTypeDetails} from the current contents of this * instance's {@link ItdTypeDetailsBuilder}. * * @since 1.2.0 */ protected void buildItd() { itdTypeDetails = builder.build(); }
@Override public int hashCode() { if (itdTypeDetails != null) { return itdTypeDetails.hashCode(); } return builder.build().hashCode(); }
/** * 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(); }
public ConfigurableMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate.isTrue(isValid(identifier), "Metadata identification string '%s' does not appear to be a valid", identifier); if (!isValid()) { return; } builder.addAnnotation(getConfigurableAnnotation()); // Create a representation of the desired output ITD itdTypeDetails = builder.build(); }
/** * Constructor * * @param identifier * @param aspectName * @param governorPhysicalTypeMetadata */ public JpaAuditMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, List<FieldMetadata> auditFields) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate .isTrue( isValid(identifier), "Metadata identification string '%s' does not appear to be a valid physical type identifier", identifier); // Saving audit fields to provide them to other components // that invoke this Metadata this.auditFields = auditFields; // Add @EntityListeners annotation ensureGovernorIsAnnotated(getEntityListenersAnnotation()); // Build ITD itdTypeDetails = builder.build(); }
/** * Constructor * * @param identifier the identifier for this item of metadata (required) * @param aspectName the Java type of the ITD (required) * @param governorPhysicalTypeMetadata the governor, which is expected to * contain a {@link ClassOrInterfaceTypeDetails} (required) * */ public DomainModelModuleMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final Map<JavaType, JavaType> mixins) { super(identifier, aspectName, governorPhysicalTypeMetadata); Map<JavaType, JavaType> orderedMixins = new TreeMap<JavaType, JavaType>(mixins); this.mixins = Collections.unmodifiableMap(orderedMixins); // Add @Configuration ensureGovernorIsAnnotated(new AnnotationMetadataBuilder(BOOT_JACKSON_JSON_COMPONENT)); // Add extends WebMvcConfigurerAdapter ensureGovernorExtends(JACKSON_SIMPLE_MODULE); // Add constructor ensureGovernorHasConstructor(new ConstructorMetadataBuilder(getConstructor())); // Build the ITD itdTypeDetails = builder.build(); }
itdTypeDetails = builder.build();
@Override protected void onAddField(final FieldMetadataBuilder md) { Validate.isTrue(governor.getDeclaredField(md.getFieldName()) == null, "Field '%s' already defined in target type '%s' (ITD target '%s')", md.getFieldName(), governor.getName().getFullyQualifiedTypeName(), aspect.getFullyQualifiedTypeName()); Validate.isTrue(build().getDeclaredField(md.getFieldName()) == null, "Field '%s' already defined in ITD (ITD target '%s')", md.getFieldName(), aspect.getFullyQualifiedTypeName()); }
@Override protected void onAddConstructor(final ConstructorMetadataBuilder md) { Validate.isTrue(governor.getDeclaredConstructor(AnnotatedJavaType .convertFromAnnotatedJavaTypes(md.getParameterTypes())) == null, "Constructor with %d parameters already defined in target type '%s' (ITD target '%s')", md .getParameterTypes().size(), governor.getName().getFullyQualifiedTypeName(), aspect .getFullyQualifiedTypeName()); Validate.isTrue( build().getDeclaredConstructor( AnnotatedJavaType.convertFromAnnotatedJavaTypes(md.getParameterTypes())) == null, "Constructor with %d parameters already defined in ITD (ITD target '%s')", md .getParameterTypes().size(), aspect.getFullyQualifiedTypeName()); Validate .notBlank( md.getBody(), "Constructor '%s' failed to provide a body, despite being identified for ITD inclusion", md); }
@Override protected void onAddAnnotation(final AnnotationMetadataBuilder md) { Validate.isTrue(governor.getAnnotation(md.getAnnotationType()) == null, "Type annotation '%s' already defined in target type '%s' (ITD target '%s')", md.getAnnotationType(), governor.getName().getFullyQualifiedTypeName(), aspect.getFullyQualifiedTypeName()); Validate.isTrue(build().getAnnotation(md.getAnnotationType()) == null, "Type annotation '%s' already defined in ITD (ITD target '%s')", md.getAnnotationType(), aspect.getFullyQualifiedTypeName()); }
/** * Constructor * * @param identifier * @param aspectName * @param governorPhysicalTypeMetadata */ public EntityProjectionMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final EntityProjectionAnnotationValues annotationValues, final List<FieldMetadata> fields) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate .isTrue( isValid(identifier), "Metadata identification string '%s' does not appear to be a valid physical type identifier", identifier); this.fields = fields; this.annotationValues = annotationValues; this.type = governorPhysicalTypeMetadata.getType(); ConstructorMetadataBuilder constructorMetadata = getConstructor(); if (!constructorMetadata.getParameterTypes().isEmpty()) { ensureGovernorHasConstructor(constructorMetadata); } // ROO-3868: New entity visualization support using a new format annotation ensureGovernorIsAnnotated(new AnnotationMetadataBuilder(getEntityFormatAnnotation())); // Build ITD itdTypeDetails = builder.build(); }
itdTypeDetails = builder.build();
/** * Constructor * * @param identifier * @param aspectName * @param governorPhysicalTypeMetadata */ public DtoMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final DtoAnnotationValues annotationValues, List<FieldMetadata> fields) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate .isTrue( isValid(identifier), "Metadata identification string '%s' does not appear to be a valid physical type identifier", identifier); this.annotationValues = annotationValues; this.fields = fields; this.type = governorPhysicalTypeMetadata.getType(); if (annotationValues.getImmutable()) { ConstructorMetadataBuilder constructorMetadata = getConstructor(); if (!constructorMetadata.getParameterTypes().isEmpty()) { ensureGovernorHasConstructor(constructorMetadata); } } // ROO-3868: New entity visualization support using a new format annotation ensureGovernorIsAnnotated(new AnnotationMetadataBuilder(getEntityFormatAnnotation())); // Build ITD itdTypeDetails = builder.build(); }
@Override protected void onAddMethod(final MethodMetadataBuilder md) { Validate.isTrue( MemberFindingUtils.getDeclaredMethod(governor, md.getMethodName(), AnnotatedJavaType.convertFromAnnotatedJavaTypes(md.getParameterTypes())) == null, "Method '%s' already defined in target type '%s' (ITD target '%s')", md.getMethodName(), governor.getName().getFullyQualifiedTypeName(), aspect.getFullyQualifiedTypeName()); Validate.isTrue( MemberFindingUtils.getDeclaredMethod(build(), md.getMethodName(), AnnotatedJavaType.convertFromAnnotatedJavaTypes(md.getParameterTypes())) == null, "Method '%s' already defined in ITD (ITD target '%s')", md.getMethodName(), aspect.getFullyQualifiedTypeName()); if (!Modifier.isAbstract(md.getModifier()) && md.getReturnType() != JavaType.VOID_PRIMITIVE) { Validate.notBlank(md.getBody(), "Method '%s' failed to provide a body, despite being identified for ITD inclusion", md); } } }
/** * 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); } }
/** * Constructor * * @param identifier * @param aspectName * @param governorPhysicalTypeMetadata * @param dataOnDemandTypes */ public JpaDataOnDemandConfigurationMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final SortedSet<JavaType> dataOnDemandTypes) { super(identifier, aspectName, governorPhysicalTypeMetadata); Validate.isTrue(isValid(identifier), "Metadata identification string '%s' does not appear to be a valid", identifier); // Add EntityManager field ensureGovernorHasField(getEntityManagerField()); // Add constructor ensureGovernorHasConstructor(getConstructor()); // Add @TestConfiguration ensureGovernorIsAnnotated(new AnnotationMetadataBuilder(SpringJavaType.TEST_CONFIGURATION)); // Add DoD bean creation method for (JavaType dodType : dataOnDemandTypes) { ensureGovernorHasMethod(new MethodMetadataBuilder(getDodTypeBeanCreationMethod(dodType))); } // Build the ITD itdTypeDetails = builder.build(); }
/** * Constructor * * @param identifier the identifier for this item of metadata (required) * @param aspectName the Java type of the ITD (required) * @param governorPhysicalTypeMetadata the governor, which is expected to * contain a {@link ClassOrInterfaceTypeDetails} (required) */ public ThymeleafMainControllerMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata) { super(identifier, aspectName, governorPhysicalTypeMetadata); this.indexMethod = getIndexMethod(); this.accessibilityMethod = getAccessibilityMethod(); this.javasrcriptTemplatesMethod = getJavascriptTemplatesmethod(); // Add @Controller annotation ensureGovernorIsAnnotated(new AnnotationMetadataBuilder(CONTROLLER_ANNOTATION)); // Add methods ensureGovernorHasMethod(new MethodMetadataBuilder(indexMethod)); ensureGovernorHasMethod(new MethodMetadataBuilder(accessibilityMethod)); ensureGovernorHasMethod(new MethodMetadataBuilder(javasrcriptTemplatesMethod)); // Build the ITD itdTypeDetails = builder.build(); }
/** * Constructor * * @param identifier the identifier for this item of metadata (required) * @param aspectName the Java type of the ITD (required) * @param governorPhysicalTypeMetadata the governor, which is expected to * contain a {@link ClassOrInterfaceTypeDetails} (required) * */ public WebMvcConfigurationMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata, final String defaultLanguage) { super(identifier, aspectName, governorPhysicalTypeMetadata); // Add @Configuration ensureGovernorIsAnnotated(new AnnotationMetadataBuilder(SpringJavaType.CONFIGURATION)); // Add extends WebMvcConfigurerAdapter ensureGovernorExtends(SpringJavaType.WEB_MVC_CONFIGURER_ADAPTER); // Add validator method ensureGovernorHasMethod(new MethodMetadataBuilder(getValidatorMethod())); // Add localResolver ensureGovernorHasMethod(new MethodMetadataBuilder(getLocaleResolver(defaultLanguage))); // Add localeChangeInterceptor ensureGovernorHasMethod(new MethodMetadataBuilder(getLocaleChangeInterceptor())); // Add addInterceptors ensureGovernorHasMethod(new MethodMetadataBuilder(getAddInterceptors())); // Build the ITD itdTypeDetails = builder.build(); }
/** * Constructor * * @param identifier the identifier for this item of metadata (required) * @param aspectName the Java type of the ITD (required) * @param governorPhysicalTypeMetadata the governor, which is expected to * contain a {@link ClassOrInterfaceTypeDetails} (required) */ public ThymeleafUIConfigurationMetadata(final String identifier, final JavaType aspectName, final PhysicalTypeMetadata governorPhysicalTypeMetadata) { super(identifier, aspectName, governorPhysicalTypeMetadata); ensureGovernorImplements(SpringJavaType.APPLICATION_CONTEXT_AWARE); this.thymeleafPropertiesField = getThymeleafPropertiesField(); this.templateEngineField = getTemplateEngineField(); this.applicationContextAwareField = getApplicationContextField(); // Adding fields ensureGovernorHasField(new FieldMetadataBuilder(this.thymeleafPropertiesField)); ensureGovernorHasField(new FieldMetadataBuilder(this.templateEngineField)); ensureGovernorHasField(new FieldMetadataBuilder(this.applicationContextAwareField)); this.setApplicationContextMethod = getMutatorMethod(this.applicationContextAwareField); this.javascriptThymeleafViewResolverMethod = getJavascriptThymeleafViewResolverMethod(); this.javascriptTemplateResolverMethod = getJavascriptTemplateResolverMethod(); // Add index method ensureGovernorHasMethod(new MethodMetadataBuilder(javascriptThymeleafViewResolverMethod)); ensureGovernorHasMethod(new MethodMetadataBuilder(javascriptTemplateResolverMethod)); // Build the ITD itdTypeDetails = builder.build(); }
itdTypeDetails = builder.build();