TypedRest for Java
Static Public Member Functions | List of all members
net.typedrest.BeanUtils Class Reference

Utility methods for Java beans (classes with getters and setters). More...

Static Public Member Functions

static List< PropertyDescriptor > getProperties (Class<?> beanType)
 Lists all properties on a bean type. More...
 
static< TAnnotation extends Annotation > List< PropertyDescriptor > getPropertiesWithAnnotation (Class<?> beanType, Class< TAnnotation > annotationType)
 Lists all properties on a bean type that have a specific annotation on their getter or backing field. More...
 
static< TAnnotation extends Annotation > List< PropertyDescriptor > getPropertiesWithoutAnnotation (Class<?> beanType, Class< TAnnotation > annotationType)
 Lists all readable and writable properties on a bean type that do not have a specific annotation on their getter or backing field. More...
 
static< TAnnotation extends Annotation > Optional< TAnnotation > getAnnotation (Class<?> beanType, PropertyDescriptor property, Class< TAnnotation > annotationType)
 Returns an annotation of a specific type on a property's getter or its backing field. More...
 

Detailed Description

Utility methods for Java beans (classes with getters and setters).

Member Function Documentation

◆ getAnnotation()

static <TAnnotation extends Annotation> Optional<TAnnotation> net.typedrest.BeanUtils.getAnnotation ( Class<?>  beanType,
PropertyDescriptor  property,
Class< TAnnotation >  annotationType 
)
static

Returns an annotation of a specific type on a property's getter or its backing field.

Parameters
<TAnnotation>The type of annotation to look for.
beanTypeThe type of bean the property is declared on.
propertyThe property to check for the annotation.
annotationTypeThe type of annotation to look for.
Returns
The annotation if present.

◆ getProperties()

static List<PropertyDescriptor> net.typedrest.BeanUtils.getProperties ( Class<?>  beanType)
static

Lists all properties on a bean type.

Ensures properties annotated with Id or called "name" are always listed first.

Parameters
beanTypeThe type of bean to check for properties.
Returns
A list of properties.

◆ getPropertiesWithAnnotation()

static <TAnnotation extends Annotation> List<PropertyDescriptor> net.typedrest.BeanUtils.getPropertiesWithAnnotation ( Class<?>  beanType,
Class< TAnnotation >  annotationType 
)
static

Lists all properties on a bean type that have a specific annotation on their getter or backing field.

Parameters
<TAnnotation>The annotation type to look for.
beanTypeThe type of bean to check for properties.
annotationTypeThe annotation type to look for.
Returns
A list of matching properties.

◆ getPropertiesWithoutAnnotation()

static <TAnnotation extends Annotation> List<PropertyDescriptor> net.typedrest.BeanUtils.getPropertiesWithoutAnnotation ( Class<?>  beanType,
Class< TAnnotation >  annotationType 
)
static

Lists all readable and writable properties on a bean type that do not have a specific annotation on their getter or backing field.

Parameters
<TAnnotation>The annotation type to look for.
beanTypeThe type of bean to check for properties.
annotationTypeThe annotation type to look for.
Returns
A list of matching properties.

The documentation for this class was generated from the following file: