I've created some class with custom toString() function:
public class Test {
public String eventName;
public Long eventTime; //timestamp
public Integer firstEventResult;
public Integer secondEventResult;
// ... and dozens more variables
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder("Event(");
stringBuilder.append("name:");
stringBuilder.append(this.eventName);
stringBuilder.append(", ");
stringBuilder.append("time:");
stringBuilder.append(this.eventTime);
if(firstEventResult != null) {
stringBuilder.append(", ");
stringBuilder.append("firstEventResult:");
stringBuilder.append(this.firstEventResult);
}
if(secondEventResult != null) {
stringBuilder.append(", ");
stringBuilder.append("secondEventResult:");
stringBuilder.append(this.secondEventResult);
}
// ...
stringBuilder.append(")");
return stringBuilder.toString();
}
}
and that toString() function provides me string like that:
Event(name:Test, time:123456789, firstEventResult:200)
How can I in this case convert back above string to the class again?