java - modify return value of all getter methods -


i have java class contains fields setters , getters. this:

public class test{     public string field1;     public string field2;     ...      //setters , getters } 

i want logic before executing every getter method. in fact want method called before calling getter methods, return value of getter method, modify , set new value(without changing body of getter methods, if possible using custom annotation). example:

test test = new test(); test.setfield1("field1"); test.setfield2("field2"); 

now, want when use test.getfield1(), 1 method called , change value of filed1 property. there anyway doing that?

edit: ambrish , kayaman realize 1 possible way in spring mvc application aspectj. question is there anyway doing custom annotation?

you can use aop library such aspectj define pointcuts getter methods. allow perform things before (and after) calling method.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -