refactoring Wrapper interface
Vladimir Bauer
3 years ago
| 670 | 670 |
|
| 671 | 671 |
func extractBaseDecorator(d decor.Decorator) decor.Decorator {
|
| 672 | 672 |
if d, ok := d.(decor.Wrapper); ok {
|
| 673 | |
return extractBaseDecorator(d.Base())
|
|
673 |
return extractBaseDecorator(d.Unwrap())
|
| 674 | 674 |
}
|
| 675 | 675 |
return d
|
| 676 | 676 |
}
|
| 92 | 92 |
// it is necessary to implement this interface to retain functionality
|
| 93 | 93 |
// of built-in Decorator.
|
| 94 | 94 |
type Wrapper interface {
|
| 95 | |
Base() Decorator
|
|
95 |
Unwrap() Decorator
|
| 96 | 96 |
}
|
| 97 | 97 |
|
| 98 | 98 |
// EwmaDecorator interface.
|
| 62 | 62 |
return d.wc.Sync()
|
| 63 | 63 |
}
|
| 64 | 64 |
|
| 65 | |
func (d *mergeDecorator) Base() Decorator {
|
|
65 |
func (d *mergeDecorator) Unwrap() Decorator {
|
| 66 | 66 |
return d.Decorator
|
| 67 | 67 |
}
|
| 68 | 68 |
|
| 34 | 34 |
return d.Decorator.Decor(s)
|
| 35 | 35 |
}
|
| 36 | 36 |
|
| 37 | |
func (d *onAbortWrapper) Base() Decorator {
|
|
37 |
func (d *onAbortWrapper) Unwrap() Decorator {
|
| 38 | 38 |
return d.Decorator
|
| 39 | 39 |
}
|
| 33 | 33 |
return d.Decorator.Decor(s)
|
| 34 | 34 |
}
|
| 35 | 35 |
|
| 36 | |
func (d *onCompleteWrapper) Base() Decorator {
|
|
36 |
func (d *onCompleteWrapper) Unwrap() Decorator {
|
| 37 | 37 |
return d.Decorator
|
| 38 | 38 |
}
|