Class OutputWriteSettings

Object
AnchorBean<OutputWriteSettings>
OutputWriteSettings

public class OutputWriteSettings extends AnchorBean<OutputWriteSettings>
Settings for how to write output, including default writers.

It is very important that initialize(org.anchoranalysis.bean.BeanInstanceMap) is run before using the bean. This normally occurs from checkMisconfigured() that is called automatically from the bean-loading framework

However, if the bean is not loaded through this mechanism, please call initialize(org.anchoranalysis.bean.BeanInstanceMap) explicitly before usage.

  • Constructor Details

    • OutputWriteSettings

      public OutputWriteSettings()
  • Method Details

    • checkMisconfigured

      public void checkMisconfigured(BeanInstanceMap defaultInstances) throws BeanMisconfiguredException
      Description copied from class: AnchorBean
      Checks that a bean's properties conform to expectations.
      Overrides:
      checkMisconfigured in class AnchorBean<OutputWriteSettings>
      Parameters:
      defaultInstances - all available default instances if the DefaultInstance annotation is used
      Throws:
      BeanMisconfiguredException - if the bean has not been configured properly as XML
    • initialize

      public void initialize(BeanInstanceMap defaultInstances) throws BeanMisconfiguredException
      This method should be called once on this object before further calling getWriterInstance(java.lang.Class<? extends T>).

      It will setup internally a state mapping different types of writers to instances, using default values where appropriate.

      Parameters:
      defaultInstances - a map indicating defaults of different instance types.
      Throws:
      BeanMisconfiguredException - if an error occurs creating any type of writer.
    • hasBeenInitialized

      public boolean hasBeenInitialized()
      Whether the method initialize(org.anchoranalysis.bean.BeanInstanceMap) has been called yet?
      Returns:
      true if the above method has been called at least once, false otherwise.
    • getWriterInstance

      public <T> Optional<T> getWriterInstance(Class<? extends T> writerFamilyType)
      Gets a writer-instance for a particular writerParentClass.

      1. First, it looks for a match among the bean-field 'writers' 2. If no match is found, then it looks among the general default-instances 3. If no match is found, then it returns null.

      When a writer is returned, it will always inherits from type c.

      Parameters:
      writerFamilyType - the class identifying which type of writer is sought
      Returns:
      a matching writer, or null.
    • getDefaultColors

      public ColorScheme getDefaultColors()
      The default color-scheme used for outputs, if no other scheme is specified.
    • setDefaultColors

      public void setDefaultColors(ColorScheme defaultColors)
      The default color-scheme used for outputs, if no other scheme is specified.
    • getWriters

      public List<NamedBean<?>> getWriters()
      Specifies a writer bean instance for a particular type of writer (identified by the writer bean class)
    • setWriters

      public void setWriters(List<NamedBean<?>> writers)
      Specifies a writer bean instance for a particular type of writer (identified by the writer bean class)