org.eclipse.ocl.examples.pivot
Class AbstractBasicEnvironment<P extends BasicEnvironment>

java.lang.Object
  extended by org.eclipse.ocl.examples.pivot.AbstractBasicEnvironment<P>
All Implemented Interfaces:
Adaptable, BasicEnvironment, Customizable
Direct Known Subclasses:
AbstractEnvironment, AbstractEvaluationEnvironment

public abstract class AbstractBasicEnvironment<P extends BasicEnvironment>
extends java.lang.Object
implements BasicEnvironment

Partial implementation of the BasicEnvironment interface, providing default behaviours for most features.


Field Summary
protected  P parent
           
 
Constructor Summary
protected AbstractBasicEnvironment(P parent)
          Initializes me with the specified parent environment.
 
Method Summary
protected  java.util.Map<Option<?>,java.lang.Object> basicGetOptions()
           
 java.util.Map<Option<?>,java.lang.Object> clearOptions()
          Clears all options.
<T> T
getAdapter(java.lang.Class<T> adapterType)
          Implements the interface method by testing whether I am an instance of the requested adapter type.
 java.util.Map<Option<?>,java.lang.Object> getOptions()
          Obtains a copy of my map of options.
 P getParent()
           
<T> T
getValue(Option<T> option)
          Obtains the value of the specified option's setting in the my options map.
 boolean isEnabled(Option<java.lang.Boolean> option)
          Queries whether the specified boolean-valued option is enabled.
 boolean notOK(Option<ProblemHandler.Severity> option)
          Queries whether I have a non-OK setting for the specified problem option.
<T> void
putOptions(java.util.Map<? extends Option<T>,? extends T> newOptions)
          Adds options to apply to my behaviour.
<T> T
removeOption(Option<T> option)
          Removes the specified option.
<T> java.util.Map<Option<T>,T>
removeOptions(java.util.Collection<Option<T>> unwantedOptions)
          Removes the specified options.
<T> void
setOption(Option<T> option, T value)
          Add an option to apply to my behaviour.
protected  void setParent(P parent)
          Assigns me a parent environment after construction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

@Nullable
protected P extends BasicEnvironment parent
Constructor Detail

AbstractBasicEnvironment

protected AbstractBasicEnvironment(P parent)
Initializes me with the specified parent environment.

Parameters:
parent - an environment (or null)
Method Detail

basicGetOptions

@NonNull
protected final java.util.Map<Option<?>,java.lang.Object> basicGetOptions()

clearOptions

@NonNull
public java.util.Map<Option<?>,java.lang.Object> clearOptions()
Description copied from interface: Customizable
Clears all options.

Specified by:
clearOptions in interface Customizable
Returns:
the former values of the options

getAdapter

public <T> T getAdapter(java.lang.Class<T> adapterType)
Implements the interface method by testing whether I am an instance of the requested adapter type.

Specified by:
getAdapter in interface Adaptable
Type Parameters:
T - the requested adapter interface
Parameters:
adapterType - the requested adapter interface
Returns:
an instance of the requested interface, or null if this environment does not adapt to it

getOptions

public java.util.Map<Option<?>,java.lang.Object> getOptions()
Description copied from interface: Customizable
Obtains a copy of my map of options. Options not explicitly set in an environment are inherited from the parent environment, if any, otherwise they are at their default values.

Specified by:
getOptions in interface Customizable
Returns:
the map of options

getParent

public final P getParent()

getValue

@Nullable
public <T> T getValue(@NonNull
                               Option<T> option)
Description copied from interface: Customizable
Obtains the value of the specified option's setting in the my options map. Options not explicitly set in an environment are inherited from the parent environment, if any, otherwise they are at their default values.

Specified by:
getValue in interface Customizable
Parameters:
option - the option to query
Returns:
value of the option

isEnabled

public boolean isEnabled(@NonNull
                         Option<java.lang.Boolean> option)
Description copied from interface: Customizable
Queries whether the specified boolean-valued option is enabled. This method essentially just puts a nice "is" name on boolean options. Options not explicitly set in an environment are inherited from the parent environment, if any, otherwise they are at their default values.

Specified by:
isEnabled in interface Customizable
Parameters:
option - an option
Returns:
whether the option is enabled

notOK

public boolean notOK(@NonNull
                     Option<ProblemHandler.Severity> option)
Queries whether I have a non-OK setting for the specified problem option. In such cases, I will need to be concerned with reporting the problem.

Parameters:
option - the problem option
Returns:
whether I have a setting for it that is not OK
See Also:
ProblemHandler.Severity.OK

putOptions

public <T> void putOptions(@NonNull
                           java.util.Map<? extends Option<T>,? extends T> newOptions)
Description copied from interface: Customizable
Adds options to apply to my behaviour.

Specified by:
putOptions in interface Customizable
Parameters:
newOptions - the options

removeOption

@Nullable
public <T> T removeOption(@NonNull
                                   Option<T> option)
Description copied from interface: Customizable
Removes the specified option.

Specified by:
removeOption in interface Customizable
Parameters:
option - the option to remove
Returns:
the former value of the option

removeOptions

@NonNull
public <T> java.util.Map<Option<T>,T> removeOptions(@NonNull
                                                            java.util.Collection<Option<T>> unwantedOptions)
Description copied from interface: Customizable
Removes the specified options.

Specified by:
removeOptions in interface Customizable
Parameters:
unwantedOptions - the options to remove
Returns:
the former values of the options

setOption

public <T> void setOption(@NonNull
                          Option<T> option,
                          @Nullable
                          T value)
Description copied from interface: Customizable
Add an option to apply to my behaviour.

Specified by:
setOption in interface Customizable
Parameters:
option - the option
value - the option's value

setParent

protected void setParent(P parent)
Assigns me a parent environment after construction. It is not advisable to set the parent to null if I previously had one.

Parameters:
parent - my new parent