common

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	URL_UNIQUENESS_NAME          string = "url"
	REPR_UNIQUENESS_NAME         string = "repr"
	TRANSIENT_ID_UNIQUENESS_NAME string = "transient-id"

	URL_UNIQUENESS_IDENT          = core.Identifier(URL_UNIQUENESS_NAME)
	REPR_UNIQUENESS_IDENT         = core.Identifier(REPR_UNIQUENESS_NAME)
	TRANSIENT_ID_UNIQUENESS_IDENT = core.Identifier(TRANSIENT_ID_UNIQUENESS_NAME)
)

Variables

View Source
var (
	ErrFailedGetUniqueKeyNoURL                                  = errors.New("failed to get unique key for value since it has no URL")
	ErrFailedGetUniqueKeyNoProps                                = errors.New("failed to get unique key for value since it has no properties")
	ErrFailedGetUniqueKeyPropMissing                            = errors.New("failed to get unique key for value since the property is missing")
	ErrPropertyBasedUniquenessRequireValuesToHaveTheProperty    = errors.New("property-based uniqueness requires values to have the property")
	ErrReprBasedUniquenessRequireValuesToBeImmutable            = errors.New("representation-based uniqueness requires values to be immutable")
	ErrTransientIDBasedUniquenessRequireValuesToHaveTransientID = errors.New("transient id-based uniqueness requires values to have a transient id")
	ErrUrlBasedUniquenessRequireValuesToBeUrlHolders            = errors.New("URL-based uniqueness requires values to be URL holders")
	ErrContainerShouldHaveURL                                   = errors.New("container should have a URL")
	ErrCannotAddURLToElemOfOtherContainer                       = errors.New("cannot add a URL to the element of an other container")

	UniqueKeyReprConfig = &core.ReprConfig{AllVisible: true}

	URL_UNIQUENESS_SYMB_IDENT          = symbolic.NewIdentifier(URL_UNIQUENESS_IDENT.UnderlyingString())
	REPR_UNIQUENESS_SYMB_IDENT         = symbolic.NewIdentifier(REPR_UNIQUENESS_IDENT.UnderlyingString())
	TRANSIENT_ID_UNIQUENESS_SYMB_IDENT = symbolic.NewIdentifier(TRANSIENT_ID_UNIQUENESS_IDENT.UnderlyingString())

	EXPECTED_SYMB_VALUE_FOR_UNIQUENESS = fmt.Sprintf("#%s, #%s, #%s or a property name is expected",
		URL_UNIQUENESS_IDENT,
		REPR_UNIQUENESS_IDENT,
		TRANSIENT_ID_UNIQUENESS_IDENT,
	)
)

Functions

func GetElementPathKeyFromKey

func GetElementPathKeyFromKey(key string, uniqueness UniquenessConstraintType) core.ElementKey

func GetUniqueKey

func GetUniqueKey(ctx *core.Context, args KeyRetrievalParams) string

GetUniqueKey computes the key of the provided value. For UniqueRepr and UniquePropertyValue uniqueness the key is written to the provided stream, so the returned string should be cloned before being stored. GetUniqueKey does not support retrieving the key for UniqueAddress uniqueness.

Types

type CollectionIterator

type CollectionIterator struct {
	HasNext_ func(*CollectionIterator, *core.Context) bool
	Next_    func(*CollectionIterator, *core.Context) bool
	Key_     func(*CollectionIterator, *core.Context) core.Value
	Value_   func(*CollectionIterator, *core.Context) core.Value
}

func NewEmptyCollectionIterator

func NewEmptyCollectionIterator() *CollectionIterator

func (*CollectionIterator) Equal

func (it *CollectionIterator) Equal(ctx *core.Context, other core.Value, alreadyCompared map[uintptr]uintptr, depth int) bool

func (*CollectionIterator) HasNext

func (it *CollectionIterator) HasNext(ctx *core.Context) bool

func (*CollectionIterator) IsMutable

func (it *CollectionIterator) IsMutable() bool

func (*CollectionIterator) Iterator

func (*CollectionIterator) Key

func (it *CollectionIterator) Key(ctx *core.Context) core.Value

func (*CollectionIterator) Next

func (it *CollectionIterator) Next(ctx *core.Context) bool

func (*CollectionIterator) PrettyPrint

func (it *CollectionIterator) PrettyPrint(w *bufio.Writer, config *core.PrettyPrintConfig, depth int, parentIndentCount int)

func (*CollectionIterator) ToSymbolicValue

func (it *CollectionIterator) ToSymbolicValue(ctx *core.Context, encountered map[uintptr]symbolic.Value) (symbolic.Value, error)

func (*CollectionIterator) Value

func (it *CollectionIterator) Value(ctx *core.Context) core.Value

type KeyRetrievalParams

type KeyRetrievalParams struct {
	Value                   core.Serializable
	Config                  UniquenessConstraint
	Container               core.Value
	Stream                  *jsoniter.Stream
	JSONSerializationConfig core.JSONSerializationConfig
}

type UniquenessConstraint

type UniquenessConstraint struct {
	Type         UniquenessConstraintType
	PropertyName core.PropertyName //set if UniquePropertyValue
}

func DeserializeNextUniquenessConstraintFromJSON

func DeserializeNextUniquenessConstraintFromJSON(it *jsoniter.Iterator) (UniquenessConstraint, error)

func NewPropertyValueUniqueness

func NewPropertyValueUniqueness(name string) *UniquenessConstraint

func NewReprUniqueness

func NewReprUniqueness() *UniquenessConstraint

func NewTransientIdUniqueness

func NewTransientIdUniqueness() *UniquenessConstraint

func NewURLUniqueness

func NewURLUniqueness() *UniquenessConstraint

func UniquenessConstraintFromSymbolicValue

func UniquenessConstraintFromSymbolicValue(val symbolic.Value, elementPattern symbolic.Pattern) (UniquenessConstraint, error)

func UniquenessConstraintFromValue

func UniquenessConstraintFromValue(val core.Value) (UniquenessConstraint, bool)

func (UniquenessConstraint) AddUrlIfNecessary

func (c UniquenessConstraint) AddUrlIfNecessary(ctx *core.Context, container core.UrlHolder, element core.Value)

func (UniquenessConstraint) Equal

func (c UniquenessConstraint) Equal(otherConstraint UniquenessConstraint) bool

func (UniquenessConstraint) ToSymbolicValue

func (c UniquenessConstraint) ToSymbolicValue() symbolic.Value

func (UniquenessConstraint) ToValue

func (UniquenessConstraint) WriteJSONRepresentation

func (c UniquenessConstraint) WriteJSONRepresentation(w *jsoniter.Stream)

type UniquenessConstraintType

type UniquenessConstraintType int
const (
	UniqueRepr UniquenessConstraintType = iota + 1
	UniqueURL
	UniquePropertyValue
	UniqueTransientID
)

Jump to

Keyboard shortcuts

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