How get special method of class in java? -


i have class methods in java follows:

public class class1 {     private string a;     private string b;       public seta(string a_){         this.a = a_;     }      public setb(string b_){         this.b = b_;     }      public string geta(){         return a;     }      @jsonignore     public string getb(){         return b;     } } 

i want methods in class1 start string get not declared @jsonignore annotation.

how do this?

you can use java reflection iterate on public , private methods:

class1 obj = new class1();  class c = obj.getclass(); (method method : c.getdeclaredmethods()) {     if (method.getannotation(jsonignore.class) == null &&         method.getname().substring(0,3).equals("get")) {         system.out.println(method.getname());     } } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -