specification

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 1 Imported by: 0

README

design pattern

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Specification

type Specification[T any] interface {

	// IsSatisfiedBy check if t is satisfied by the specification.
	IsSatisfiedBy(ctx context.Context, 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]

	// Conjunction create a new specification that is conjunction operation of the current specification.
	Conjunction(others ...Specification[T]) Specification[T]

	// Disjunction create a new specification that is disjunction operation of the current specification.
	Disjunction(others ...Specification[T]) Specification[T]
}

Specification interface. Use specification as specification for creating specifications, and only the method predicate(Object) must be implemented.

func And

func And[T any](left Specification[T], right Specification[T]) Specification[T]

func Conjunction added in v1.3.2

func Conjunction[T any](specs ...Specification[T]) Specification[T]

func Disjunction added in v1.3.2

func Disjunction[T any](specs ...Specification[T]) Specification[T]

func New

func New[T any](predicate func(ctx context.Context, t T) bool) Specification[T]

func Not

func Not[T any](spec Specification[T]) Specification[T]

func Or

func Or[T any](left Specification[T], right Specification[T]) Specification[T]

Jump to

Keyboard shortcuts

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