base

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BExpressionPath    = BExpressionCtxKey("BExpressionPath")
	BExpressionElement = BExpressionCtxKey("BExpressionElement")
)

Variables

View Source
var (
	BinaryExpressionUnionError = NewUnionExpressionError("BinaryExpression", []string{"Literal", "Comparison", "Aggregator", "UnaryExpression"})
)
View Source
var ErrEmptyOperands = errors.New("at least one operand must be set")

Functions

func AggregatorOperatorStrings

func AggregatorOperatorStrings() []string

AggregatorOperatorStrings returns a slice of all String values of the enum

func CtxExtendPathAndSetElement

func CtxExtendPathAndSetElement(ctx context.Context, path string, element interface{}) context.Context

func UnaryOperatorStrings

func UnaryOperatorStrings() []string

UnaryOperatorStrings returns a slice of all String values of the enum

Types

type Aggregator

type Aggregator[T Comparison] struct {
	Operator AggregatorOperator    `json:"operator" yaml:"operator" gqlgen:"operator"`
	Operands []BinaryExpression[T] `json:"operands" yaml:"operands" gqlgen:"operands"`
}

func (*Aggregator[T]) Accept

func (a *Aggregator[T]) Accept(ctx context.Context, visitor Visitor) error

func (*Aggregator[T]) IsBinaryExpression

func (a *Aggregator[T]) IsBinaryExpression()

func (*Aggregator[T]) Validate

func (a *Aggregator[T]) Validate(ctx context.Context) error

type AggregatorOperator

type AggregatorOperator int
const (
	AggregatorOperatorAnd AggregatorOperator = iota
	AggregatorOperatorOr
)

func AggregatorOperatorString

func AggregatorOperatorString(s string) (AggregatorOperator, error)

AggregatorOperatorString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func AggregatorOperatorValues

func AggregatorOperatorValues() []AggregatorOperator

AggregatorOperatorValues returns all values of the enum

func (AggregatorOperator) IsAAggregatorOperator

func (i AggregatorOperator) IsAAggregatorOperator() bool

IsAAggregatorOperator returns "true" if the value is listed in the enum definition. "false" otherwise

func (AggregatorOperator) MarshalGQL

func (i AggregatorOperator) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface for AggregatorOperator

func (AggregatorOperator) MarshalJSON

func (i AggregatorOperator) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for AggregatorOperator

func (AggregatorOperator) MarshalYAML

func (i AggregatorOperator) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for AggregatorOperator

func (AggregatorOperator) String

func (i AggregatorOperator) String() string

func (*AggregatorOperator) UnmarshalGQL

func (i *AggregatorOperator) UnmarshalGQL(value interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface for AggregatorOperator

func (*AggregatorOperator) UnmarshalJSON

func (i *AggregatorOperator) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for AggregatorOperator

func (*AggregatorOperator) UnmarshalYAML

func (i *AggregatorOperator) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for AggregatorOperator

func (AggregatorOperator) Values

func (AggregatorOperator) Values() []string

type BExpressionCtxKey

type BExpressionCtxKey string

type BinaryExpression

type BinaryExpression[T Comparison] struct {
	Literal         *bool               `json:"literal,omitempty" yaml:"literal,omitempty" gqlgen:"literal"`
	Comparison      T                   `json:"comparison,omitempty" yaml:"comparison,omitempty" gqlgen:"comparison"`
	Aggregator      *Aggregator[T]      `json:"aggregator,omitempty" yaml:"aggregator,omitempty" gqlgen:"aggregator"`
	UnaryExpression *UnaryExpression[T] `json:"unaryExpression,omitempty" yaml:"unaryExpression,omitempty" gqlgen:"unaryExpression"`
}

func (*BinaryExpression[T]) Accept

func (b *BinaryExpression[T]) Accept(ctx context.Context, visitor Visitor) error

func (*BinaryExpression[T]) ToGql

func (b *BinaryExpression[T]) ToGql() (BinaryExpressionUnion, error)

func (*BinaryExpression[T]) Validate

func (b *BinaryExpression[T]) Validate(ctx context.Context) error

type BinaryExpressionUnion

type BinaryExpressionUnion interface {
	IsBinaryExpression()
}

type Comparison

type Comparison interface {
	Validatable
	VisitableElement
	ToGql() (BinaryExpressionUnion, error)
}

type ErrUnionExpression

type ErrUnionExpression struct {
	ElementType       string
	ElementChildTypes []string
}

func NewUnionExpressionError

func NewUnionExpressionError(elementType string, elementChildTypes []string) *ErrUnionExpression

func (*ErrUnionExpression) Error

func (e *ErrUnionExpression) Error() string

type Literal

type Literal[T any] struct {
	Value T `json:"value" yaml:"value" gqlgen:"value"`
}

type LiteralBool

type LiteralBool Literal[bool]

func (*LiteralBool) IsBinaryExpression

func (l *LiteralBool) IsBinaryExpression()

type MockVisitor

type MockVisitor struct {
	mock.Mock
}

MockVisitor is an autogenerated mock type for the Visitor type

func NewMockVisitor

func NewMockVisitor(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockVisitor

NewMockVisitor creates a new instance of MockVisitor. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockVisitor) EXPECT

func (_m *MockVisitor) EXPECT() *MockVisitor_Expecter

func (*MockVisitor) EnterExpressionElement

func (_m *MockVisitor) EnterExpressionElement(ctx context.Context, element VisitableElement) error

EnterExpressionElement provides a mock function with given fields: ctx, element

func (*MockVisitor) LeaveExpressionElement

func (_m *MockVisitor) LeaveExpressionElement(ctx context.Context, element VisitableElement)

LeaveExpressionElement provides a mock function with given fields: ctx, element

func (*MockVisitor) Literal

func (_m *MockVisitor) Literal(ctx context.Context, l interface{}) error

Literal provides a mock function with given fields: ctx, l

type MockVisitor_EnterExpressionElement_Call

type MockVisitor_EnterExpressionElement_Call struct {
	*mock.Call
}

MockVisitor_EnterExpressionElement_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnterExpressionElement'

func (*MockVisitor_EnterExpressionElement_Call) Return

func (*MockVisitor_EnterExpressionElement_Call) Run

func (*MockVisitor_EnterExpressionElement_Call) RunAndReturn

type MockVisitor_Expecter

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

func (*MockVisitor_Expecter) EnterExpressionElement

func (_e *MockVisitor_Expecter) EnterExpressionElement(ctx interface{}, element interface{}) *MockVisitor_EnterExpressionElement_Call

EnterExpressionElement is a helper method to define mock.On call

  • ctx context.Context
  • element VisitableElement

func (*MockVisitor_Expecter) LeaveExpressionElement

func (_e *MockVisitor_Expecter) LeaveExpressionElement(ctx interface{}, element interface{}) *MockVisitor_LeaveExpressionElement_Call

LeaveExpressionElement is a helper method to define mock.On call

  • ctx context.Context
  • element VisitableElement

func (*MockVisitor_Expecter) Literal

func (_e *MockVisitor_Expecter) Literal(ctx interface{}, l interface{}) *MockVisitor_Literal_Call

Literal is a helper method to define mock.On call

  • ctx context.Context
  • l interface{}

type MockVisitor_LeaveExpressionElement_Call

type MockVisitor_LeaveExpressionElement_Call struct {
	*mock.Call
}

MockVisitor_LeaveExpressionElement_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LeaveExpressionElement'

func (*MockVisitor_LeaveExpressionElement_Call) Return

func (*MockVisitor_LeaveExpressionElement_Call) Run

func (*MockVisitor_LeaveExpressionElement_Call) RunAndReturn

type MockVisitor_Literal_Call

type MockVisitor_Literal_Call struct {
	*mock.Call
}

MockVisitor_Literal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Literal'

func (*MockVisitor_Literal_Call) Return

func (*MockVisitor_Literal_Call) Run

func (_c *MockVisitor_Literal_Call) Run(run func(ctx context.Context, l interface{})) *MockVisitor_Literal_Call

func (*MockVisitor_Literal_Call) RunAndReturn

func (_c *MockVisitor_Literal_Call) RunAndReturn(run func(context.Context, interface{}) error) *MockVisitor_Literal_Call

type UnaryExpression

type UnaryExpression[T Comparison] struct {
	Operator UnaryOperator       `json:"operator" yaml:"operator" gqlgen:"operator"`
	Operand  BinaryExpression[T] `json:"expression" yaml:"expression" gqlgen:"expression"`
}

func (*UnaryExpression[T]) Accept

func (n *UnaryExpression[T]) Accept(ctx context.Context, visitor Visitor) error

func (*UnaryExpression[T]) IsBinaryExpression

func (n *UnaryExpression[T]) IsBinaryExpression()

func (*UnaryExpression[T]) Validate

func (n *UnaryExpression[T]) Validate(ctx context.Context) error

type UnaryOperator

type UnaryOperator int
const (
	UnaryOperatorNot UnaryOperator = iota
)

func UnaryOperatorString

func UnaryOperatorString(s string) (UnaryOperator, error)

UnaryOperatorString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func UnaryOperatorValues

func UnaryOperatorValues() []UnaryOperator

UnaryOperatorValues returns all values of the enum

func (UnaryOperator) IsAUnaryOperator

func (i UnaryOperator) IsAUnaryOperator() bool

IsAUnaryOperator returns "true" if the value is listed in the enum definition. "false" otherwise

func (UnaryOperator) MarshalGQL

func (i UnaryOperator) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface for UnaryOperator

func (UnaryOperator) MarshalJSON

func (i UnaryOperator) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for UnaryOperator

func (UnaryOperator) MarshalYAML

func (i UnaryOperator) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for UnaryOperator

func (UnaryOperator) String

func (i UnaryOperator) String() string

func (*UnaryOperator) UnmarshalGQL

func (i *UnaryOperator) UnmarshalGQL(value interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface for UnaryOperator

func (*UnaryOperator) UnmarshalJSON

func (i *UnaryOperator) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for UnaryOperator

func (*UnaryOperator) UnmarshalYAML

func (i *UnaryOperator) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for UnaryOperator

func (UnaryOperator) Values

func (UnaryOperator) Values() []string

type Validatable

type Validatable interface {
	Validate(ctx context.Context) error
}

type VisitableElement

type VisitableElement interface {
	Accept(ctx context.Context, visitor Visitor) error
}

type Visitor

type Visitor interface {
	EnterExpressionElement(ctx context.Context, element VisitableElement) error
	LeaveExpressionElement(ctx context.Context, element VisitableElement)

	Literal(ctx context.Context, l interface{}) error
}

Jump to

Keyboard shortcuts

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