F
- family-type, the type returned the duplicateBean()
method is calledpublic abstract class AnchorBean<F> extends Object
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.
Constructor and Description |
---|
AnchorBean() |
Modifier and Type | Method and Description |
---|---|
void |
checkMisconfigured(BeanInstanceMap defaultInstances)
Checks that a bean's properties conform to expectations.
|
String |
describeBean()
A (maybe longer) description identifying the bean and perhaps its key parameters.
|
protected String |
describeChildren()
Generates a string describing the children of the current bean.
|
F |
duplicateBean()
Creates a new bean that deep-copies every property value.
|
List<Field> |
fields()
A list of all bean-fields that are associated with this bean directly (fields of
children are not checked).
|
<T extends AnchorBean<?>> |
findFieldsOfClass(Class<?> match)
Finds all bean-fields that are instances of a certain class.
|
String |
getBeanName()
A short-name identifying a bean (by default the name of the class associated with the bean).
|
Path |
getLocalPath()
A local path on the filesystem associated with this bean (from serialization) if defined.
|
void |
localise(Path path)
Called once after the bean is created, localising the bean to a path on the filesystem.
|
String |
toString()
By default, we use
describeBean() as the string representation of the bean. |
public final String getBeanName()
public String describeBean()
By default, it returns the same as getBeanName()
but beans can optionally override
it
public String toString()
describeBean()
as the string representation of the bean.public void localise(Path path) throws BeanMisconfiguredException
It is sometimes useful to override this method so as to include other files.
path
- a path on the filesystem which is associated with the bean (can be null,
indicating no localization)BeanMisconfiguredException
- if a relative-path is passedpublic void checkMisconfigured(BeanInstanceMap defaultInstances) throws BeanMisconfiguredException
defaultInstances
- all available default instances if the DefaultInstance
annotation is usedBeanMisconfiguredException
- if the bean has not been configured properly as XMLpublic F duplicateBean()
Any state that is not a BeanField
is ignored.
protected String describeChildren()
public <T extends AnchorBean<?>> List<T> findFieldsOfClass(Class<?> match) throws BeanMisconfiguredException
All immediate children are checked, and any items in immediate lists.
T
- the type of bean returned in the listmatch
- the class that a field must be assignable from (equal to or inherit from)BeanMisconfiguredException
- if we discover the bean has been misconfiguredpublic List<Field> fields()
This operation is cached as the necessary reflection calls are costly.
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.