structural

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package structural describes structural design patterns. The design patterns described are all related to composition.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adaptee

type Adaptee struct {
}

Adaptee defines the old interface which needs to be adapted.

func (*Adaptee) SpecificExecute

func (a *Adaptee) SpecificExecute()

SpecificExecute defines the old interface for executing which needs to be adapted to the new interface defined by Target.

type Adapter

type Adapter struct {
	*Adaptee
}

Adapter is the adaptor to the new interface Target.

func (*Adapter) Execute

func (a *Adapter) Execute()

Execute adapts from the new interface Execute to the old SpecificExecute.

type BasicTimeImp

type BasicTimeImp struct {
	// contains filtered or unexported fields
}

BasicTimeImp defines a TimeImp which tells the time in 24 hour format.

func (*BasicTimeImp) Tell

func (t *BasicTimeImp) Tell()

Tell tells the time in 24 hour format.

type CarAccessories

type CarAccessories struct {
}

CarAccessories is the fourth car subsystem which describes the car accessories.

func NewCarAccessories

func NewCarAccessories() *CarAccessories

NewCarAccessories creates new car accessories.

func (*CarAccessories) SetAccessories

func (c *CarAccessories) SetAccessories()

SetAccessories sets the car accessories and logs.

type CarBody

type CarBody struct {
}

CarBody is the third car subsystem which describes the car body.

func NewCarBody

func NewCarBody() *CarBody

NewCarBody creates a new car body.

func (*CarBody) SetBody

func (c *CarBody) SetBody()

SetBody sets the car body and logs.

type CarEngine

type CarEngine struct {
}

CarEngine is the second car subsystem which describes the car engine.

func NewCarEngine

func NewCarEngine() *CarEngine

NewCarEngine creates a new car engine.

func (*CarEngine) SetEngine

func (c *CarEngine) SetEngine()

SetEngine sets the car engine and logs.

type CarFacade

type CarFacade struct {
	// contains filtered or unexported fields
}

CarFacade describes the car facade which provides a simplified interface to create a car.

func NewCarFacade

func NewCarFacade() *CarFacade

NewCarFacade creates a new CarFacade.

func (*CarFacade) CreateCompleteCar

func (c *CarFacade) CreateCompleteCar()

CreateCompleteCar creates a new complete car.

type CarModel

type CarModel struct {
}

CarModel is the first car subsystem which describes the car model.

func NewCarModel

func NewCarModel() *CarModel

NewCarModel creates a new car model.

func (*CarModel) SetModel

func (c *CarModel) SetModel()

SetModel sets the car model and logs.

type CivilianTime

type CivilianTime struct {
	Time
}

CivilianTime is a time with a civilian time implementation.

type CivilianTimeImp

type CivilianTimeImp struct {
	BasicTimeImp
	// contains filtered or unexported fields
}

CivilianTimeImp defines a TimeImp which tells the time in 12 hour format with meridem.

func (*CivilianTimeImp) Tell

func (t *CivilianTimeImp) Tell()

Tell tells the time in 12 hour format.

type Component

type Component interface {
	Traverse()
}

Component describes the behavior that needs to be exercised uniformly across all primitive and composite objects.

type Composite

type Composite struct {
	// contains filtered or unexported fields
}

Composite describes a composite of components.

func NewComposite

func NewComposite() *Composite

NewComposite creates a new composite.

func (*Composite) Add

func (c *Composite) Add(component Component)

Add adds a new component to the composite.

func (*Composite) Traverse

func (c *Composite) Traverse()

Traverse traverses the composites children.

type Flyweight

type Flyweight struct {
	Name string
}

Flyweight is a flyweight object which can be shared to support large numbers of objects efficiently.

func NewFlyweight

func NewFlyweight(name string) *Flyweight

NewFlyweight creates a new Flyweight object.

type FlyweightFactory

type FlyweightFactory struct {
	// contains filtered or unexported fields
}

FlyweightFactory is a factory for creating and storing flyweights.

func NewFlyweightFactory

func NewFlyweightFactory() *FlyweightFactory

NewFlyweightFactory creates a new FlyweightFactory.

func (*FlyweightFactory) GetFlyweight

func (f *FlyweightFactory) GetFlyweight(name string) *Flyweight

GetFlyweight gets or creates a flyweight depending on whether a flyweight of the same name already exists.

type ITask

type ITask interface {
	Execute(taskType string)
}

ITask is an interface for performing tasks.

type Leaf

type Leaf struct {
	// contains filtered or unexported fields
}

Leaf describes a primitive leaf object in the hierarchy.

func NewLeaf

func NewLeaf(value int) *Leaf

NewLeaf creates a new leaf.

func (*Leaf) Traverse

func (l *Leaf) Traverse()

Traverse prints the value of the leaf.

type ProxyTask

type ProxyTask struct {
	// contains filtered or unexported fields
}

ProxyTask represents a proxy task with re-routes tasks.

func NewProxyTask

func NewProxyTask() *ProxyTask

NewProxyTask creates a new instance of a ProxyTask.

func (*ProxyTask) Execute

func (t *ProxyTask) Execute(taskType string)

Execute intercepts the Execute command and re-routes it to the Task Execute command.

type Target

type Target interface {
	Execute()
}

Target is the target interface to adapt to.

type Task

type Task struct {
}

Task implements the ITask interface for performing tasks.

func (*Task) Execute

func (t *Task) Execute(taskType string)

Execute implements the task.

type TaskFunc

type TaskFunc func(int) int

TaskFunc represents a function to perform a task.

func LogDecorate

func LogDecorate(fn TaskFunc) TaskFunc

LogDecorate decorates a task functions execution with some logging.

type Time

type Time struct {
	// contains filtered or unexported fields
}

Time is the base struct for Time containing the implementation.

func NewCivilianTime

func NewCivilianTime(hour, minute int, pm bool) *Time

NewCivilianTime creates a new civilian time.

func NewTime

func NewTime(hour, minute int) *Time

NewTime creates a new time which uses a basic time for its implementation.

func NewZuluTime

func NewZuluTime(hour, minute, zoneID int) *Time

NewZuluTime creates a new Zulu time.

func (*Time) Tell

func (t *Time) Tell()

Tell tells the time with the given implementation.

type TimeImp

type TimeImp interface {
	Tell()
}

TimeImp is the interface for different implementations of telling the time.

func NewBasicTimeImp

func NewBasicTimeImp(hour, minute int) TimeImp

NewBasicTimeImp creates a new TimeImp.

func NewCivilianTimeImp

func NewCivilianTimeImp(hour, minute int, pm bool) TimeImp

NewCivilianTimeImp creates a new TimeImp.

func NewZuluTimeImp

func NewZuluTimeImp(hour, minute, zoneID int) TimeImp

NewZuluTimeImp creates a new TimeImp.

type ZuluTime

type ZuluTime struct {
	Time
}

ZuluTime is a time with a Zulu time implementation.

type ZuluTimeImp

type ZuluTimeImp struct {
	BasicTimeImp
	// contains filtered or unexported fields
}

ZuluTimeImp defines a TimeImp which tells the time in Zulu zone format.

func (*ZuluTimeImp) Tell

func (t *ZuluTimeImp) Tell()

Tell tells the time in 24 hour format in Zulu time zone.

Jump to

Keyboard shortcuts

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