boolean

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func If

func If(b Interface, doIfFn func(criteria Interface)) bool

If executes the provided doIfFn if the given Interface is true and return whether the function was executed.

func IfElse

func IfElse(
	b Interface,
	doIfFn func(criteria Interface),
	doElseFn func(elseCriteria Interface),
) bool

IfElse executes the provided doIfFn if the given Interface is true. Otherwise, doElseFn is executed instead. Finally, the value of Interface will be returned.

func IfNot

func IfNot(b Interface, doIfNotFn func(criteria Interface)) bool

IfNot executes the provided doIfNotFn if the given Interface is false and return whether the function was executed.

Types

type Interface

type Interface interface {
	Value
	// And applies AND operation on the value of this Interface and the given acal.TypedValue.
	And(acal.TypedValue[bool]) Simple
	// Or applies OR operation on the value of this Interface and the given acal.TypedValue.
	Or(acal.TypedValue[bool]) Simple
	// Not returns the inverse value of this Interface.
	Not() Simple
}

Interface governs the methods that Value should provide.

type MockInterface

type MockInterface struct {
	mock.Mock
}

MockInterface is an autogenerated mock type for the Interface type

func NewMockInterface

func NewMockInterface(t mockConstructorTestingTNewMockInterface) *MockInterface

NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockInterface) And

func (_m *MockInterface) And(_a0 acal.TypedValue[bool]) Simple

And provides a mock function with given fields: _a0

func (*MockInterface) Bool

func (_m *MockInterface) Bool() bool

Bool provides a mock function with given fields:

func (*MockInterface) ExtractValues

func (_m *MockInterface) ExtractValues(cache acal.IValueCache) acal.IValueCache

ExtractValues provides a mock function with given fields: cache

func (*MockInterface) GetAlias

func (_m *MockInterface) GetAlias() string

GetAlias provides a mock function with given fields:

func (*MockInterface) GetName

func (_m *MockInterface) GetName() string

GetName provides a mock function with given fields:

func (*MockInterface) GetTypedValue

func (_m *MockInterface) GetTypedValue() bool

GetTypedValue provides a mock function with given fields:

func (*MockInterface) GetValue

func (_m *MockInterface) GetValue() interface{}

GetValue provides a mock function with given fields:

func (*MockInterface) HasIdentity

func (_m *MockInterface) HasIdentity() bool

HasIdentity provides a mock function with given fields:

func (*MockInterface) Identify

func (_m *MockInterface) Identify() string

Identify provides a mock function with given fields:

func (*MockInterface) IsNil

func (_m *MockInterface) IsNil() bool

IsNil provides a mock function with given fields:

func (*MockInterface) Not

func (_m *MockInterface) Not() Simple

Not provides a mock function with given fields:

func (*MockInterface) Or

func (_m *MockInterface) Or(_a0 acal.TypedValue[bool]) Simple

Or provides a mock function with given fields: _a0

func (*MockInterface) SetAlias

func (_m *MockInterface) SetAlias(_a0 string)

SetAlias provides a mock function with given fields: _a0

func (*MockInterface) Stringify

func (_m *MockInterface) Stringify() string

Stringify provides a mock function with given fields:

func (*MockInterface) ToSyntaxOperand

func (_m *MockInterface) ToSyntaxOperand(nextOp acal.Op) *acal.SyntaxOperand

ToSyntaxOperand provides a mock function with given fields: nextOp

type MockValue

type MockValue struct {
	mock.Mock
}

MockValue is an autogenerated mock type for the Value type

func NewMockValue

func NewMockValue(t mockConstructorTestingTNewMockValue) *MockValue

NewMockValue creates a new instance of MockValue. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockValue) Bool

func (_m *MockValue) Bool() bool

Bool provides a mock function with given fields:

func (*MockValue) ExtractValues

func (_m *MockValue) ExtractValues(cache acal.IValueCache) acal.IValueCache

ExtractValues provides a mock function with given fields: cache

func (*MockValue) GetAlias

func (_m *MockValue) GetAlias() string

