org.specrunner.features.core
Class FeatureManagerImpl

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<String,Object>
          extended by org.specrunner.features.core.FeatureManagerImpl
All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>, IFeatureManager

public class FeatureManagerImpl
extends HashMap<String,Object>
implements IFeatureManager

Default feature manager implementation.

Author:
Thiago Santos
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected  IConfiguration configuration
          The current configuration.
protected  Map<String,Boolean> overrides
          Set of overrides information.
 
Constructor Summary
FeatureManagerImpl()
           
 
Method Summary
 IFeatureManager add(String key, Object value)
          Set a feature to a value.
 IFeatureManager add(String key, Object value, boolean override)
          Set a feature to a value.
 Object get(Object key)
           
 Object get(String key, Object defaultValue)
          Get a value from map, if not found, result is 'defaultValue'.
 IConfiguration getConfiguration()
          Gets the configuration.
protected  String getField(String feature)
          Recover the property name for the feature.
 Object put(String key, Object value)
           
 void set(String feature, Object target)
          Sets a feature to an object if the feature exists and the type is compatible.
 void setConfiguration(IConfiguration configuration)
          Set a set of local configuration as complementary information to feature settings.
 void setStrict(String feature, Object target)
          Sets a feature to an object if the feature exists and the type is compatible.
protected  void setValue(String feature, Object value, Object target, String field, IAccess access)
          Set the value.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, hashCode, isEmpty, keySet, putAll, remove, size, values
 

Field Detail

overrides

protected Map<String,Boolean> overrides
Set of overrides information.


configuration

protected IConfiguration configuration
The current configuration.

Constructor Detail

FeatureManagerImpl

public FeatureManagerImpl()
Method Detail

put

public Object put(String key,
                  Object value)
Specified by:
put in interface Map<String,Object>
Overrides:
put in class HashMap<String,Object>

add

public IFeatureManager add(String key,
                           Object value)
Description copied from interface: IFeatureManager
Set a feature to a value.

Specified by:
add in interface IFeatureManager
Parameters:
key - The feature name.
value - The value.
Returns:
The manager itself.

add

public IFeatureManager add(String key,
                           Object value,
                           boolean override)
Description copied from interface: IFeatureManager
Set a feature to a value.

Specified by:
add in interface IFeatureManager
Parameters:
key - The feature name.
value - The value.
override - true, if the value should overwrite previous values, false, otherwise.
Returns:
The manager itself.

get

public Object get(Object key)
Specified by:
get in interface Map<String,Object>
Overrides:
get in class HashMap<String,Object>

set

public void set(String feature,
                Object target)
Description copied from interface: IFeatureManager
Sets a feature to an object if the feature exists and the type is compatible.

Specified by:
set in interface IFeatureManager
Parameters:
feature - The feature name.
target - The object where the feature must be set.

setStrict

public void setStrict(String feature,
                      Object target)
               throws FeatureManagerException
Description copied from interface: IFeatureManager
Sets a feature to an object if the feature exists and the type is compatible. Throws error if set is not possible.

Specified by:
setStrict in interface IFeatureManager
Parameters:
feature - The feature name.
target - The object where the feature must be set.
Throws:
FeatureManagerException - On object setup.

getField

protected String getField(String feature)
                   throws FeatureManagerException
Recover the property name for the feature.

Parameters:
feature - The feature name.
Returns:
The field name, if it exists.
Throws:
FeatureManagerException - On field name recovery errors.

setValue

protected void setValue(String feature,
                        Object value,
                        Object target,
                        String field,
                        IAccess access)
                 throws FeatureManagerException
Set the value.

Parameters:
feature - The feature name.
value - The feature value.
target - The target object.
field - The target field.
access - The field access.
Throws:
FeatureManagerException - On setting error.

getConfiguration

public IConfiguration getConfiguration()
Gets the configuration.

Returns:
The configuration.

setConfiguration

public void setConfiguration(IConfiguration configuration)
Description copied from interface: IFeatureManager
Set a set of local configuration as complementary information to feature settings. When a instance of a ISpecRunner received a IConfiguration, this is set here as local and at the beginning of a new test execution it can be just replaced.

Specified by:
setConfiguration in interface IFeatureManager
Parameters:
configuration - Set configuration features.

get

public Object get(String key,
                  Object defaultValue)
Description copied from interface: IFeatureManager
Get a value from map, if not found, result is 'defaultValue'.

Specified by:
get in interface IFeatureManager
Parameters:
key - A name.
defaultValue - The default value.
Returns:
The key value, or defaultValue, if not found.


Copyright © 2014. All rights reserved.