Class AnnotationMetadataProvider
java.lang.Object
org.vaadin.miki.superfields.object.reflect.AnnotationMetadataProvider
- All Implemented Interfaces:
MetadataProvider
Provides
PropertyMetadata based on previously registered annotations. Each field together with its setter and getter are scanned.- Since:
- 2022-09-01
- Author:
- miki
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetMetadata(String name, Field field, Method setter, Method getter) CollectsPropertyMetadatafor a given property.voidregisterAnnotation(String name, Class<? extends Annotation> annotation) Registers the given annotation to be discovered during scanning and maps it to abooleanPropertyMetadata.<V,A extends Annotation>
voidregisterAnnotation(String name, Class<V> type, Class<A> annotation, com.vaadin.flow.function.SerializableFunction<A, V> valueFunction) Registers the given annotation to be discovered during scanning and maps it to aPropertyMetadata.withRegisteredAnnotation(String name, Class<? extends Annotation> annotation) ChainsregisterAnnotation(String, Class)and returns itself.final <V,A extends Annotation>
AnnotationMetadataProviderwithRegisteredAnnotation(String name, Class<A> annotation, Class<V> type, com.vaadin.flow.function.SerializableFunction<A, V> valueFunction) ChainsregisterAnnotation(String, Class, Class, SerializableFunction)and returns itself.
-
Constructor Details
-
AnnotationMetadataProvider
public AnnotationMetadataProvider()
-
-
Method Details
-
getMetadata
public Collection<PropertyMetadata> getMetadata(String name, Field field, Method setter, Method getter) Description copied from interface:MetadataProviderCollectsPropertyMetadatafor a given property.- Specified by:
getMetadatain interfaceMetadataProvider- Parameters:
name- Name of the property.field- AFieldthat corresponds to the property. Will not benull, but may not be accessible.setter- AMethodthat is a setter for the given field. May benullif there is no setter.getter- AMethodthat is a getter for the given field. May benullif there is no getter.- Returns:
- A non-
null, but possibly empty, collection ofPropertyMetadata.
-
registerAnnotation
public <V,A extends Annotation> void registerAnnotation(String name, Class<V> type, Class<A> annotation, com.vaadin.flow.function.SerializableFunction<A, V> valueFunction) Registers the given annotation to be discovered during scanning and maps it to aPropertyMetadata.- Type Parameters:
A- Annotation type.V- Metadata value type.- Parameters:
name- Name of the metadata.type- Value type of the metadata.annotation- Annotation to map.valueFunction- Function to obtain the value from the given annotation.
-
withRegisteredAnnotation
public final <V,A extends Annotation> AnnotationMetadataProvider withRegisteredAnnotation(String name, Class<A> annotation, Class<V> type, com.vaadin.flow.function.SerializableFunction<A, V> valueFunction) ChainsregisterAnnotation(String, Class, Class, SerializableFunction)and returns itself.- Type Parameters:
A- Annotation type.V- Metadata value type.- Parameters:
name- Name of the metadata.type- Value type of the metadata.annotation- Annotation to map.valueFunction- Function to obtain the value from the given annotation.- Returns:
- This.
- See Also:
-
registerAnnotation
Registers the given annotation to be discovered during scanning and maps it to abooleanPropertyMetadata. Only the presence of the annotation will result in creation of the metadata and setting its value totrue. This means that the absence of the annotation will not create the metadata.- Parameters:
name- Name of the metadata.annotation- Annotation to map.
-
withRegisteredAnnotation
public final AnnotationMetadataProvider withRegisteredAnnotation(String name, Class<? extends Annotation> annotation) ChainsregisterAnnotation(String, Class)and returns itself.- Parameters:
name- Name of the metadata.annotation- Annotation to map.- Returns:
- This.
- See Also:
-