Class AnchorBean<F>
Object
AnchorBean<F>
- Type Parameters:
F- family-type, the type returned theduplicateBean()method is called
- Direct Known Subclasses:
Define,DefineAdderBean,DoubleList,DoubleSet,InitializableBean,IntegerList,IntegerSet,PermuteProperty,SequenceInteger,StringList,StringSet
The base class of all beans used in Anchor.
The family-type exists as a templated parameter <F> to return a sensibly-typed object
when duplicateBean() is called. Typically, this is either the type of the class itself, or
an abstract base class representing a family of similar classes. A bean must always be assignable
from (i.e. be equal to or inherit from) the family-type it is associated with.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckMisconfigured(BeanInstanceMap defaultInstances) Checks that a bean's properties conform to expectations.A (maybe longer) description identifying the bean and perhaps its key parameters.protected StringGenerates a string describing the children of the current bean.Creates a new bean that deep-copies every property value.fields()A list of all bean-fields that are associated with this bean directly (fields of children are not checked).<T extends AnchorBean<?>>
List<T> findFieldsOfClass(Class<?> match) Finds all bean-fields that are instances of a certain class.final StringA short-name identifying a bean (by default the name of the class associated with the bean).A local path on the file-system, optionally associated with this bean.voidCalled once after the bean is created, localising the bean to a path on the filesystem.toString()By default, we usedescribeBean()as the string representation of the bean.
-
Constructor Details
-
AnchorBean
public AnchorBean()
-
-
Method Details
-
getBeanName
A short-name identifying a bean (by default the name of the class associated with the bean).- Returns:
- the short-name of the bean
-
describeBean
A (maybe longer) description identifying the bean and perhaps its key parameters.By default, it returns the same as
getBeanName()but beans can optionally override it- Returns:
- either the short-name of the bean, or a longer description
-
getLocalPath
-
toString
By default, we usedescribeBean()as the string representation of the bean. -
localise
Called once after the bean is created, localising the bean to a path on the filesystem.It is sometimes useful to override this method so as to include other files.
- Parameters:
path- a path on the filesystem which is associated with the bean (can be null, indicating no localization)- Throws:
BeanMisconfiguredException- if a relative-path is passed
-
checkMisconfigured
Checks that a bean's properties conform to expectations.- Parameters:
defaultInstances- all available default instances if theDefaultInstanceannotation is used- Throws:
BeanMisconfiguredException- if the bean has not been configured properly as XML
-
duplicateBean
-
describeChildren
Generates a string describing the children of the current bean.- Returns:
- a string describing the children.
-
findFieldsOfClass
public <T extends AnchorBean<?>> List<T> findFieldsOfClass(Class<?> match) throws BeanMisconfiguredException Finds all bean-fields that are instances of a certain class.All immediate children are checked, and any items in immediate lists.
- Type Parameters:
T- the type of bean returned in the list- Parameters:
match- the class that a field must be assignable from (equal to or inherit from)- Returns:
- a list of all bean-fields that match the criteria
- Throws:
BeanMisconfiguredException- if we discover the bean has been misconfigured
-
fields
-