Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyStaticCondition(criteria TypedValue[bool], values ...StaticConditionalValue)
- func Describe(v Value) string
- func DescribeValueAsFormula[T any](v TypedValue[T]) func() *SyntaxNode
- func ExtractTypedValue[T any](tv TypedValue[T]) T
- func HasIdentity(v Value) bool
- func Identify(v Value) string
- func IsNilValue(v Value) bool
- func MarshalJSON(values ...Value) ([]byte, error)
- func MarshalJSONByFields(data any) ([]byte, error)
- func Stringify(v Value) string
- func ToString(aVal ...Value) string
- type CloseIfFunc
- type Condition
- type Constant
- func (c *Constant[T]) ExtractValues(cache IValueCache) IValueCache
- func (v *Constant) GetAlias() string
- func (f *Constant) GetFormatFn() func(T) string
- func (c *Constant[T]) GetFormulaFn() func() *SyntaxNode
- func (v *Constant) GetName() string
- func (c *Constant[T]) GetTypedValue() T
- func (c *Constant[T]) GetValue() any
- func (c *Constant[T]) HasFormula() bool
- func (v *Constant) HasIdentity() bool
- func (v *Constant) Identify() string
- func (c *Constant[T]) IsNil() bool
- func (c *Constant[T]) SetAlias(alias string)
- func (c *Constant[T]) Stringify() string
- func (c *Constant[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
- func (f *Constant) WithFormatFn(formatFn func(T) string)
- type ICondOps
- type IMarshalOps
- type ITagger
- type IValueCache
- type IValueOps
- type Local
- func (c *Local) AddCondition(condition *Condition)
- func (l *Local[T]) DoAnchor(name string) *Simple[T]
- func (l *Local[T]) ExtractValues(cache IValueCache) IValueCache
- func (v *Local) GetAlias() string
- func (c *Local) GetCondition() *Condition
- func (f *Local) GetFormatFn() func(T) string
- func (v *Local) GetName() string
- func (t *Local) GetTags() Tags
- func (l *Local[T]) GetTypedValue() T
- func (l *Local[T]) GetValue() any
- func (v *Local) HasIdentity() bool
- func (v *Local) Identify() string
- func (c *Local) IsConditional() bool
- func (l *Local[T]) IsNil() bool
- func (l *Local[T]) MarshalJSON() ([]byte, error)
- func (v *Local) SetAlias(alias string)
- func (l *Local[T]) Stringify() string
- func (t *Local) Tag(tags ...Tag)
- func (l *Local[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
- func (f *Local) WithFormatFn(formatFn func(T) string)
- type MockICondOps
- type MockIMarshalOps
- type MockITagger
- type MockIValueCache
- type MockIValueOps
- func (_m *MockIValueOps) Describe(v Value) string
- func (_m *MockIValueOps) DescribeValueAsFormula(v Value) func() *SyntaxNode
- func (_m *MockIValueOps) HasIdentity(v Value) bool
- func (_m *MockIValueOps) Identify(v Value) string
- func (_m *MockIValueOps) IsNilValue(v Value) bool
- func (_m *MockIValueOps) Stringify(v Value) string
- type MockProgressiveConditionalValue
- type MockStaticConditionalValue
- type MockTypedValue
- func (_m *MockTypedValue[T]) ExtractValues(cache IValueCache) IValueCache
- func (_m *MockTypedValue[T]) GetAlias() string
- func (_m *MockTypedValue[T]) GetName() string
- func (_m *MockTypedValue[T]) GetTypedValue() T
- func (_m *MockTypedValue[T]) GetValue() interface{}
- func (_m *MockTypedValue[T]) HasIdentity() bool
- func (_m *MockTypedValue[T]) Identify() string
- func (_m *MockTypedValue[T]) IsNil() bool
- func (_m *MockTypedValue[T]) SetAlias(_a0 string)
- func (_m *MockTypedValue[T]) Stringify() string
- func (_m *MockTypedValue[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
- type MockValue
- func (_m *MockValue) ExtractValues(cache IValueCache) IValueCache
- func (_m *MockValue) GetAlias() string
- func (_m *MockValue) GetName() string
- func (_m *MockValue) GetValue() interface{}
- func (_m *MockValue) HasIdentity() bool
- func (_m *MockValue) Identify() string
- func (_m *MockValue) IsNil() bool
- func (_m *MockValue) SetAlias(_a0 string)
- func (_m *MockValue) Stringify() string
- func (_m *MockValue) ToSyntaxOperand(nextOp Op) *SyntaxOperand
- type Op
- type OpCategory
- type Progressive
- func (p *Progressive[T]) AddCondition(criteria TypedValue[bool]) CloseIfFunc
- func (p *Progressive[T]) AsTag() Tag
- func (p *Progressive[T]) DoAnchor(name string) *Simple[T]
- func (p *Progressive[T]) ExtractValues(cache IValueCache) IValueCache
- func (v *Progressive) GetAlias() string
- func (f *Progressive) GetFormatFn() func(T) string
- func (v *Progressive) GetName() string
- func (t *Progressive) GetTags() Tags
- func (p *Progressive[T]) GetTypedValue() T
- func (p *Progressive[T]) GetValue() any
- func (v *Progressive) HasIdentity() bool
- func (v *Progressive) Identify() string
- func (p *Progressive[T]) IsNil() bool
- func (p *Progressive[T]) MarshalJSON() ([]byte, error)
- func (v *Progressive) SetAlias(alias string)
- func (p *Progressive[T]) Stringify() string
- func (t *Progressive) Tag(tags ...Tag)
- func (p *Progressive[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
- func (p *Progressive[T]) Update(value TypedValue[T])
- func (f *Progressive) WithFormatFn(formatFn func(T) string)
- type ProgressiveConditionalValue
- type Remote
- func (c *Remote) AddCondition(condition *Condition)
- func (r *Remote[T]) DoAnchor(name string) *Simple[T]
- func (r *Remote[T]) ExtractValues(cache IValueCache) IValueCache
- func (v *Remote) GetAlias() string
- func (c *Remote) GetCondition() *Condition
- func (f *Remote) GetFormatFn() func(T) string
- func (v *Remote) GetName() string
- func (t *Remote) GetTags() Tags
- func (r *Remote[T]) GetTypedValue() T
- func (r *Remote[T]) GetValue() any
- func (v *Remote) HasIdentity() bool
- func (v *Remote) Identify() string
- func (c *Remote) IsConditional() bool
- func (r *Remote[T]) IsNil() bool
- func (r *Remote[T]) MarshalJSON() ([]byte, error)
- func (v *Remote) SetAlias(alias string)
- func (r *Remote[T]) Stringify() string
- func (t *Remote) Tag(tags ...Tag)
- func (r *Remote[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
- func (f *Remote) WithFormatFn(formatFn func(T) string)
- type Simple
- func (c *Simple) AddCondition(condition *Condition)
- func (s *Simple[T]) DoAnchor(name string) (*Simple[T], bool)
- func (s *Simple[T]) ExtractValues(cache IValueCache) IValueCache
- func (s *Simple[T]) From(source Source)
- func (v *Simple) GetAlias() string
- func (c *Simple) GetCondition() *Condition
- func (f *Simple) GetFormatFn() func(T) string
- func (s *Simple[T]) GetFormulaFn() func() *SyntaxNode
- func (v *Simple) GetName() string
- func (s *Simple[T]) GetSource() Source
- func (t *Simple) GetTags() Tags
- func (s *Simple[T]) GetTypedValue() T
- func (s *Simple[T]) GetValue() any
- func (s *Simple[T]) HasFormula() bool
- func (v *Simple) HasIdentity() bool
- func (v *Simple) Identify() string
- func (c *Simple) IsConditional() bool
- func (s *Simple[T]) IsNil() bool
- func (s *Simple[T]) MarshalJSON() ([]byte, error)
- func (v *Simple) SetAlias(alias string)
- func (s *Simple[T]) Stringify() string
- func (t *Simple) Tag(tags ...Tag)
- func (s *Simple[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
- func (f *Simple) WithFormatFn(formatFn func(T) string)
- type Source
- type Stage
- func (s *Stage[T]) ExtractValues(cache IValueCache) IValueCache
- func (s *Stage[T]) GetAlias() string
- func (s *Stage[T]) GetName() string
- func (s *Stage[T]) GetTypedValue() T
- func (s *Stage[T]) GetValue() any
- func (s *Stage[T]) HasIdentity() bool
- func (s *Stage[T]) Identify() string
- func (s *Stage[T]) IsNil() bool
- func (s *Stage[T]) SetAlias(alias string)
- func (s *Stage[T]) Stringify() string
- func (s *Stage[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
- type StaticConditionalValue
- type SyntaxNode
- type SyntaxOperand
- type Tag
- type Tags
- type TypedValue
- type Value
Constants ¶
const (
UnknownValueName = "Unknown"
)
Variables ¶
var AppendTags = func(t ITagger, tags ...Tag) Tags { if t == nil { return nil } curTags := t.GetTags() if curTags == nil { return tags } return curTags.AddTags(tags...) }
AppendTags appends the provided Tag to collection of tags of the given ITagger.
var PerformStandardValueExtraction = func(v Value, cache IValueCache) IValueCache { if IsNilValue(v) { return cache } if HasIdentity(v) { if !cache.Take(v) { return cache } } if c, ok := v.(StaticConditionalValue); ok && c.IsConditional() { c.GetCondition().criteria.ExtractValues(cache) } if t, ok := v.(ITagger); ok { for _, tag := range t.GetTags() { if tag.aVal != nil { tag.aVal.ExtractValues(cache) } } } fp, ok := v.(formulaProvider) if !ok || !fp.HasFormula() { return cache } formula := fp.GetFormulaFn()() for _, operand := range formula.GetOperands() { if ev, ok := operand.(extractable); ok { ev.ExtractValues(cache) } } return cache }
PerformStandardValueExtraction extracts all Value that were used to calculate the given value and put them in the provided cache.
Functions ¶
func ApplyStaticCondition ¶
func ApplyStaticCondition(criteria TypedValue[bool], values ...StaticConditionalValue)
ApplyStaticCondition creates a Condition and applies it on all given StaticConditionalValue.
func Describe ¶
Describe returns a full description of the given Value, including its identity and current value in string format.
func DescribeValueAsFormula ¶
func DescribeValueAsFormula[T any](v TypedValue[T]) func() *SyntaxNode
DescribeValueAsFormula returns a full description of the given Value, in the form of a formula.
func ExtractTypedValue ¶
func ExtractTypedValue[T any](tv TypedValue[T]) T
ExtractTypedValue returns the typed value the given TypedValue contains.
func HasIdentity ¶
HasIdentity returns whether the given Value is anchored.
func Identify ¶
Identify returns the identity of the given Value, which is its alias if not nil. Otherwise, the result should be its name.
func MarshalJSON ¶
MarshalJSON puts the provided Value and all other Value that were used to calculate the given Value into a map and returns a JSON encoding of this map.
func MarshalJSONByFields ¶
MarshalJSONByFields will execute MarshalJSON on the provided data if it's a Value. Otherwise, each exported field of the provided data will be put into a map. If such field is a Value, all other Value that were used to calculate this field will also be added to this map. Finally, a JSON encoding of this map will be returned.
If the alias of any Value happens to collide with the name of non-Value fields, such Value will be de-duplicated in the JSON map by appending a suffix to the alias of all duplicates. Format for alias of de-duplicated variables: <name_of_variable>.<count>. - count starts from 2 - example: duplicate.2, duplicate3.2
Types ¶
type CloseIfFunc ¶
type CloseIfFunc func()
CloseIfFunc is to be called when an if clause ends so that progressive variables can record the close if stage index.
var DoNothingCloseIfFunc CloseIfFunc = func() {}
DoNothingCloseIfFunc is a CloseIfFunc that does nothing.
func ApplyProgressiveCondition ¶
func ApplyProgressiveCondition(criteria TypedValue[bool], values ...ProgressiveConditionalValue) CloseIfFunc
ApplyProgressiveCondition applies the provided Condition on all given ProgressiveConditionalValue and returns a single CloseIfFunc to close all conditions at once.
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
Condition represents an if clause in a calculation algorithm.
func NewCondition ¶
func NewCondition(criteria TypedValue[bool]) *Condition
NewCondition returns a new Condition with the provided fields.
func NewProgressiveCondition ¶
func NewProgressiveCondition(criteria TypedValue[bool], prevCondition *Condition, openIfStageIdx int) *Condition
NewProgressiveCondition returns a new Condition with the provided fields.
func (*Condition) MarshalJSON ¶
MarshalJSON returns the JSON encoding of this Condition.
type Constant ¶
type Constant[T any] struct { // contains filtered or unexported fields }
Constant ...
func NewConstantWithFormat ¶
NewConstantWithFormat ...
func (*Constant[T]) ExtractValues ¶
func (c *Constant[T]) ExtractValues(cache IValueCache) IValueCache
ExtractValues does nothing for Constant as it's a constant.
func (*Constant) GetFormatFn ¶
func (f *Constant) GetFormatFn() func(T) string
func (*Constant[T]) GetFormulaFn ¶
func (c *Constant[T]) GetFormulaFn() func() *SyntaxNode
GetFormulaFn returns the function to build a formula of this Constant.
func (*Constant[T]) GetTypedValue ¶
func (c *Constant[T]) GetTypedValue() T
GetTypedValue returns the typed value this Constant contains.
func (*Constant[T]) HasFormula ¶
HasFormula returns whether this Constant has a formula.
func (*Constant[T]) ToSyntaxOperand ¶
func (c *Constant[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
ToSyntaxOperand returns the SyntaxOperand representation of this Constant.
func (*Constant) WithFormatFn ¶
func (f *Constant) WithFormatFn(formatFn func(T) string)
type ICondOps ¶
type ICondOps interface { // ApplyStaticCondition ... ApplyStaticCondition(criteria TypedValue[bool], values ...StaticConditionalValue) // ApplyProgressiveCondition ... ApplyProgressiveCondition(criteria TypedValue[bool], values ...ProgressiveConditionalValue) CloseIfFunc }
ICondOps ...
type IMarshalOps ¶
type IMarshalOps interface { // MarshalJSON ... MarshalJSON(values ...Value) ([]byte, error) // MarshalJSONByFields ... MarshalJSONByFields(data any) ([]byte, error) }
IMarshalOps ...
type ITagger ¶
type ITagger interface { // Tag append the given Tag to the existing tags of this ITagger. Tag(...Tag) // GetTags returns the current tags of this ITagger. GetTags() Tags }
ITagger represents any struct that can have tags attached to it.
type IValueCache ¶
type IValueCache interface { // Take accepts a Value to put into ValueCache. It will automatically de-duplicate // variables under the same name by giving duplicates an alias if it doesn't have // one already. The return value indicates whether the given value was accepted // into the cache. // // Format for alias of de-duplicated variables: <name_of_variable><count>. // - count starts from 2 // - example: duplicate2, duplicate3 Take(v Value) bool // Flatten returns a map of calculated variables that is ready for marshalling into // JSON. Variables with colliding alias will be de-duplicated by appending a count // suffix to the alias of all duplicates. // // Format for alias of de-duplicated variables: <name_of_variable>_<count>. // - count starts from 2 // - example: duplicate_2, duplicate3_2 Flatten() map[string]Value }
IValueCache keeps extracted values during marshalling so that we can build a complete JSON structure containing all calculated variables from a small set of input variables.
type IValueOps ¶
type IValueOps interface { // IsNilValue ... IsNilValue(v Value) bool // HasIdentity ... HasIdentity(v Value) bool // Identify ... Identify(v Value) string // Stringify ... Stringify(v Value) string // Describe ... Describe(v Value) string // DescribeValueAsFormula ... DescribeValueAsFormula(v Value) func() *SyntaxNode }
IValueOps ...
type Local ¶
type Local[T any] struct { // contains filtered or unexported fields }
Local ...
func (*Local) AddCondition ¶
func (c *Local) AddCondition(condition *Condition)
AddCondition attaches the given Condition to this Simple.
func (*Local[T]) DoAnchor ¶
DoAnchor returns a new Simple initialized to the value of this Local and anchored with the given name.
func (*Local[T]) ExtractValues ¶
func (l *Local[T]) ExtractValues(cache IValueCache) IValueCache
ExtractValues extracts this Local and all Value that were used to calculate it.
func (*Local) GetCondition ¶
func (c *Local) GetCondition() *Condition
GetCondition returns the Condition attached to this Simple.
func (*Local) GetFormatFn ¶
func (f *Local) GetFormatFn() func(T) string
func (*Local) GetTags ¶
func (t *Local) GetTags() Tags
GetTags returns the current tags of this tagger.
func (*Local[T]) GetTypedValue ¶
func (l *Local[T]) GetTypedValue() T
GetTypedValue returns the typed value this Local contains.
func (*Local) IsConditional ¶
func (c *Local) IsConditional() bool
IsConditional returns whether a Condition is attached to this iStaticConditioner.
func (*Local[T]) MarshalJSON ¶
MarshalJSON returns the JSON encoding of this Local.
func (*Local) Tag ¶
func (t *Local) Tag(tags ...Tag)
Tag append the given Tag to the existing tags of this tagger.
func (*Local[T]) ToSyntaxOperand ¶
func (l *Local[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
ToSyntaxOperand returns the SyntaxOperand representation of this Local.
func (*Local) WithFormatFn ¶
func (f *Local) WithFormatFn(formatFn func(T) string)
type MockICondOps ¶
MockICondOps is an autogenerated mock type for the ICondOps type
func NewMockICondOps ¶
func NewMockICondOps(t mockConstructorTestingTNewMockICondOps) *MockICondOps
NewMockICondOps creates a new instance of MockICondOps. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockICondOps) ApplyProgressiveCondition ¶
func (_m *MockICondOps) ApplyProgressiveCondition(criteria TypedValue[bool], values ...ProgressiveConditionalValue) CloseIfFunc
ApplyProgressiveCondition provides a mock function with given fields: criteria, values
func (*MockICondOps) ApplyStaticCondition ¶
func (_m *MockICondOps) ApplyStaticCondition(criteria TypedValue[bool], values ...StaticConditionalValue)
ApplyStaticCondition provides a mock function with given fields: criteria, values
type MockIMarshalOps ¶
MockIMarshalOps is an autogenerated mock type for the IMarshalOps type
func NewMockIMarshalOps ¶
func NewMockIMarshalOps(t mockConstructorTestingTNewMockIMarshalOps) *MockIMarshalOps
NewMockIMarshalOps creates a new instance of MockIMarshalOps. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockIMarshalOps) MarshalJSON ¶
func (_m *MockIMarshalOps) MarshalJSON(values ...Value) ([]byte, error)
MarshalJSON provides a mock function with given fields: values
func (*MockIMarshalOps) MarshalJSONByFields ¶
func (_m *MockIMarshalOps) MarshalJSONByFields(data interface{}) ([]byte, error)
MarshalJSONByFields provides a mock function with given fields: data
type MockITagger ¶
MockITagger is an autogenerated mock type for the ITagger type
func NewMockITagger ¶
func NewMockITagger(t mockConstructorTestingTNewMockITagger) *MockITagger
NewMockITagger creates a new instance of MockITagger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockITagger) GetTags ¶
func (_m *MockITagger) GetTags() Tags
GetTags provides a mock function with given fields:
func (*MockITagger) Tag ¶
func (_m *MockITagger) Tag(_a0 ...Tag)
Tag provides a mock function with given fields: _a0
type MockIValueCache ¶
MockIValueCache is an autogenerated mock type for the IValueCache type
func NewMockIValueCache ¶
func NewMockIValueCache(t mockConstructorTestingTNewMockIValueCache) *MockIValueCache
NewMockIValueCache creates a new instance of MockIValueCache. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockIValueCache) Flatten ¶
func (_m *MockIValueCache) Flatten() map[string]Value
Flatten provides a mock function with given fields:
func (*MockIValueCache) Take ¶
func (_m *MockIValueCache) Take(v Value) bool
Take provides a mock function with given fields: v
type MockIValueOps ¶
MockIValueOps is an autogenerated mock type for the IValueOps type
func NewMockIValueOps ¶
func NewMockIValueOps(t mockConstructorTestingTNewMockIValueOps) *MockIValueOps
NewMockIValueOps creates a new instance of MockIValueOps. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockIValueOps) Describe ¶
func (_m *MockIValueOps) Describe(v Value) string
Describe provides a mock function with given fields: v
func (*MockIValueOps) DescribeValueAsFormula ¶
func (_m *MockIValueOps) DescribeValueAsFormula(v Value) func() *SyntaxNode
DescribeValueAsFormula provides a mock function with given fields: v
func (*MockIValueOps) HasIdentity ¶
func (_m *MockIValueOps) HasIdentity(v Value) bool
HasIdentity provides a mock function with given fields: v
func (*MockIValueOps) Identify ¶
func (_m *MockIValueOps) Identify(v Value) string
Identify provides a mock function with given fields: v
func (*MockIValueOps) IsNilValue ¶
func (_m *MockIValueOps) IsNilValue(v Value) bool
IsNilValue provides a mock function with given fields: v
func (*MockIValueOps) Stringify ¶
func (_m *MockIValueOps) Stringify(v Value) string
Stringify provides a mock function with given fields: v
type MockProgressiveConditionalValue ¶
MockProgressiveConditionalValue is an autogenerated mock type for the ProgressiveConditionalValue type
func NewMockProgressiveConditionalValue ¶
func NewMockProgressiveConditionalValue(t mockConstructorTestingTNewMockProgressiveConditionalValue) *MockProgressiveConditionalValue
NewMockProgressiveConditionalValue creates a new instance of MockProgressiveConditionalValue. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockProgressiveConditionalValue) AddCondition ¶
func (_m *MockProgressiveConditionalValue) AddCondition(_a0 TypedValue[bool]) CloseIfFunc
AddCondition provides a mock function with given fields: _a0
type MockStaticConditionalValue ¶
MockStaticConditionalValue is an autogenerated mock type for the StaticConditionalValue type
func NewMockStaticConditionalValue ¶
func NewMockStaticConditionalValue(t mockConstructorTestingTNewMockStaticConditionalValue) *MockStaticConditionalValue
NewMockStaticConditionalValue creates a new instance of MockStaticConditionalValue. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockStaticConditionalValue) AddCondition ¶
func (_m *MockStaticConditionalValue) AddCondition(_a0 *Condition)
AddCondition provides a mock function with given fields: _a0
func (*MockStaticConditionalValue) GetCondition ¶
func (_m *MockStaticConditionalValue) GetCondition() *Condition
GetCondition provides a mock function with given fields:
func (*MockStaticConditionalValue) IsConditional ¶
func (_m *MockStaticConditionalValue) IsConditional() bool
IsConditional provides a mock function with given fields:
type MockTypedValue ¶
MockTypedValue is an autogenerated mock type for the TypedValue type
func NewMockTypedValue ¶
func NewMockTypedValue[T interface{}](t mockConstructorTestingTNewMockTypedValue) *MockTypedValue[T]
NewMockTypedValue creates a new instance of MockTypedValue. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockTypedValue[T]) ExtractValues ¶
func (_m *MockTypedValue[T]) ExtractValues(cache IValueCache) IValueCache
ExtractValues provides a mock function with given fields: cache
func (*MockTypedValue[T]) GetAlias ¶
func (_m *MockTypedValue[T]) GetAlias() string
GetAlias provides a mock function with given fields:
func (*MockTypedValue[T]) GetName ¶
func (_m *MockTypedValue[T]) GetName() string
GetName provides a mock function with given fields:
func (*MockTypedValue[T]) GetTypedValue ¶
func (_m *MockTypedValue[T]) GetTypedValue() T
GetTypedValue provides a mock function with given fields:
func (*MockTypedValue[T]) GetValue ¶
func (_m *MockTypedValue[T]) GetValue() interface{}
GetValue provides a mock function with given fields:
func (*MockTypedValue[T]) HasIdentity ¶
func (_m *MockTypedValue[T]) HasIdentity() bool
HasIdentity provides a mock function with given fields:
func (*MockTypedValue[T]) Identify ¶
func (_m *MockTypedValue[T]) Identify() string
Identify provides a mock function with given fields:
func (*MockTypedValue[T]) IsNil ¶
func (_m *MockTypedValue[T]) IsNil() bool
IsNil provides a mock function with given fields:
func (*MockTypedValue[T]) SetAlias ¶
func (_m *MockTypedValue[T]) SetAlias(_a0 string)
SetAlias provides a mock function with given fields: _a0
func (*MockTypedValue[T]) Stringify ¶
func (_m *MockTypedValue[T]) Stringify() string
Stringify provides a mock function with given fields:
func (*MockTypedValue[T]) ToSyntaxOperand ¶
func (_m *MockTypedValue[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
ToSyntaxOperand provides a mock function with given fields: nextOp
type MockValue ¶
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) ExtractValues ¶
func (_m *MockValue) ExtractValues(cache IValueCache) IValueCache
ExtractValues provides a mock function with given fields: cache
func (*MockValue) GetValue ¶
func (_m *MockValue) GetValue() interface{}
GetValue provides a mock function with given fields:
func (*MockValue) HasIdentity ¶
HasIdentity provides a mock function with given fields:
func (*MockValue) ToSyntaxOperand ¶
func (_m *MockValue) ToSyntaxOperand(nextOp Op) *SyntaxOperand
ToSyntaxOperand provides a mock function with given fields: nextOp
type Op ¶
type Op int
Op represents an operation that can be performed on Value.
const ( // OpTransparent is a transparent op that does not show up in formulas. OpTransparent Op = -1 )
func (Op) IsTransparent ¶
IsTransparent returns whether this Op is the special OpTransparent.
type OpCategory ¶
type OpCategory int
OpCategory represents the kind of operation being performed, which can decide how such operation should be displayed in a formula.
const ( // OpCategoryFunctionCall represents an operation that looks like a function call. OpCategoryFunctionCall OpCategory = iota // OpCategoryTwoValMiddleOp represents an operation with the operator lies in the middle of 2 operands. OpCategoryTwoValMiddleOp // OpCategoryAssignVariable represents an assign operation where a variable is assigned as the value of another variable. OpCategoryAssignVariable // OpCategoryAssignStatic represents an assign operation where a static value is assigned as the value of a variable. OpCategoryAssignStatic )
type Progressive ¶
type Progressive[T any] struct { // contains filtered or unexported fields }
Progressive ...
func (*Progressive[T]) AddCondition ¶
func (p *Progressive[T]) AddCondition(criteria TypedValue[bool]) CloseIfFunc
AddCondition attaches the given condition to this Progressive, returning a CloseIfFunc that must be triggered when an if clause ends so that the framework can record at which stage this condition ends.
func (*Progressive[T]) AsTag ¶
func (p *Progressive[T]) AsTag() Tag
AsTag returns a Tag represented by this Progressive.
func (*Progressive[T]) DoAnchor ¶
func (p *Progressive[T]) DoAnchor(name string) *Simple[T]
DoAnchor returns a new Simple initialized to the current value of this Progressive and anchored with the given name.
func (*Progressive[T]) ExtractValues ¶
func (p *Progressive[T]) ExtractValues(cache IValueCache) IValueCache
ExtractValues extracts this Progressive and all Value that were used to calculate it.
func (*Progressive) GetFormatFn ¶
func (f *Progressive) GetFormatFn() func(T) string
func (*Progressive) GetTags ¶
func (t *Progressive) GetTags() Tags
GetTags returns the current tags of this tagger.
func (*Progressive[T]) GetTypedValue ¶
func (p *Progressive[T]) GetTypedValue() T
GetTypedValue returns the typed value this Progressive contains.
func (*Progressive[T]) GetValue ¶
func (p *Progressive[T]) GetValue() any
GetValue returns the untyped value this Progressive contains.
func (*Progressive[T]) IsNil ¶
func (p *Progressive[T]) IsNil() bool
IsNil returns whether this Progressive is nil.
func (*Progressive[T]) MarshalJSON ¶
func (p *Progressive[T]) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of this FloatP
func (*Progressive[T]) Stringify ¶
func (p *Progressive[T]) Stringify() string
Stringify returns the value this Progressive contains as a string.
func (*Progressive) Tag ¶
func (t *Progressive) Tag(tags ...Tag)
Tag append the given Tag to the existing tags of this tagger.
func (*Progressive[T]) ToSyntaxOperand ¶
func (p *Progressive[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
ToSyntaxOperand returns the SyntaxOperand representation of this Progressive.
func (*Progressive[T]) Update ¶
func (p *Progressive[T]) Update(value TypedValue[T])
Update adds a new Stage to this Progressive to record its new value.
func (*Progressive) WithFormatFn ¶
func (f *Progressive) WithFormatFn(formatFn func(T) string)
type ProgressiveConditionalValue ¶
type ProgressiveConditionalValue interface { // AddCondition attaches the given Condition to this ProgressiveConditionalValue // and returns a CloseIfFunc to close the Condition. AddCondition(TypedValue[bool]) CloseIfFunc }
ProgressiveConditionalValue needs to be implemented by progressive Value that might involve conditional calculation.
type Remote ¶
type Remote[T any] struct { // contains filtered or unexported fields }
Remote ...
func (*Remote) AddCondition ¶
func (c *Remote) AddCondition(condition *Condition)
AddCondition attaches the given Condition to this Simple.
func (*Remote[T]) DoAnchor ¶
DoAnchor returns a new Simple initialized to the value of this Remote and anchored with the given name.
func (*Remote[T]) ExtractValues ¶
func (r *Remote[T]) ExtractValues(cache IValueCache) IValueCache
ExtractValues extracts this Remote and all Value that were used to calculate it.
func (*Remote) GetCondition ¶
func (c *Remote) GetCondition() *Condition
GetCondition returns the Condition attached to this Simple.
func (*Remote) GetFormatFn ¶
func (f *Remote) GetFormatFn() func(T) string
func (*Remote) GetTags ¶
func (t *Remote) GetTags() Tags
GetTags returns the current tags of this tagger.
func (*Remote[T]) GetTypedValue ¶
func (r *Remote[T]) GetTypedValue() T
GetTypedValue returns the typed value this Remote contains.
func (*Remote) IsConditional ¶
func (c *Remote) IsConditional() bool
IsConditional returns whether a Condition is attached to this iStaticConditioner.
func (*Remote[T]) MarshalJSON ¶
MarshalJSON returns the JSON encoding of this Remote.
func (*Remote) Tag ¶
func (t *Remote) Tag(tags ...Tag)
Tag append the given Tag to the existing tags of this tagger.
func (*Remote[T]) ToSyntaxOperand ¶
func (r *Remote[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
ToSyntaxOperand returns the SyntaxOperand representation of this Remote.
func (*Remote) WithFormatFn ¶
func (f *Remote) WithFormatFn(formatFn func(T) string)
type Simple ¶
type Simple[T any] struct { // contains filtered or unexported fields }
Simple ...
func NewSimpleFrom ¶
func NewSimpleFrom[T any](value TypedValue[T]) *Simple[T]
NewSimpleFrom returns a new Simple using the given value as formula.
func NewSimpleWithFormula ¶
func NewSimpleWithFormula[T any](value T, formulaFn func() *SyntaxNode) *Simple[T]
NewSimpleWithFormula returns a new Simple with the given value and formula.
func (*Simple) AddCondition ¶
func (c *Simple) AddCondition(condition *Condition)
AddCondition attaches the given Condition to this Simple.
func (*Simple[T]) ExtractValues ¶
func (s *Simple[T]) ExtractValues(cache IValueCache) IValueCache
ExtractValues extracts this Simple and all Value that were used to calculate it.
func (*Simple) GetCondition ¶
func (c *Simple) GetCondition() *Condition
GetCondition returns the Condition attached to this Simple.
func (*Simple) GetFormatFn ¶
func (f *Simple) GetFormatFn() func(T) string
func (*Simple[T]) GetFormulaFn ¶
func (s *Simple[T]) GetFormulaFn() func() *SyntaxNode
GetFormulaFn returns the function to build a formula of this Simple.
func (*Simple) GetTags ¶
func (t *Simple) GetTags() Tags
GetTags returns the current tags of this tagger.
func (*Simple[T]) GetTypedValue ¶
func (s *Simple[T]) GetTypedValue() T
GetTypedValue returns the typed value this Simple contains.
func (*Simple[T]) HasFormula ¶
HasFormula returns whether this Simple has a formula.
func (*Simple) IsConditional ¶
func (c *Simple) IsConditional() bool
IsConditional returns whether a Condition is attached to this iStaticConditioner.
func (*Simple[T]) MarshalJSON ¶
MarshalJSON returns the JSON encoding of this Simple.
func (*Simple) Tag ¶
func (t *Simple) Tag(tags ...Tag)
Tag append the given Tag to the existing tags of this tagger.
func (*Simple[T]) ToSyntaxOperand ¶
func (s *Simple[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
ToSyntaxOperand returns the SyntaxOperand representation of this Simple.
func (*Simple) WithFormatFn ¶
func (f *Simple) WithFormatFn(formatFn func(T) string)
type Source ¶
type Source string
Source represents where a Value comes from.
type Stage ¶
type Stage[T any] struct { // contains filtered or unexported fields }
Stage ...
func (*Stage[T]) ExtractValues ¶
func (s *Stage[T]) ExtractValues(cache IValueCache) IValueCache
ExtractValues extracts this Stage and all Value that were used to calculate it.
func (*Stage[T]) GetTypedValue ¶
func (s *Stage[T]) GetTypedValue() T
GetTypedValue returns the typed value this Stage contains.
func (*Stage[T]) HasIdentity ¶
HasIdentity returns whether the underlying Progressive was given an identity.
func (*Stage[T]) Identify ¶
Identify returns the identity that was given to the underlying Progressive.
func (*Stage[T]) SetAlias ¶
SetAlias updates the alias of the underlying Progressive to the provided string.
func (*Stage[T]) ToSyntaxOperand ¶
func (s *Stage[T]) ToSyntaxOperand(nextOp Op) *SyntaxOperand
ToSyntaxOperand returns the SyntaxOperand representation of this Stage.
type StaticConditionalValue ¶
type StaticConditionalValue interface { // IsConditional returns whether a Condition is attached to this StaticConditionalValue. IsConditional() bool // GetCondition returns the Condition attached to this StaticConditionalValue. GetCondition() *Condition // AddCondition attaches the given Condition to this StaticConditionalValue. AddCondition(*Condition) }
StaticConditionalValue needs to be implemented by static Value that holds a Condition.
type SyntaxNode ¶
type SyntaxNode struct {
// contains filtered or unexported fields
}
SyntaxNode is the representation of an operation performed on Value.
func NewFormulaForFunctionCall ¶
func NewFormulaForFunctionCall(fnName string, arguments ...any) *SyntaxNode
NewFormulaForFunctionCall returns a new SyntaxNode representing a function call taking in the provided arguments. Clients must make sure to call PreProcessOperand on all args of Value type before sending them into this method.
func NewFormulaForTwoValMiddleOp ¶
func NewFormulaForTwoValMiddleOp(v1 Value, v2 Value, op Op, opDesc string) *SyntaxNode
NewFormulaForTwoValMiddleOp returns a new SyntaxNode representing a binary operation that has an operator lied in the middle of two operands. Clients must make sure that to call PreProcessOperand on both v1 and v2 before sending them into this method.
func NewSyntaxNode ¶
func NewSyntaxNode(category OpCategory, op Op, opDesc string, operands []any) *SyntaxNode
NewSyntaxNode returns a new SyntaxNode with the provided fields.
func (*SyntaxNode) GetCategory ¶
func (n *SyntaxNode) GetCategory() OpCategory
GetCategory returns the category of this SyntaxNode.
func (*SyntaxNode) GetOp ¶
func (n *SyntaxNode) GetOp() Op
GetOp returns the operation performed of this SyntaxNode.
func (*SyntaxNode) GetOpDesc ¶
func (n *SyntaxNode) GetOpDesc() string
GetOpDesc returns the operation description of this SyntaxNode.
func (*SyntaxNode) GetOperands ¶
func (n *SyntaxNode) GetOperands() []any
GetOperands returns the operands of this SyntaxNode.
func (*SyntaxNode) MarshalJSON ¶
func (n *SyntaxNode) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of this SyntaxNode.
type SyntaxOperand ¶
type SyntaxOperand struct { Name string `json:",omitempty"` StageIdx int `json:",omitempty"` StaticValue string `json:",omitempty"` Node *SyntaxNode `json:",omitempty"` WrapInParentheses bool `json:",omitempty"` }
SyntaxOperand represents how an operand of a SyntaxNode should be encoded in JSON format.
func NewSyntaxOperand ¶
func NewSyntaxOperand(v Value) *SyntaxOperand
NewSyntaxOperand returns a new SyntaxOperand for those Value that come without stageIdx.
func NewSyntaxOperandWithFormula ¶
func NewSyntaxOperandWithFormula(formula *SyntaxNode, wrapInParentheses bool) *SyntaxOperand
NewSyntaxOperandWithFormula returns a new SyntaxOperand for those Value that are not anchored but have a formula.
func NewSyntaxOperandWithStageIdx ¶
func NewSyntaxOperandWithStageIdx(v Value, stageIdx int) *SyntaxOperand
NewSyntaxOperandWithStageIdx returns a new SyntaxOperand for those Value that come with stageIdx.
func NewSyntaxOperandWithStaticValue ¶
func NewSyntaxOperandWithStaticValue(value string) *SyntaxOperand
NewSyntaxOperandWithStaticValue returns a new SyntaxOperand for static values.
type Tag ¶
Tag is a simple pair of name and value that can be attached to a Value to provide extra information.
type Tags ¶
type Tags []Tag
Tags is the collection of tags that was applied on a Value.
func (Tags) MarshalJSON ¶
MarshalJSON returns the JSON encoding of this Tags.
type TypedValue ¶
type TypedValue[T any] interface { Value // GetTypedValue returns the typed value this TypedValue contains. GetTypedValue() T }
TypedValue is a Value bounded by a particular type.
func PreProcessOperand ¶
func PreProcessOperand[T any](tv TypedValue[T]) TypedValue[T]
PreProcessOperand returns a replacement for the input value if it's nil.
type Value ¶
type Value interface { // IsNil returns whether this Value is nil. IsNil() bool // GetValue returns the untyped value this Value contains. GetValue() any // Stringify returns the value this Value contains as a string. Stringify() string // contains filtered or unexported methods }
Value is a wrapper that gives an identity to any variables that are used in our code.
Source Files ¶
- cache.go
- conditional.go
- conditional_ops.go
- constant.go
- formula.go
- helpers.go
- local.go
- marshal.go
- marshal_ops.go
- mock_i_cond_ops.go
- mock_i_marshal_ops.go
- mock_i_tagger.go
- mock_i_value_cache.go
- mock_i_value_ops.go
- mock_progressive_conditional_value.go
- mock_sourcer.go
- mock_static_conditional_value.go
- mock_typed_value.go
- mock_value.go
- mock_value_with_all_features.go
- mock_value_with_formula.go
- op.go
- progressive.go
- progressive_stage.go
- remote.go
- simple.go
- source.go
- tags.go
- test.go
- value.go
- value_ops.go