Module org.bzdev.obnaming
Package org.bzdev.obnaming
Class ParmManager<T extends NamedObjectFactory>
java.lang.Object
org.bzdev.obnaming.ParmManager<T>
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAll
(Collection<Parm> collection) Add every Parm in a collection.protected void
Add every Parm in an array.protected void
addDocResourceBundle
(String baseName, Class clazz) Add a resource bundle for docs associated with configuration entries.protected void
addDocResourceBundle
(String keyPrefix, String delimiter, String baseName, Class clazz) Add a resource bundle for docs associated with compound configuration entries.protected void
addLabelResourceBundle
(String baseName, Class clazz) Add a resource bundle for labels associated with configuration parameters.protected void
addLabelResourceBundle
(String keyPrefix, String delimiter, String baseName, Class clazz) Add a resource bundle for labels associated with keyed configuration parameters.protected void
Add a Parm.protected void
addTipResourceBundle
(String baseName, Class clazz) Add a resource bundle for tips associated with configuration entries.protected void
addTipResourceBundle
(String keyPrefix, String delimiter, String baseName, Class clazz) Add a resource bundle for tips associated with compound configuration entries.protected T
Get the factory.Return the parameter data that a ParmManager provides for a given name.protected Parm[]
getParms()
Get the Parm instances that have been defined.protected abstract void
setDefaults
(T factory) Set factory fields to their default values.
-
Constructor Details
-
ParmManager
Constructor.- Parameters:
factory
- the factory that will interact with this ParmManager
-
-
Method Details
-
getParms
Get the Parm instances that have been defined.- Returns:
- an array of Parm
-
getParm
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
Add a Parm.- Parameters:
parm
- the Parm to add
-
addAll
Add every Parm in a collection.- Parameters:
collection
- the Parm collection
-
addALL
Add every Parm in an array.- Parameters:
parms
- an array of the Parm instances to add
-
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 resourceclazz
- 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 namedelimiter
- the delimiter for a keyed parameter namebaseName
- the fully qualified name of a class representing this resourceclazz
- 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 resourceclazz
- 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 namedelimiter
- the delimiter for a keyed parameter namebaseName
- the fully qualified name of a class representing this resourceclazz
- 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 resourceclazz
- 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 namedelimiter
- the delimiter for a keyed parameter namebaseName
- the fully qualified name of a class representing this resourceclazz
- the class of the parm manager adding the resource bundle- Throws:
NullPointerException
MissingResourceException
-
setDefaults
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
-