Hi,
See SLING-2938 for the history and prototypes of simplified adapters,
example below.
Do we still need this with Sling Models?
I'd say both things are orthogonal, but I haven't worked with models
so far, so I'd like a second opinion - let's not introduce too many
different ways of doing the same thing.
-Bertrand
Example adapter, defined by the (controversial) AdapterProvider
interface, and @Adapter annotations:
public static class MultipleMethodsProvider implements AdapterProvider {
@Adapter
public Integer adaptToInt(TestAdaptable src) {
return new Integer((int)src.value);
}
@Adapter
public URL adaptToURL(TestAdaptable src) {
final String url = "http://example.com/" + src.value;
try {
return new URL(url);
} catch(MalformedURLException mfu) {
throw new RuntimeException("Invalid URL " + url, mfu);
}
}
}