Android annotation to call a specific function

When an instance of my class is created, it should always be closed when the work is done.

public class MyClass {
    // I'm searching for an annotation like this:
    @RememberToCall(function="#close()")
    public MyClass() {
    }

    /**
     * Always call this function when you are done with your work.
     */
    public void close() {
        // Do some tear down stuff
    }
}

Similarly, SQLiteDatabasewhen executing an SQL query, you were reminded to call a function close()on the cursor object that returned. I want to do the same with my class, is there any annotation for this?

+4
source share

Source: https://habr.com/ru/post/1659514/


All Articles