Class ParmManager<T extends NamedObjectFactory>

java.lang.Object
org.bzdev.obnaming.ParmManager<T>

public abstract class ParmManager<T extends NamedObjectFactory> extends Object
Class for managing a collection of Parm instances to simplify building named-object factories. Subclasses should implement a method named setDefaults that takes one argument (the factory) and that does not return a value. This method should restore all parameters associated with this ParmManager to their default values. It may be called by the factory to restore parameters defined using annotations to their default values when the factory's clear method is called.
  • Constructor Details

    • ParmManager

      protected ParmManager(T factory)
      Constructor.
      Parameters:
      factory - the factory that will interact with this ParmManager
  • Method Details

    • getParms

      protected Parm[] getParms()
      Get the Parm instances that have been defined.
      Returns:
      an array of Parm
    • getParm

      public Parm getParm(String name)
      Return the parameter data that a ParmManager provides for a given name. This is useful in cases where a particular parameter is removed by a factory after being installed from a ParmManager and access to the original is needed.
      Parameters:
      name - the name of the parameter
      Returns:
      the parameter data; null if there is none
    • addParm

      protected void addParm(Parm parm)
      Add a Parm.
      Parameters:
      parm - the Parm to add
    • addAll

      protected void addAll(Collection<Parm> collection)
      Add every Parm in a collection.
      Parameters:
      collection - the Parm collection
    • addALL

      protected void addALL(Parm[] parms)
      Add every Parm in an array.
      Parameters:
      parms - an array of the Parm instances to add
    • getFactory

      protected T getFactory()
      Get the factory.
      Returns:
      the factory used to initialize this object
    • addTipResourceBundle

      protected void addTipResourceBundle(String baseName, Class clazz) throws NullPointerException, MissingResourceException
      Add a resource bundle for tips associated with configuration entries. A subclass should call this method within the constructor.
      Parameters:
      baseName - the fully qualified name of a class representing this resource
      clazz - the class of the parm manager adding the resource bundle
      Throws:
      NullPointerException
      MissingResourceException
    • addTipResourceBundle

      protected void addTipResourceBundle(String keyPrefix, String delimiter, String baseName, Class clazz) throws NullPointerException, MissingResourceException
      Add a resource bundle for tips associated with compound configuration entries. A subclass should call this method within the constructor.
      Parameters:
      keyPrefix - the prefix for a keyed parameter name
      delimiter - the delimiter for a keyed parameter name
      baseName - the fully qualified name of a class representing this resource
      clazz - the class of the parm manager adding the resource bundle
      Throws:
      NullPointerException
      MissingResourceException
    • addDocResourceBundle

      protected void addDocResourceBundle(String baseName, Class clazz) throws NullPointerException, MissingResourceException
      Add a resource bundle for docs associated with configuration entries. A subclass should call this method within the constructor.
      Parameters:
      baseName - the fully qualified name of a class representing this resource
      clazz - the class of the parm manager adding the resource bundle
      Throws:
      NullPointerException
      MissingResourceException
    • addDocResourceBundle

      protected void addDocResourceBundle(String keyPrefix, String delimiter, String baseName, Class clazz) throws NullPointerException, MissingResourceException
      Add a resource bundle for docs associated with compound configuration entries. A subclass should call this method within the constructor.
      Parameters:
      keyPrefix - the prefix for a keyed parameter name
      delimiter - the delimiter for a keyed parameter name
      baseName - the fully qualified name of a class representing this resource
      clazz - the class of the parm manager adding the resource bundle
      Throws:
      NullPointerException
      MissingResourceException
    • addLabelResourceBundle

      protected void addLabelResourceBundle(String baseName, Class clazz) throws NullPointerException, MissingResourceException
      Add a resource bundle for labels associated with configuration parameters. A subclass should call this method within the constructor.
      Parameters:
      baseName - the fully qualified name of a class representing this resource
      clazz - the class of the parm manager adding the resource bundle
      Throws:
      NullPointerException
      MissingResourceException
    • addLabelResourceBundle

      protected void addLabelResourceBundle(String keyPrefix, String delimiter, String baseName, Class clazz) throws NullPointerException, MissingResourceException
      Add a resource bundle for labels associated with keyed configuration parameters. A subclass should call this method within the constructor.
      Parameters:
      keyPrefix - the prefix for a keyed parameter name
      delimiter - the delimiter for a keyed parameter name
      baseName - the fully qualified name of a class representing this resource
      clazz - the class of the parm manager adding the resource bundle
      Throws:
      NullPointerException
      MissingResourceException
    • setDefaults

      protected abstract void setDefaults(T factory)
      Set factory fields to their default values. The fields that will be set to their default values are the the fields associated with the parameters that this parameter manager defines.

      This method should be called by the factory's clear() method.

      Parameters:
      factory - the named-object factory associated with this parameter manager