com.emarsys.ecommon.prefs.config.backend
Class ImmutableConfigurationBackend

java.lang.Object
  extended by com.emarsys.ecommon.prefs.config.backend.ImmutableConfigurationBackend
All Implemented Interfaces:
ConfigurationBackend

public class ImmutableConfigurationBackend
extends java.lang.Object
implements ConfigurationBackend

An immutable or read-only wrapper for ConfigurationBackends.

An ImmutableConfigurationBackend will behave exactly like its wrapped ConfigurationBackend but prevent changes by throwing ImmutableObjectExceptions on every call to set(ISetting).

Author:
Michael "kULO" Kulovits

Field Summary
protected  ConfigurationBackend backend
           
 
Constructor Summary
ImmutableConfigurationBackend(ConfigurationBackend backend)
           
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 ISetting get(java.lang.String name)
          Retrieves the ISetting with the passed name.
protected  java.lang.reflect.InvocationHandler getInvocationHandler()
          Creates a new InvocationHandler that will forward requests to this instance, see #wrap(ConfigurationBackend).
 java.util.List<ISetting> getSettings()
           Retrieves all ISettings from this backend.
 int hashCode()
           
 void set(ISetting setting)
          Will throw an ImmutableObjectException if called.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

backend

protected ConfigurationBackend backend
Constructor Detail

ImmutableConfigurationBackend

public ImmutableConfigurationBackend(ConfigurationBackend backend)
Parameters:
backend -
Method Detail

get

public ISetting get(java.lang.String name)
             throws java.lang.IllegalArgumentException
Description copied from interface: ConfigurationBackend
Retrieves the ISetting with the passed name.

Specified by:
get in interface ConfigurationBackend
Returns:
the ISetting with the passed name or null if not present.
Throws:
java.lang.IllegalArgumentException - - if the passed name is null.
See Also:
com.emarsys.core.setting.backend.ConfigurationBackend#get(java.lang.String)

getSettings

public java.util.List<ISetting> getSettings()
Description copied from interface: ConfigurationBackend

Retrieves all ISettings from this backend.

What exactly "all" means in the context of the concrete ConfigurationBackend is up to the implementation. For instance the List may or may not contain default values or fallbacked ISettings or might even return a cached list.

The only requirement for this method is to be logically in synch with ConfigurationBackend.get(String) and ConfigurationBackend.set(ISetting). Thus if a Setting is inserted/updated/deleted and nothing is changed in the meantime the next call to ConfigurationBackend.getSettings() has to reflect the changes made.

Specified by:
getSettings in interface ConfigurationBackend
Returns:
always a valid List of ISettings, never null.
See Also:
com.emarsys.core.setting.backend.ConfigurationBackend#getSettings()

set

public void set(ISetting setting)
         throws java.lang.IllegalArgumentException,
                ImmutableObjectException
Will throw an ImmutableObjectException if called.

Specified by:
set in interface ConfigurationBackend
Throws:
ImmutableObjectException - - in any case
java.lang.IllegalArgumentException - - if the passed setting, its name or value is null.
See Also:
com.emarsys.core.setting.backend.ConfigurationBackend#set(com.emarsys.ecommon.prefs.config.ISetting)

getInvocationHandler

protected java.lang.reflect.InvocationHandler getInvocationHandler()
Creates a new InvocationHandler that will forward requests to this instance, see #wrap(ConfigurationBackend).

Returns:

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


Copyright © 2010 emarsys AG. All Rights Reserved.