I recently thought about a problem when you have a method that performs some action, but it should not be called directly, but through another method that properly processes it.
So what I'm going to do is create an annotation in which the method will be used, namely: IE:
@NonDirectUsage(direct=MyClass.directMethod);
It should look like comments, where you can link the link, however I want to use it in such a way that it can be used through runtime, etc.
An example in live code would look something like this:
List<Integer> myList = new ArrayList<>(); @Override @NonDirectUsage(direct=addToList) public void add(T t) { super.add(t); } public void addToList(Integer i) { System.out.println("added integer properly: "+i); add(i); }
Is there any way to do this?
source share