Class AnchorBean<F>

Object
AnchorBean<F>
Type Parameters:
F - family-type, the type returned the duplicateBean() method is called
Direct Known Subclasses:
AddCriteriaPair, AnnotationBackground, AnnotationComparisonAssigner, AnnotationLabel, AnnotatorStrategy, BlurStrategy, BoundRotation, BoxAligner, Cell, ChannelAggregator, ChannelConvertStyle, ChannelMapCreator, CheckParsedFilePathBag, ColorScheme, CombineObjectsForFeatures, ComparableSource, ConvertChannelToWithHistogram, CopyFilesMethod, CopyFilesNaming, CreateMarkFromPoints, DecodeInstanceSegmentation, Define, DefineAdderBean, DefineOutputter, DerivePath, DirectionVectorBean, DoubleList, DoubleSet, DrawObject, Experiment, ExperimentIdentifier, ExportFeaturesStyle, FeatureList, FeatureSource, FileNamer, FilePath, FilePathMatcher, FilePathParser, FilesProvider, FromStacks, GrayscaleReconstructionByErosion, Grouper, HeaderFormat, HOGParameters, ImageLabeller, ImageMetadataReader, IndexedChannel, InitializableBean, InputManager, IntegerList, IntegerSet, Interpolator, JobProcessor, LoggingDestination, MarkBounds, MarkFactory, MarkRegion, MinimaImposition, MorphologicalIterations, MultipleComparer, OutputEnabled, OutputEnabledRules, OutputManager, OutputWriteSettings, Padding, PathPrefixer, PermuteProperty, RandomCollection, RandomNumberGeneratorBean, ReadOptions, ReduceElements, RegEx, RegionMap, RegionMembership, RelationBean, RelationToThreshold, RequireArguments, ResolvedBound, RGBColorBean, RootPath, SequenceInteger, SizeXY, StackArranger, StackDisplayer, StackReader, StackWriter, StringList, StringMap, StringMapItem, StringSet, Summarizer, Task, TextStyle, ThumbnailFromObjects, ThumbnailFromStack, TimestampPattern, UnitValueDistance, UnitValueExtent

public abstract class AnchorBean<F> extends Object
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 Details

    • AnchorBean

      public AnchorBean()
  • Method Details

    • getBeanName

      public final String 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

      public String 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

      public Optional<Path> getLocalPath()
      A local path on the file-system, optionally associated with this bean.

      The association is usually established when a bean is loaded (deserialized) from a file.

      Returns:
      the local-path, if defined.
    • toString

      public String toString()
      By default, we use describeBean() as the string representation of the bean.
      Overrides:
      toString in class Object
      Returns:
      the string representation
    • localise

      public void localise(Path path) throws BeanMisconfiguredException
      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

      public void checkMisconfigured(BeanInstanceMap defaultInstances) throws BeanMisconfiguredException
      Checks that a bean's properties conform to expectations.
      Parameters:
      defaultInstances - all available default instances if the DefaultInstance annotation is used
      Throws:
      BeanMisconfiguredException - if the bean has not been configured properly as XML
    • duplicateBean

      public F duplicateBean()
      Creates a new bean that deep-copies every property value.

      Any state that is not a BeanField is ignored.

      Returns:
      the newly created bean
    • describeChildren

      protected String 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

      public List<Field> fields()
      A list of all bean-fields that are associated with this bean directly (fields of children are not checked).

      This operation is cached as the necessary reflection calls are costly.

      Returns:
      a list of bean-fields associated with the current bean