|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||
@Retention(value=RUNTIME) @Target(value=METHOD) @Documented public @interface DuckTyped
Indicates that this method on ConfigBeanProxy is a duck-typed method
that are implemented by the static method on the nested static Duck class.
Often it's convenient if one can define some convenience methods on the config bean proxy.
This mechanism allows you to do that by putting this annotation on a convenience method,
then write the nested static Duck class and places the actual implementation there.
interface MyConfigBean extends ConfigBeanProxy {
@Element
List<Property> getProperties();
<DuckTyped
String getPropertyValue(String name);
class Duck {
public static String getPropertyValue(MyConfigBean me, String name) {
for( Property p : me.getProperties() )
if(p.getName().equals(name))
return p.getValue();
return null;
}
}
}
The invocation of the getPropertyValue above will cause HK2 to in turn invoke
the corresponding static method on Duck, where the first argument will be the
original this value.
ConfigBeanProxy
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||||