Annotation Type Self


@Target(PARAMETER)
@Retention(RUNTIME)
public @interface Self
A marker annotation for annotating the "self"-instance which can be injected into a constructor to access state in a safe way. Usually, one accesses the state of an entity view in an unsafe way in a constructor through getters like: @EntityView(Cat.class) public abstract class CatView { public CatView() { System.out.println(getName()); } public abstract String getName(); } With @Self it is possible to inject the self instance and get the state from it which is safe. @EntityView(Cat.class) public abstract class CatView { public CatView(@Self CatView self) { System.out.println(self.getName()); } public abstract String getName(); }
Since:
1.5.0
Author:
Christian Beikov