com.emarsys.ecommon.util
Interface GenericAdapter<T>

All Known Subinterfaces:
SchedulableQueueElement<T>
All Known Implementing Classes:
MockSchedulable, SchedulableQueueElementProxy

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 GenericAdapters 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() );
}

Author:
Michael "kULO" Kulovits

Method Summary
 T getConcreteInstance()
           
 

Method Detail

getConcreteInstance

T getConcreteInstance()
Returns:
this instance with its concrete type T.


Copyright © 2010 emarsys AG. All Rights Reserved.