GetAlias provides a mock function with given fields:

func (*MockValue) GetName

func (_m *MockValue) GetName() string

GetName provides a mock function with given fields:

func (*MockValue) GetTypedValue

func (_m *MockValue) GetTypedValue() bool

GetTypedValue provides a mock function with given fields:

func (*MockValue) GetValue

func (_m *MockValue) GetValue() interface{}

GetValue provides a mock function with given fields:

func (*MockValue) HasIdentity

func (_m *MockValue) HasIdentity() bool

HasIdentity provides a mock function with given fields:

func (*MockValue) Identify

func (_m *MockValue) Identify() string

Identify provides a mock function with given fields:

func (*MockValue) IsNil

func (_m *MockValue) IsNil() bool

IsNil provides a mock function with given fields:

func (*MockValue) SetAlias

func (_m *MockValue) SetAlias(_a0 string)

SetAlias provides a mock function with given fields: _a0

func (*MockValue) Stringify

func (_m *MockValue) Stringify() string

Stringify provides a mock function with given fields:

func (*MockValue) ToSyntaxOperand

func (_m *MockValue) ToSyntaxOperand(nextOp acal.Op) *acal.SyntaxOperand

ToSyntaxOperand provides a mock function with given fields: nextOp

type Simple

type Simple struct {
	*acal.Simple[bool]
}

Simple ...

var NilBool Simple

func MakeSimple

func MakeSimple(name string, value bool) Simple

MakeSimple ...

func MakeSimpleFrom

func MakeSimpleFrom(value acal.TypedValue[bool]) Simple

MakeSimpleFrom returns a new Simple using the given value as formula.

func MakeSimpleWithFormula

func MakeSimpleWithFormula(value bool, formulaFn func() *acal.SyntaxNode) Simple

MakeSimpleWithFormula returns a new Simple with the given value and formula.

func PerformBinaryLogicOp

func PerformBinaryLogicOp[T any](
	tv1 acal.TypedValue[T],
	tv2 acal.TypedValue[T],
	op acal.Op,
	opDesc string,
	binaryOpFn func(a, b T) bool,
) Simple

PerformBinaryLogicOp returns a Simple to represent the result of performing binaryOpFn on the values of the provided acal.TypedValue.

func PerformUnaryLogicOp

func PerformUnaryLogicOp[T any](
	tv acal.TypedValue[T],
	fnName string,
	unaryOpFn func(v T) bool,
) Simple

PerformUnaryLogicOp returns a Simple to represent the result of performing unaryOpFn on the values of the provided acal.TypedValue.

func (Simple) Anchor

func (s Simple) Anchor(name string) Simple

Anchor updates the name of this Simple to the provided string.

func (Simple) And

func (s Simple) And(s2 acal.TypedValue[bool]) Simple

And applies AND operation on the value of this Simple and the given acal.TypedValue.

func (Simple) Bool

func (s Simple) Bool() bool

Bool returns the value of this Simple as a bool. If it's nil, false is returned.

func (Simple) GetTypedValue

func (s Simple) GetTypedValue() bool

GetTypedValue returns the typed value this Simple contains.

func (Simple) Not

func (s Simple) Not() Simple

Not returns the inverse value of this Simple.

func (Simple) Or

func (s Simple) Or(s2 acal.TypedValue[bool]) Simple

Or applies OR operation on the value of this Simple and the given acal.TypedValue.

func (Simple) Then

func (s Simple) Then() Simple

Then does nothing and returns this Simple as-is. It's meant for separating code into more readable chunk.

func (Simple) ToSyntaxOperand

func (s Simple) ToSyntaxOperand(nextOp acal.Op) *acal.SyntaxOperand

ToSyntaxOperand returns the acal.SyntaxOperand representation of this Simple.

type Value

type Value interface {
	acal.TypedValue[bool]
	// Bool returns the value of this Value as a bool.
	// If it's nil, false is returned.
	Bool() bool
}

Value represents an acal.Value of boolean kind.

Jump to

Keyboard shortcuts

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