Created
June 27, 2011 12:06
-
-
Save Riduidel/1048747 to your computer and use it in GitHub Desktop.
An example external adapter (for cases where IAdaptable won't suffice)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Adapter { | |
/** | |
* Check if this adapter can adapt from source class to target one | |
* @param from class to adapt | |
* @param to class to create | |
* @return isn't it obvious ? true if this adapter can transform an object of "from" class into an object of "to" class | |
*/ | |
public boolean canAdapt(Class<?> from, Class<?> to); | |
/** | |
* Adapts an object of input class into an object of output class | |
* @param input input object to adapt | |
* @param outputClass output class to produce. This is given due to some restrictions of Java generics | |
* @return an object of output class that corresponds to input object | |
* @throws UnableToAdapt if adaptation failed for any reason | |
*/ | |
public <Input, Output> Output getAdapter(Input input, Class<Output> outputClass) throws UnableToAdapt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment