org.syphr.prom
Class PropertiesManagers

java.lang.Object
  extended by org.syphr.prom.PropertiesManagers

public class PropertiesManagers
extends Object

This class provides builder methods to construct managers with various options.

Author:
Gregory P. Moyer

Method Summary
static
<T extends Enum<T> & Defaultable>
Properties
getDefaultProperties(Class<T> keyType, Translator<T> translator)
          Retrieve a Properties instance that contains all of the default values defined for the given Defaultable.
static
<T extends Enum<T>>
Translator<T>
getDefaultTranslator(Class<T> enumType)
          Get the default translator to convert back and forth between Enums and property names (keys).
static Properties getProperties(File file)
          Load values from a file.
static
<T extends Enum<T> & Defaultable>
PropertiesManager<T>
newManager(File file, Class<T> keyType)
          Build a new manager for the given properties file.
static
<T extends Enum<T> & Defaultable>
PropertiesManager<T>
newManager(File file, Class<T> keyType, Evaluator evaluator, ExecutorService executor)
          Build a new manager for the given properties file.
static
<T extends Enum<T> & Defaultable>
PropertiesManager<T>
newManager(File file, Class<T> keyType, ExecutorService executor)
          Build a new manager for the given properties file.
static
<T extends Enum<T> & Defaultable>
PropertiesManager<T>
newManager(File file, Class<T> keyType, Translator<T> translator, ExecutorService executor)
          Build a new manager for the given properties file.
static
<T extends Enum<T>>
PropertiesManager<T>
newManager(File file, File defaultFile, Class<T> keyType)
          Build a new manager for the given properties file.
static
<T extends Enum<T>>
PropertiesManager<T>
newManager(File file, File defaultFile, Class<T> keyType, ExecutorService executor)
          Build a new manager for the given properties file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newManager

public static <T extends Enum<T>> PropertiesManager<T> newManager(File file,
                                                                  File defaultFile,
                                                                  Class<T> keyType)
                                                       throws IOException
Build a new manager for the given properties file.

Type Parameters:
T - the type of key used for the new manager
Parameters:
file - the file system location of the properties represented by the new manager
defaultFile - a file containing default values for the properties represented by the new manager
keyType - the enumeration of keys in the properties file
Returns:
a new manager
Throws:
IOException - if there is an error while reading the default properties

newManager

public static <T extends Enum<T>> PropertiesManager<T> newManager(File file,
                                                                  File defaultFile,
                                                                  Class<T> keyType,
                                                                  ExecutorService executor)
                                                       throws IOException
Build a new manager for the given properties file.

Type Parameters:
T - the type of key used for the new manager
Parameters:
file - the file system location of the properties represented by the new manager
defaultFile - a file containing default values for the properties represented by the new manager
keyType - the enumeration of keys in the properties file
executor - a service to handle potentially long running tasks, such as interacting with the file system
Returns:
a new manager
Throws:
IOException - if there is an error while reading the default properties

newManager

public static <T extends Enum<T> & Defaultable> PropertiesManager<T> newManager(File file,
                                                                               Class<T> keyType)
Build a new manager for the given properties file.

Type Parameters:
T - the type of key used for the new manager
Parameters:
file - the file system location of the properties represented here
keyType - the enumeration of keys in the properties file
Returns:
a new manager

newManager

public static <T extends Enum<T> & Defaultable> PropertiesManager<T> newManager(File file,
                                                                               Class<T> keyType,
                                                                               ExecutorService executor)
Build a new manager for the given properties file.

Type Parameters:
T - the type of key used for the new manager
Parameters:
file - the file system location of the properties represented here
keyType - the enumeration of keys in the properties file
executor - a service to handle potentially long running tasks, such as interacting with the file system
Returns:
a new manager

newManager

public static <T extends Enum<T> & Defaultable> PropertiesManager<T> newManager(File file,
                                                                               Class<T> keyType,
                                                                               Translator<T> translator,
                                                                               ExecutorService executor)
Build a new manager for the given properties file.

Type Parameters:
T - the type of key used for the new manager
Parameters:
file - the file system location of the properties represented here
keyType - the enumeration of keys in the properties file
translator - the translator to convert between Enum names and property keys
executor - a service to handle potentially long running tasks, such as interacting with the file system
Returns:
a new manager

newManager

public static <T extends Enum<T> & Defaultable> PropertiesManager<T> newManager(File file,
                                                                               Class<T> keyType,
                                                                               Evaluator evaluator,
                                                                               ExecutorService executor)
Build a new manager for the given properties file.

Type Parameters:
T - the type of key used for the new manager
Parameters:
file - the file system location of the properties represented here
keyType - the enumeration of keys in the properties file
evaluator - the evaluator to convert nested property references into fully evaluated strings
executor - a service to handle potentially long running tasks, such as interacting with the file system
Returns:
a new manager

getProperties

public static Properties getProperties(File file)
                                throws IOException
Load values from a file.

Parameters:
file - the file containing default values
Returns:
a new properties instance loaded with values from the given file
Throws:
IOException - if there is an error while reading the given file

getDefaultProperties

public static <T extends Enum<T> & Defaultable> Properties getDefaultProperties(Class<T> keyType,
                                                                               Translator<T> translator)
Retrieve a Properties instance that contains all of the default values defined for the given Defaultable.

Type Parameters:
T - the key type whose default values are requested
Parameters:
keyType - the class that contains the appropriate defaults
translator - a translator to convert between key instances and property names
Returns:
a Properties instance containing the default values stored in the given key type

getDefaultTranslator

public static <T extends Enum<T>> Translator<T> getDefaultTranslator(Class<T> enumType)
Get the default translator to convert back and forth between Enums and property names (keys).

Type Parameters:
T - the type of Enum representing the properties
Parameters:
enumType - the Enum class used to represent the properties
Returns:
the default translator implementation


Copyright © 2010 Gregory P. Moyer. All Rights Reserved.