I currently have some functionality like following in my method.
if(obj instanceof A) {
someString = ((ChildClass)((A)obj)).get(0).getSomeString();
}
if(obj instanceof B) {
someString = ((B)obj)).getSomeString();
}
if(obj instanceof C) {
someString = ((c)obj)).getSomeString();
}
someString = performSomeOperation(someString);
if(obj instanceof A) {
((ChildClass)((A)obj)).get(0).setSomeString(someString);
}
if(obj instanceof B) {
someString = ((B)obj)).setSomeString(someString);
}
if(obj instanceof C) {
someString = ((c)obj)).setSomeString(someString);
}
I am advised to use builder pattern, but I am not sure if we can use builder pattern here, is it possible? if not, is there any other approach?
Aucun commentaire:
Enregistrer un commentaire