any

package
v0.0.0-...-e7c744b Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WithoutEqualityChecks option makes the merge skip all pre-merge equality checks.
	WithoutEqualityChecks equalityCheckOption = iota
	// WithInitialEqualityCheck option makes the merge check for equality of the input values before merging them to potentially skip costly merges.
	WithInitialEqualityCheck
	// WithSubtreeEqualityChecks option makes the merge check for equality of every value pair before merging them to potentially skip costly merges.
	WithSubtreeEqualityChecks
)
View Source
const (
	// UseFirst is a merge strategy that always returns the first value without modifying it.
	UseFirst useFirstMergeStrategy = true
	// UseSecond is a merge strategy that always returns the second value without modifying it.
	UseSecond useFirstMergeStrategy = false
)
View Source
const Identity identityTransformation = false

Identity is the identity transformation

Variables

This section is empty.

Functions

This section is empty.

Types

type MergeContext

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

MergeContext stores merge state and configuration

func NewMergeContext

func NewMergeContext(options ...MergeOption) MergeContext

NewMergeContext returns a new MergeContext with the specified MergeOptions applied to it.

type MergeOption

type MergeOption interface {
	// contains filtered or unexported methods
}

MergeOption represents a merge configuration option.

type MergeOptions

type MergeOptions []MergeOption

MergeOptions represent a list of merge configuration options.

type MergeStrategy

type MergeStrategy interface {
	// Merge merges two values using the provided MergeContext.
	Merge(ctx MergeContext, fst, snd Value) (Value, error)
}

MergeStrategy represents a merge strategy.

type MergeStrategyFunc

type MergeStrategyFunc func(MergeContext, Value, Value) (Value, error)

MergeStrategyFunc adapts a function to a MergeStrategy.

func (MergeStrategyFunc) Merge

func (fn MergeStrategyFunc) Merge(ctx MergeContext, fst, snd Value) (Value, error)

Merge merges two values by delegating to the merge strategy function.

type MergeStrategyOption

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

MergeStrategyOption represents a merge strategy configuration option.

func WithStrategy

func WithStrategy(fstType, sndType reflect.Type, strategy MergeStrategy) MergeStrategyOption

WithStrategy returns a MergeStrategyOption with the provided parameters.

type Transformation

type Transformation interface {
	// Transform performs the transformation
	Transform(Value) (Value, error)
}

Transformation can transform a value to another

func Compose

func Compose(transformations ...Transformation) Transformation

Compose returns the composition of the specified transformations performed in order

type TransformationFunc

type TransformationFunc func(Value) (Value, error)

TransformationFunc wraps a function that implements the transformation

func (TransformationFunc) Transform

func (f TransformationFunc) Transform(src Value) (Value, error)

Transform implements the transformation by delegating to the wrapped function

type Value

type Value = interface{}

Value can represent any value

func Merge

func Merge(fst, snd Value, options ...MergeOption) (Value, error)

Merge returns the merge of its first and second arguments.

func MergeWithContext

func MergeWithContext(ctx MergeContext, fst, snd Value) (Value, error)

MergeWithContext returns the merge of fst and snd using the specified MergeContext.

func MustMerge

func MustMerge(fst, snd Value, options ...MergeOption) Value

MustMerge returns the merge of its first and second arguments. It panics if there were any errors during merging.

Jump to

Keyboard shortcuts

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