|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface GenericAdapter<T>
GenericAdapter
is supposed to be a super interface
for arbitrary interfaces that specify an adapter
to classes and have the same single type parameter T.
A concrete class T
implementing an interface that represents a
GenericAdapter
will pass its own type T
as a
parameter to the GenericAdapter
interface.
The sole purpose of this super inteface is to provide a
common way to access the concrete object implementing
this interface with its concrete dynamic subtype in contrast
to the supertype specified by the interface extending
GenericAdapter
.
If there are several GenericAdapter
s to the same
class, this interface ensures that there has to be only one
accessor to the concrete instance.
An example is maybe better than the above theoretic bla bla:
public interface Doable<T> extends GenericAdapter<T> {
void doIt(); }
public interface Undoable<T> extends GenericAdapter<T> {
void undoIt(); }
public class Action implements Doable<Action>,
Undoable<Action> {
void setExecutionDate( Date date ) { ... }
void doIt() { ... }
void undoIt() { ... }
\//only one implementation for two generic adapter interfaces
void getConcreteInstance() { return this; }
}
...
public static void foo( Doable\<\?\> doable ) {
doable.doIt();
if( doable.getConcreteInstance() instanceof Action )
doable.getConcreteInstance().setExecutionDate( new Date() );
}
Method Summary | |
---|---|
T |
getConcreteInstance()
|
Method Detail |
---|
T getConcreteInstance()
T
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |