[Home] [By Thread] [By Date] [Recent Entries]
Alaric B. Snell wrote:
> But metadata extraction code I've writ for Java looks like:
>
> link = getLinkFromSomewhere () // you missed this out in the HTTP one
>
> Class c = link.getClass ();
>
> boolean idempotent;
>
> try {
> idempotent = c.getField (methodName + "IsIdempotent").getBoolean (link);
> }
> catch (NoSuchFieldException e) {
> // There was no explicit flag, assume not idempotent for now
> idempotent = false;
> }
If the objects implemented an interface, you could just use a cast:
try
{
Idempotent i = (Idempotent)getLinkFromSomewhere ()
...
}
..
and avoid all that reflection verbosity.
> Reflective programming languages make this explicit!
Not as explicit as a cast/classcastexception block - which is what
you're doing deep down.
Bill de hÓra
--
Propylon
www.propylon.com
|

Cart



