Lombok restricted access

Status: inactive
Initiation: 2014

The idea is to build something like Kohsuke Kawaguchi's Custom Access Modifier as a custom Lombok handler. When using Lombok, no Maven-Plugins or any other build magic is required - just adding the dependencies and it works.

You annotate the methods that shall not be called outside of your Framework with the RestrictedAccess annotation. At compile time, Lombok's magic injects a check if the caller of the method/constructor is in the allowed package. If not, an RuntimeException is thrown.

package my.private.api.internal;
   public class PrivateAPI {
    @RestrictedAccess("my.private.api")
    public PrivateAPI() {
        // DO private stuff
    }
}
package third.party.app;
...
   new PrivateApi().doStuff()
...
}

A working example can be found in the sub project example_usage

This is only a proof of concept. Production usage is not recommended!