Package io.guise.framework.platform
Class AbstractEnvironment
- java.lang.Object
-
- io.guise.framework.platform.AbstractEnvironment
-
- All Implemented Interfaces:
Environment
- Direct Known Subclasses:
DefaultEnvironment
public class AbstractEnvironment extends java.lang.Object implements Environment
An abstract implementation of the platform user local environment.- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description AbstractEnvironment()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.Object>
getProperties()
Returns the available environment properties as a read-only map of property names and values.<T> T
getProperty(java.lang.String name)
Retrieves an environment property by its name.<T> T
getProperty(java.lang.String name, T defaultValue)
Retrieves an environment property by its name, returning a default value if no value is available.<T> T
getRequiredProperty(java.lang.String name)
Retrieves a required environment property by its name, throwing an exception if the value is missing.boolean
hasProperty(java.lang.String name)
Determines if an environment property exists.void
removeProperty(java.lang.String name)
Removes the property specified by the given name.void
setProperties(java.util.Map<java.lang.String,java.lang.Object> map)
Sets multiple environment properties.void
setProperty(java.lang.String name, java.lang.Object value)
Sets an environment property.
-
-
-
Method Detail
-
hasProperty
public boolean hasProperty(java.lang.String name)
Description copied from interface:Environment
Determines if an environment property exists.- Specified by:
hasProperty
in interfaceEnvironment
- Parameters:
name
- The name of the property to check.- Returns:
true
if the environment has the given property.
-
getProperty
public <T> T getProperty(java.lang.String name)
Description copied from interface:Environment
Retrieves an environment property by its name. AClassCastException
will eventually be thrown if the given value is not the generic type requested.- Specified by:
getProperty
in interfaceEnvironment
- Type Parameters:
T
- The type of property value expected.- Parameters:
name
- The name of the property to retrieve.- Returns:
- The property value, or
null
if there is no such property.
-
getProperty
public <T> T getProperty(java.lang.String name, T defaultValue)
Description copied from interface:Environment
Retrieves an environment property by its name, returning a default value if no value is available. AClassCastException
will eventually be thrown if the given value is not the generic type requested.- Specified by:
getProperty
in interfaceEnvironment
- Type Parameters:
T
- The type of property value expected.- Parameters:
name
- The name of the property to retrieve.defaultValue
- The value to return if no such property is available, ornull
if there is no default value.- Returns:
- The property value, or the provided default value if there is no such property.
-
getRequiredProperty
public <T> T getRequiredProperty(java.lang.String name)
Description copied from interface:Environment
Retrieves a required environment property by its name, throwing an exception if the value is missing. AClassCastException
will eventually be thrown if the given value is not the generic type requested.- Specified by:
getRequiredProperty
in interfaceEnvironment
- Type Parameters:
T
- The type of property value expected.- Parameters:
name
- The name of the property to retrieve.- Returns:
- The property value.
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value)
Description copied from interface:Environment
Sets an environment property.- Specified by:
setProperty
in interfaceEnvironment
- Parameters:
name
- The name of the property.value
- The value to associate with the name.
-
setProperties
public void setProperties(java.util.Map<java.lang.String,java.lang.Object> map)
Description copied from interface:Environment
Sets multiple environment properties.- Specified by:
setProperties
in interfaceEnvironment
- Parameters:
map
- The map of property names and values to set.
-
removeProperty
public void removeProperty(java.lang.String name)
Description copied from interface:Environment
Removes the property specified by the given name.- Specified by:
removeProperty
in interfaceEnvironment
- Parameters:
name
- The name of the property to remove.
-
getProperties
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
Description copied from interface:Environment
Returns the available environment properties as a read-only map of property names and values.- Specified by:
getProperties
in interfaceEnvironment
- Returns:
- The available environment properties.
-
-