ddd

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregate

type Aggregate[T any, ID any] interface {
	Root() Entity[T, ID]
}

type AndSpecification

type AndSpecification[T any] struct {
	// contains filtered or unexported fields
}

AndSpecification used to create a new specification that is the AND of two other specifications.

func NewAndSpecification

func NewAndSpecification[T any](left Specification[T], right Specification[T]) *AndSpecification[T]

func (*AndSpecification) And

func (spec *AndSpecification) And(another Specification[T]) Specification[T]

func (*AndSpecification[T]) IsSatisfiedBy

func (spec *AndSpecification[T]) IsSatisfiedBy(t T) bool

func (*AndSpecification) Not

func (spec *AndSpecification) Not(another Specification[T]) Specification[T]

func (*AndSpecification) Or

func (spec *AndSpecification) Or(another Specification[T]) Specification[T]

type DomainEvent

type DomainEvent[T any] interface {
	SameEventAs(other T) bool
}

DomainEvent is something that is unique, but does not have a lifecycle. The identity may be explicit, for example the sequence number of a payment, or it could be derived from various aspects of the event such as where, when and what has happened.

type Entity

type Entity[T any, ID any] interface {
	SameIdentityAs(other T) bool
	Identity() ID
}

Entity as explained in the DDD book. Entities compare by identity, not by attributes.

type NotSpecification

type NotSpecification[T any] struct {
	// contains filtered or unexported fields
}

NotSpecification used to create a new specification that is the inverse (NOT) of the given spec.

func NewNotSpecification

func NewNotSpecification[T any](spec Specification[T]) *NotSpecification[T]

func (*NotSpecification) And

func (spec *NotSpecification) And(another Specification[T]) Specification[T]

func (*NotSpecification[T]) IsSatisfiedBy

func (spec *NotSpecification[T]) IsSatisfiedBy(t T) bool

func (*NotSpecification) Not

func (spec *NotSpecification) Not(another Specification[T]) Specification[T]

func (*NotSpecification) Or

func (spec *NotSpecification) Or(another Specification[T]) Specification[T]

type OrSpecification

type OrSpecification[T any] struct {
	// contains filtered or unexported fields
}

OrSpecification used to create a new specification that is the OR of two other specifications.

func NewOrSpecification

func NewOrSpecification[T any](left Specification[T], right Specification[T]) *OrSpecification[T]

func (*OrSpecification) And

func (spec *OrSpecification) And(another Specification[T]) Specification[T]

func (*OrSpecification[T]) IsSatisfiedBy

func (spec *OrSpecification[T]) IsSatisfiedBy(t T) bool

func (*OrSpecification) Not

func (spec *OrSpecification) Not(another Specification[T]) Specification[T]

func (*OrSpecification) Or

func (spec *OrSpecification) Or(another Specification[T]) Specification[T]

type Specification

type Specification[T any] interface {
	// IsSatisfiedBy check if t is satisfied by the specification.
	IsSatisfiedBy(t T) bool
	// And create a new specification that is the AND operation of the current specification and
	// another specification.
	And(another Specification[T]) Specification[T]
	// Or create a new specification that is the OR operation of the current specification and
	// another specification.
	Or(another Specification[T]) Specification[T]
	// Not create a new specification that is the NOT operation of the current specification.
	Not(another Specification[T]) Specification[T]
}

Specification interface. Use BaseSpecification as base for creating specifications, and only the method isSatisfiedBy(Object) must be implemented.

func NewSpecification

func NewSpecification[T any](isSatisfiedBy func(t T) bool) Specification[T]

type ValueObject

type ValueObject[T any] interface {
	SameValueAs(other T) bool
}

ValueObject as described in the DDD book. Value objects compare by the values of their attributes, they don't have an identity.

Jump to

Keyboard shortcuts

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