decorator

package
v0.0.0-...-021ab65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 0 Imported by: 0

README

装饰模式

装饰模式使用对象组合的方式动态改变或增加对象行为。

Go语言借助于匿名组合和非入侵式接口可以很方便实现装饰模式。

使用匿名组合,在装饰器中不必显式定义转调原对象方法。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddDecorator

type AddDecorator struct {
	Component
	// contains filtered or unexported fields
}

func (*AddDecorator) Calc

func (d *AddDecorator) Calc() int

type Component

type Component interface {
	Calc() int
}

func WarpAddDecorator

func WarpAddDecorator(c Component, num int) Component

func WarpMulDecorator

func WarpMulDecorator(c Component, num int) Component

type ConcreteComponent

type ConcreteComponent struct{}

func (*ConcreteComponent) Calc

func (*ConcreteComponent) Calc() int

type MulDecorator

type MulDecorator struct {
	Component
	// contains filtered or unexported fields
}

func (*MulDecorator) Calc

func (d *MulDecorator) Calc() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL