This question already has an answer here:
I have a POJO representing a record in DynmaoDB table:
class Request{
String id,
String name,
Status statusName,
}
where Status is
public enum Status{
OPEN, REVIEW, APPROVED }
I want to get the String representing the fields in a fixed format, just like
Request_1 Name_1 OPEN
Request_2 empty_string APPROVED
empty_string represents an empty string which is used when the value of the field is not defined. What I am doing now is
String requestRecord = this.toString(request);
where the toString
method is :
public String toString(Request request) {
return new ReflectionToStringBuilder(request, new RecursiveToStringStyle()).toString();
}
This gives me the output like this :
com.datamodel.Request@3bb5ceb[id=Request_1,name=,statusName=com.datatype.Status@2ffb3aec[statusName=Review,name=REVIEW,ordinal=1]]
Can anyone tell me how to get the string in the required format.?
Aucun commentaire:
Enregistrer un commentaire