Skip to main content

Three small updates about as(...)

Posted by fabriziogiudici on December 4, 2009 at 4:19 AM PST

I've previously blogged about the href="">as(...)
pattern I'm using for my projects. In an email exchange with href="">Taylor Cowan,
I've been made aware that href="">Taylor
has been using this pattern since a quite a few time in his href="">JenaBean
project (Jena
is another big player in the world of RDF and Java). A stripped down
pseudocode from his example:"thetitle").created("2006-09-07T09:33:30Z");

Have a look at his code since the examples are much more powerful than
the excerpt above.

Second, another exchange with
Tor Norbye
(for a completely different topic) made me aware
of an
updated naming convention for Java identifiers containing acronyms
So, I'm now using SkosConcept
and OwlThing
in place of SKOSConcept
and OWLThing.

Third, my friend Uberto
suggested me that there's a way to get rid of that style="font-family: monospace;">.class suffix,
without hoping for a compiler change. If you define such a thing as:

public interface

  { style="font-family: monospace;">
public final static
Class<SkosConcept> SkosConcept
= SkosConcept.class;
style="font-family: monospace;">


  } style="font-family: monospace;">

interface GeoCoderEntityProxy
style="font-family: monospace;">
  { style="font-family: monospace;">
public final static Class<GeoCoderEntityProxy>
GeoCoderEntityProxy = GeoCoderEntityProxy.class;
style="font-family: monospace;">



you can write:

import static
style="font-family: monospace;">
import static
style="font-family: monospace;">

list =;

which is quite readable. The Java compiler is capable of understanding
the difference between a type reference (for instance the style="font-family: monospace;">GeoCoderEntityProxy
generic parameter in
) and a field reference (such as the
one statically imported). The only thing that you're loosing is that
you won't be able to invoke an hypotethical static method such as style="font-family: monospace;">GeoCoderEntityProxy.doSomething().
But in most cases I'm dealing with interfaces, so this is not a real

Related Topics >>



I could definitely see a Lombok annotation to help write the constant in the interface