org.jboss.portal.common.util
Class AbstractTypedMap.Converter<E,I>

java.lang.Object
  extended by org.jboss.portal.common.util.AbstractTypedMap.Converter<E,I>
Enclosing class:
AbstractTypedMap<EK,EV,IK,IV>

public abstract static class AbstractTypedMap.Converter<E,I>
extends java.lang.Object

Defines a converter that converts an internal value to an external value and vice versa. Null values will not passed as arguments to the methods and if a conversion method returns a null value it will be considered as a conversion failure although the implementations should not rely and this behavior and rather rely on a adapted exception.


Constructor Summary
AbstractTypedMap.Converter()
           
 
Method Summary
protected abstract  boolean equals(I left, I right)
          Compare internal values, the passed argument are never null so the method does not need to check nullity of the arguments.
protected abstract  E getExternal(I internal)
          Converts the internal value into its external representation.
protected abstract  I getInternal(E external)
          Converts the external value to the its internal representation that will be stored in the map.
static
<T> AbstractTypedMap.Converter<T,T>
identityConverter()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTypedMap.Converter

public AbstractTypedMap.Converter()
Method Detail

identityConverter

public static <T> AbstractTypedMap.Converter<T,T> identityConverter()

getInternal

protected abstract I getInternal(E external)
                          throws java.lang.IllegalArgumentException,
                                 java.lang.ClassCastException
Converts the external value to the its internal representation that will be stored in the map.

Parameters:
external - the external value
Returns:
the the internal value
Throws:
java.lang.ClassCastException - if the class of the specified argument prevents it from being converter
java.lang.IllegalArgumentException - if some aspect of this argument prevents it from being converted

getExternal

protected abstract E getExternal(I internal)
                          throws java.lang.IllegalArgumentException,
                                 java.lang.ClassCastException
Converts the internal value into its external representation.

Parameters:
internal - the internal value
Returns:
the external value
Throws:
java.lang.ClassCastException - if the class of the specified argument prevents it from being converter
java.lang.IllegalArgumentException - if some aspect of this argument prevents it from being converted

equals

protected abstract boolean equals(I left,
                                  I right)
Compare internal values, the passed argument are never null so the method does not need to check nullity of the arguments.

Parameters:
left - the left value
right - the right value
Returns:
true if the values are considered equals


Copyright © 2008. All Rights Reserved.