- a decorator class implements some interface
- it is an [insert interface name here]
- BUT it also has an instance of that interface
- "decoratee" is the instance of the interface that the decorator class has
- if you extend the decorator class...
- instances of this concrete class can make the instance in the decorator class immutable
- IF you
@Overrideall the methods that modify the decoratee - this way you can safely make an instance of the concrete decorator that has an immutable [insert interface name here]
- any subclasses the interface requires must also be decorated, both in the decorator class and any concrete classes that extend the decorator
CollectionDecorator- the decorator class itself
- implements
Collection - has an instance of
Collectioncalleddecoratee - also has a subclass
IteratorDecoratorthat implementsIteratorand has an instance ofIterator
UnmodifiableCollection- extends
CollectionDecorator - overrides all of its methods
- leaves methods that modify the collection unimplemented (i.e. they throw
Unimplementedexceptions) - also has a subclass
UnmodifiableIteratorthat extendsIteratorDecorator- the iterator methods that modify the collection (
remove,add, etc.) throwUnimplementedexceptions
- the iterator methods that modify the collection (
- extends