Any way to cut recursion on a certain Type excluding root object ? #2693
-
Hi, I'm trying to compare two objects recursively, but I dont want a certain Type to use recursive comparison (lets call it GenericObject). Right now to achieve this comparison I use Do you see a better way to achieve this kind of comparison ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
One solution I see is a bit of a hack, create a Wrapper class like and use it to wrap you object and expected object with it so that it avoids the root object issue: class Wrapper<T> {
T object;
Wrapper(T object) {
this.optional = optional;
}
} I'll think about adding an option to avoid considering the root object in the comparison if we have more use cases for it, your case being quite specific. |
Beta Was this translation helpful? Give feedback.
I've been able to cut recursion on a certain Type except root object, by converting the root object to a map before doing the comparison.
Not a perfect solution, but it seems to work fine so far.