Package org.anchoranalysis.bean
Class FieldAccessor
Object
FieldAccessor
Utilities to access a
Field of an AnchorBean.- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionfieldFromBean(AnchorBean<?> bean, Field field) Retrieves the value of aFieldfrom aAnchorBean.static booleanisFieldAnnotatedAsOptional(Field field) Is a particularFieldon aAnchorBeanmarked as optional?
-
Method Details
-
fieldFromBean
public static Optional<Object> fieldFromBean(AnchorBean<?> bean, Field field) throws IllegalAccessException, BeanMisconfiguredException Retrieves the value of aFieldfrom aAnchorBean.- Parameters:
bean- the beanfield- the field to retrieve a value from- Returns:
- the value, it it exists, or
Optional.empty()if it doesn't exist and the bean is marked as optional. - Throws:
IllegalAccessException- if reflection tries to access a property it has no permissions for.BeanMisconfiguredException- if no value exists for the field (and it's not marked as optional).
-
isFieldAnnotatedAsOptional
Is a particularFieldon aAnchorBeanmarked as optional?- Parameters:
field- the field- Returns:
- true iff it is marked as optional.
-