1

I want inject property to class before induce fromJson.

PrimitiveDocument document = null;
document = (PrimitiveDocument) gson.fromJson(requestBody.toString(), AcceptPathDocument.class);

In AcceptPathDocument induce constructor PrimitiveDocument:

if (!this.getApplicationTag().equals("")) {
    Database db = Master.getDB(this.getApplicationTag());
    try {
        this.doc = db.createDocument();
        this.setForm(this.getForm());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

but I have applicationTag in requestBody so when this code is running applicationTag is empty. How I can inject application tag from requestbody before induce fromJson?

Tomasz Knapp
  • 91
  • 1
  • 4

1 Answers1

1

May decomposing AcceptPathDocument class to two class helps. this means that first convert json to pojo then add this object as a field to second class. like decorator pattern.