specification

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 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 AndSpecification added in v1.2.3

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

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

func (*AndSpecification[T]) IsSatisfiedBy added in v1.2.3

func (spec *AndSpecification[T]) IsSatisfiedBy(ctx context.Context, t T) bool

type BaseSpecification added in v1.2.3

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

func (*BaseSpecification[T]) And added in v1.2.3

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

func (*BaseSpecification[T]) IsSatisfiedBy added in v1.2.3

func (spec *BaseSpecification[T]) IsSatisfiedBy(ctx context.Context, t T) bool

func (*BaseSpecification[T]) Not added in v1.2.3

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

func (*BaseSpecification[T]) Or added in v1.2.3

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

type NotSpecification added in v1.2.3

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

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

func (*NotSpecification[T]) IsSatisfiedBy added in v1.2.3

func (spec *NotSpecification[T]) IsSatisfiedBy(ctx context.Context, t T) bool

type OrSpecification added in v1.2.3

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

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

func (*OrSpecification[T]) IsSatisfiedBy added in v1.2.3

func (spec *OrSpecification[T]) IsSatisfiedBy(ctx context.Context, t T) bool

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]
}

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

func And

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

func New

func New[T any](isSatisfiedBy 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