org.millscript.commons.util.defaults
Class ConstantListDefault<V>

java.lang.Object
  extended by org.millscript.commons.util.defaults.ConstantListDefault<V>
All Implemented Interfaces:
IListDefault<V>, IMapDefault<java.lang.Integer,V>

public class ConstantListDefault<V>
extends java.lang.Object
implements IListDefault<V>

The class provides a default implementation which returns a constant value.


Constructor Summary
ConstantListDefault(V def)
          Constructs a new constant default object which will use the specified default value.
 
Method Summary
 V first(IList<V> list)
          Returns the value to use when there is no first element in the list.
 V get(IMap<java.lang.Integer,V> map, java.lang.Integer key)
          Returns the value to use when the specified key is not valid in the for the mapping.
 V last(IList<V> list)
          Returns the value to use when there is no last element in the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstantListDefault

public ConstantListDefault(V def)
Constructs a new constant default object which will use the specified default value.

Parameters:
def - the default value
Method Detail

first

public V first(IList<V> list)
Description copied from interface: IListDefault
Returns the value to use when there is no first element in the list.

Specified by:
first in interface IListDefault<V>
Parameters:
list - the list which requested the default value for the first element
Returns:
the default value for when there is no first element
See Also:
IListDefault.first(IList)

get

public V get(IMap<java.lang.Integer,V> map,
             java.lang.Integer key)
Description copied from interface: IMapDefault
Returns the value to use when the specified key is not valid in the for the mapping.

Specified by:
get in interface IMapDefault<java.lang.Integer,V>
Parameters:
map - the map which requested the default value for the given key
key - the key that is not valid for the mapping
Returns:
the default value for when the key is not valid
See Also:
org.millscript.commons.util.IMapDefault#get(IMap, K)

last

public V last(IList<V> list)
Description copied from interface: IListDefault
Returns the value to use when there is no last element in the list.

Specified by:
last in interface IListDefault<V>
Parameters:
list - the list which requested the default value for the last element
Returns:
the default value for when there is no last element
See Also:
IListDefault.last(IList)


Copyright © 2005-2007 Open World Ltd. All Rights Reserved.