Class 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
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractEnvironment

        public AbstractEnvironment()
    • 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 interface Environment
        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. A ClassCastException will eventually be thrown if the given value is not the generic type requested.
        Specified by:
        getProperty in interface Environment
        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. A ClassCastException will eventually be thrown if the given value is not the generic type requested.
        Specified by:
        getProperty in interface Environment
        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, or null 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. A ClassCastException will eventually be thrown if the given value is not the generic type requested.
        Specified by:
        getRequiredProperty in interface Environment
        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 interface Environment
        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 interface Environment
        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 interface Environment
        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 interface Environment
        Returns:
        The available environment properties.