jeudi 8 février 2018

Return full class metadata in json format

have the following problem:

Lets say I have a class, for instance,

//lombok annotations
public class Config implements Serializable, Cloneable {

    private String domain;
    private Timestamp firstBillTime;
    private Period billPeriod;    
    @Override
    public Config clone(){
        return new Config(domain, firstBillTime, billPeriod);
    }

    public enum Period {
        MONTH(Calendar.MONTH),
        YEAR(Calendar.YEAR);

        public final int calendarId;

        Period(int calendarId) {
            this.calendarId = calendarId;
        }
    }
}

And I would like to get it's metadata in JSON format like:

{

"domain":"java.util.String",
"firstBillTime":"java.sql.Timestamp";
"config":" { //list of possible values since it is enum
  [
    "MONTH",
    "YEAR"
  ]
}

}

I know there is a possibility to implement something like that with a combination of reflection and custom annotations.

However, I would be really grateful if someone could give a hint if there is some ready solution for such kind of a problem,

Thanks





Aucun commentaire:

Enregistrer un commentaire