I have an interesting problem to solve.
Let's consider the following classes (Person and Telephone):
Person
@AllArgsConstructor
@Getter
@Setter
@ToString
public class Person {
private String name;
private int age;
private Telephone telephone;
}
Telephone
@AllArgsConstructor
@Getter
@Setter
@ToString
public class Telephone {
private int codeArea;
private String number;
}
And suppose that I have a Person object string generated by the lombok annotation @ToString:
Person(name=John, age=30, telephone=Telephone(codeArea=16, number=1111-2222))
How can I convert the string above to the object again? Is there any library that can help me with this process, or do I have to create manually a parser for it?
I know that there are other ways like generating json or serializing as a java object and then converting it back. However, this is not a solution for me now, as I must have to work with the string mentioned above.