GWT has another somewhat interesting tactic; you write an interface 
containing one method named after an image file for each image. GWT has a 
utility class that gives you an instance of the same type as the interface, 
and all methods just work.

You could build something very similar using an annotation processor (You'd 
generate the actual implementing class, based on the interface, which has an 
annotation to trigger the AP). You'd then get compile checking in both cases 
as well as auto-complete on your resources (i.e. you'll get an error at 
compile time if an image is missing because the AP can tell, and they can 
raise a compiler error, and you'll get an error if some other code tries to 
use a non-existing image because the method won't exist in the interface).

Another option is that your interface is just an empty, package-private 
dummy whose only purpose is to carry an annotation that includes a path to a 
directory of images. This AP can then generate the entire interface + 
implementation (or just bundle it up in one class if you prefer) with 1 
method for each resource that it found in the file.

I doubt this would take you more than a single man-day of work, including 
testing.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/javaposse/-/aRgn8TNP-bsJ.
To post to this group, send email to javaposse@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to