vendredi 31 mars 2017

Java Complex Object Replace

I never faced a requirement like that and I am pretty confused how can I implement that.

Lets consider the following Beans:

Company{
String companyName;
String companyId;
Person person;
//getter and setters
}

Person{
String id;
String name;
String lastName;
List<Address> address;
//getter and setters
}

Address{
String id;
String name;
String description;
//getter and setters
}

So the hierarchy would be like this:

Company has Person has Address

What I have to do is, replace all String fields with other String, for instance

Company.companyName = "Hi there #xyz"

Address.name = "St. Example #xyz"

I need to replace the char #xyx with #abcd, for instance.

The object is much more complex than that and has a huge hierarchy.

I tried to find some API that would help me to do that, however I couldn't find anyone (I don't know if look correctly).

A solution that I have is in each getter method replace the char, however I don't think that is the best way to solve that.

I appreciate your help.

Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire