I'm currently facing the following problem:
Imagine I have an abstract Class A
for filtering specific entities.
So I have a PassThroughFilter
extending A
, which does nothing (NIL-Element). Through a decorator pattern I have an other abstract class A_Dec
, which holds the property type
. Further, I have classes B
and C
both extending A_Dec
. They use the type
for various things, so they are logically different.
A sample filter then could be: C(type=XC, decorator=B(type=XB, decorator=A))
Not I want to create a JSON to save to current filter. Which is easy to do, BUT for the JSON:
{type=X, decorator={}}
where {}
represents A
I cannot distinguish between B
and C
.
An easy fix would be to create a local variable with the name of the class or something other unique. But is there a proper way to handle this?
Thank you in advance!