|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.rode.thesis.adapter.AdapterStrategy
public class AdapterStrategy
Simple adapter strategies used in conjunction with
SequenceAdapter
instances.
Each strategy is stateless, and thus thread-safe.
Implementation notes:
Adapter composition is implemented according to the
Strategy pattern. As the explicit
type parameters are important and differs between each concrete
strategy, theses strategies cannot be declared as values in an
enumeration. A benefit of this is that the class is open for
sub-classing.
Each strategy is implemented as an anonymous class implementing the
AdapterDelegate
interface, which is by it self a representation
of adaptation. It is common practice in Java to utilise anonymous inner
class to implement adapters.
All strategies for adaptation defined here are state
preserving and imply a simple representation shift except
for the LONG_TO_INTEGER
and BIGINTEGER_TO_LONG
strategies,
which may truncate values.
Field Summary | |
---|---|
static AdapterDelegate<Object,Object> |
ANY_TO_OBJECT
A strategy to shift from an any type into Object . |
static AdapterDelegate<Object,String> |
ANY_TO_STRING
A strategy to shift from an Object or wild-card representation
to a String representation by invoking toString()
on the object. |
static AdapterDelegate<BigInteger,Long> |
BIGINTEGER_TO_LONG
A strategy to shift from a BigInteger representation
to a Long representation. |
static AdapterDelegate<CharSequence,Long> |
CHAR_TO_LONG
A strategy to shift from a CharSequence representation
to a Long representation. |
static AdapterDelegate<CharSequence,String> |
CHAR_TO_STRING
A strategy to shift from a CharSequence representation
to a String representation. |
static AdapterDelegate<Long,Integer> |
LONG_TO_INTEGER
A strategy to shift from a Long representation
to an Integer representation. |
static AdapterDelegate<Long,String> |
LONG_TO_STRING
A strategy to shift from a Long representation
to a String representation. |
static AdapterDelegate<Number,String> |
NUMBER_TO_STRING
A strategy to shift from a Number representation
to a String representation. |
static AdapterDelegate<String,CharSequence> |
STRING_TO_CHAR
A strategy to shift from a String representation
to a CharSequence representation via a simple
implicit cast. |
Constructor Summary | |
---|---|
protected |
AdapterStrategy()
No-arg sub-class constructor. |
Method Summary |
---|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final AdapterDelegate<Object,Object> ANY_TO_OBJECT
Object
. This is useful if wild-cards is to be used.
public static final AdapterDelegate<Object,String> ANY_TO_STRING
Object
or wild-card representation
to a String
representation by invoking toString()
on the object.
public static final AdapterDelegate<BigInteger,Long> BIGINTEGER_TO_LONG
BigInteger
representation
to a Long
representation. The long representation is simply truncated. Hence, this strategy cannot be guaranteed to preserve the entire state.
public static final AdapterDelegate<CharSequence,Long> CHAR_TO_LONG
CharSequence
representation
to a Long
representation.
public static final AdapterDelegate<CharSequence,String> CHAR_TO_STRING
CharSequence
representation
to a String
representation.
public static final AdapterDelegate<Long,Integer> LONG_TO_INTEGER
Long
representation
to an Integer
representation. The integer representation is simply truncated. Hence, this strategy cannot be guaranteed to preserve the entire state, e.g. from 64 to 32 bit values.
public static final AdapterDelegate<Long,String> LONG_TO_STRING
Long
representation
to a String
representation.
public static final AdapterDelegate<Number,String> NUMBER_TO_STRING
Number
representation
to a String
representation.
public static final AdapterDelegate<String,CharSequence> STRING_TO_CHAR
String
representation
to a CharSequence
representation via a simple
implicit cast.
Constructor Detail |
---|
protected AdapterStrategy()
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |