So, this is my design.
AccessDecorator classes have a reference to another
Access just like normal Decorator Pattern.
But the problem is when I create an
AccessDecorator wrapping a
ConcreteAccess and then try to see which type the Access is:
Access access = new InAllowedAccess(); Access wrapperAccess = new MismatchAccess(access); if (wrapperAccess instanceof InAllowedAccess) //this condition could be used to be a predicate for a filtering over an access list for example //do something
Of course this won't work because
wrapperAccess is not of type
InAllowedAccess but what I really want to know is the type of the concrete access wrapped by the decorator.
I thought about implementing methods like
Access classes but don't seems a good solution, I don't know...
Otherwise should I create decorator classes for each 4 types
Or there is other better design?