Class AnnotationMetadataProvider
- java.lang.Object
-
- org.vaadin.miki.superfields.object.reflect.AnnotationMetadataProvider
-
- All Implemented Interfaces:
MetadataProvider
public class AnnotationMetadataProvider extends Object implements MetadataProvider
ProvidesPropertyMetadatabased on previously registered annotations. Each field together with its setter and getter are scanned.- Since:
- 2022-09-01
- Author:
- miki
-
-
Constructor Summary
Constructors Constructor Description AnnotationMetadataProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<PropertyMetadata>getMetadata(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.AnnotationMetadataProviderwithRegisteredAnnotation(String name, Class<? extends Annotation> annotation)ChainsregisterAnnotation(String, Class)and returns itself.<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.
-
-
-
Method Detail
-
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(String, Class, Class, SerializableFunction)
-
registerAnnotation
public void registerAnnotation(String name, Class<? extends Annotation> annotation)
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:
registerAnnotation(String, Class)
-
-