Package org.sm.smtools.application.util
Enum Class Registry
- All Implemented Interfaces:
Serializable
,Comparable<Registry>
,Constable
The
Registry
class provides a mechanism for accessing (persistent) global variables.
The Registry
class is actually a singleton instance, and a local reference to it
should be obtained as follows:
Registry registry = Registry.kINSTANCE;The registry contains serialisable objects that can be stored and retrieved via a
String
key using the
addObject(String,Object)
and getObject(String)
methods.- Version:
- 26/06/2018
- Author:
- Sven Maerivoet
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an object to the registry.void
clear()
Clears the registry.Returns an object from the registry.void
Loads all objects in the registry from a file using deserialisation.void
Saves all objects in the registry to a file using serialisation.static Registry
Returns the enum constant of this class with the specified name.static Registry[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
kINSTANCE
The singleton instance.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
clear
public void clear()Clears the registry. -
addObject
Adds an object to the registry.- Parameters:
name
- the name of the objectobject
- a reference to the object
-
getObject
Returns an object from the registry.- Parameters:
name
- the name of the object- Returns:
- a reference to the object
-
load
Loads all objects in the registry from a file using deserialisation.- Parameters:
filename
- the name of the file to load the registry from- Throws:
RegistryException
- if an error occurred during the deserialisation process
-
save
Saves all objects in the registry to a file using serialisation.Note that care should be taken that all the objects are serialisable.
- Parameters:
filename
- the name of the file to save the registry to- Throws:
RegistryException
- if an error occurred during the serialisation process
-