[deepamehta-devel] compiler-safe type URIs

Robert Schuster robert.schuster.rs01 at gmail.com
Fri Jun 23 21:53:35 CEST 2017

Hey everybody,
in some of the past DM projects I had a few problems due to the fact
that I sometimes used the wrong type URI. As the type URIs are just
strings, lots of things can go wrong.

So for a current project I came up with a scheme that makes the type URI
compiler safe. The strings turn into ah object structure and so even the
IDE can help you finding the correct element. The code that sets this up
looks a bit intimidating at first but when in use it looks pretty nifty.

Here is an example:


Neat, isn't it?

NS is the namespace class, route is the namespace for a complex type and
name is a child topic.

When access to a complex stype is needed a little workaround produces
the actual string (as route is a non-string Java object):


Here is a bit of code that shows how it would allow some objects like this:


public class NS {
    private static final String root = "de.deepamehta.project";

    public static final WorkspaceNS workspace = new WorkspaceNS();

    public static class WorkspaceNS extends InnerNameSpace {
        public final String types = makeMember("types");
        public final String data = makeMember("data");


I know its a bit esoteric but I like that fact that it safes me from
hunting problems because I mistyped a type or confused a dot. :-)

If anyone is interested in the source for this, let me know.

All the best,

Robert Schuster
freiberuflicher Softwareingenieur

RS01 - IT-Systemanalyse und -entwicklung Robert Schuster
Kalkbergeweg 75 • 12589 Berlin
+49 157 798 00 310
robert.schuster.rs01 at gmail.com

More information about the devel mailing list