model

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: Apache-2.0, Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrMapLen added in v1.6.0

func ArrMapLen(arr reflect.Value, arg []reflect.Value) (reflect.Value, error)

ArrMapLen will return the size of underlying map, array or slice

func SetNumberValue added in v1.6.0

func SetNumberValue(target, newvalue reflect.Value) error

SetNumberValue will assign a numeric value to a numeric target value this helper function is to ensure assignment between numerical types is happening regardless of types, int, uint or float. The rule designer should be careful as conversion of types in automatic way like this will cause lost of precision during conversion. This will be removed in the future version.

func StrCompare added in v1.6.0

func StrCompare(str string, arg []reflect.Value) (reflect.Value, error)

StrCompare is like strings.compare() function, to be called by the ValueNode function call if the underlying data is string.

func StrContains added in v1.6.0

func StrContains(str string, arg []reflect.Value) (reflect.Value, error)

StrContains is like strings.Contains() function, to be called by the ValueNode function call if the underlying data is string. is like strings.compare() function, to be called by the ValueNode functioncall if the underlying data is string.

func StrCount added in v1.6.0

func StrCount(str string, arg []reflect.Value) (reflect.Value, error)

StrCount is like strings.Count() function, to be called by the ValueNode function call if the underlying data is string.

func StrHasPrefix added in v1.6.0

func StrHasPrefix(str string, arg []reflect.Value) (reflect.Value, error)

StrHasPrefix is like strings.HasPrefix() function, to be called by the ValueNode functioncall if the underlying data is string.

func StrHasSuffix added in v1.6.0

func StrHasSuffix(str string, arg []reflect.Value) (reflect.Value, error)

StrHasSuffix is like strings.HasSuffix() function, to be called by the ValueNode functioncall if the underlying data is string.

func StrIndex added in v1.6.0

func StrIndex(str string, arg []reflect.Value) (reflect.Value, error)

StrIndex is like strings.Index() function, to be called by the ValueNode functioncall if the underlying data is string.

func StrLastIndex added in v1.6.0

func StrLastIndex(str string, arg []reflect.Value) (reflect.Value, error)

StrLastIndex is like strings.LastIndex() function, to be called by the ValueNode functioncall if the underlying data is string.

func StrLen added in v1.6.1

func StrLen(str string, arg []reflect.Value) (reflect.Value, error)

StrLen is return the string length value

func StrRepeat added in v1.6.0

func StrRepeat(str string, arg []reflect.Value) (reflect.Value, error)

StrRepeat is like strings.Repeat() function, to be called by the ValueNode functioncall if the underlying data is string.

func StrReplace added in v1.6.0

func StrReplace(str string, arg []reflect.Value) (reflect.Value, error)

StrReplace is like strings.Replace() function, to be called by the ValueNode functioncall if the underlying data is string.

func StrSplit added in v1.6.0

func StrSplit(str string, arg []reflect.Value) (reflect.Value, error)

StrSplit is like strings.Split() function, to be called by the ValueNode functioncall if the underlying data is string.

func StrToLower added in v1.6.0

func StrToLower(str string, arg []reflect.Value) (reflect.Value, error)

StrToLower is like strings.ToLower() function, to be called by the ValueNode functioncall if the underlying data is string.

func StrToUpper added in v1.6.0

func StrToUpper(str string, arg []reflect.Value) (reflect.Value, error)

StrToUpper is like strings.ToUpper() function, to be called by the ValueNode functioncall if the underlying data is string.

func StrTrim added in v1.6.0

func StrTrim(str string, arg []reflect.Value) (reflect.Value, error)

StrTrim is like strings.Trim() function, to be called by the ValueNode functioncall if the underlying data is string.

Types

type GoValueNode added in v1.6.0

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

GoValueNode is an implementation of ValueNode that used to traverse native golang primitives through reflect package

func (*GoValueNode) AppendValue added in v1.6.0

func (node *GoValueNode) AppendValue(value []reflect.Value) (err error)

AppendValue will append the new values into the current underlying array. will return error if argument list are not compatible with the array element type.

func (*GoValueNode) CallFunction added in v1.6.0

func (node *GoValueNode) CallFunction(funcName string, args ...reflect.Value) (retval reflect.Value, err error)

CallFunction will call a function owned by the underlying value receiver. this function will artificially create a built-in functions for constants, array and map.

func (*GoValueNode) ContinueWithValue added in v1.6.0

func (node *GoValueNode) ContinueWithValue(value reflect.Value, identifiedAs string) ValueNode

ContinueWithValue will return a nother ValueNode to wrap the specified value and treated as child of current node. The main purpose of this is for easier debugging.

func (*GoValueNode) GetArrayType added in v1.6.0

func (node *GoValueNode) GetArrayType() (reflect.Type, error)

GetArrayType to get the type of underlying value array element types.

func (*GoValueNode) GetArrayValueAt added in v1.6.0

func (node *GoValueNode) GetArrayValueAt(index int) (reflect.Value, error)

GetArrayValueAt to get the value of an array element if the current underlying value is an array

func (*GoValueNode) GetChildNodeByField added in v1.6.0

func (node *GoValueNode) GetChildNodeByField(field string) (ValueNode, error)

GetChildNodeByField will retrieve the underlying struct's field and return the ValueNode wraper.

func (*GoValueNode) GetChildNodeByIndex added in v1.6.0

func (node *GoValueNode) GetChildNodeByIndex(index int) (ValueNode, error)

GetChildNodeByIndex is similar to `GetArrayValueAt`, where this will return a ValueNode that wrap the value.

func (*GoValueNode) GetChildNodeBySelector added in v1.6.0

func (node *GoValueNode) GetChildNodeBySelector(index reflect.Value) (ValueNode, error)

GetChildNodeBySelector is similar to GetMapValueAt, it retrieve a value of map element identified by a value index as ValueNode.

func (*GoValueNode) GetMapValueAt added in v1.6.0

func (node *GoValueNode) GetMapValueAt(index reflect.Value) (reflect.Value, error)

GetMapValueAt will retrieve a map value by the specified key argument.

func (*GoValueNode) GetObjectTypeByField added in v1.6.0

func (node *GoValueNode) GetObjectTypeByField(field string) (typ reflect.Type, err error)

GetObjectTypeByField will return underlying type of the value's field

func (*GoValueNode) GetObjectValueByField added in v1.6.0

func (node *GoValueNode) GetObjectValueByField(field string) (reflect.Value, error)

GetObjectValueByField will return underlying value's field

func (*GoValueNode) GetType added in v1.6.0

func (node *GoValueNode) GetType() (reflect.Type, error)

GetType will return the underlying value's type

func (*GoValueNode) GetValue added in v1.6.0

func (node *GoValueNode) GetValue() (reflect.Value, error)

GetValue will return the underlying reflect.Value

func (*GoValueNode) HasParent added in v1.6.0

func (node *GoValueNode) HasParent() bool

HasParent returns `true` if the current value is a field, function, map, array, slice of another value

func (*GoValueNode) IdentifiedAs added in v1.6.0

func (node *GoValueNode) IdentifiedAs() string

IdentifiedAs return the current representation of this Value Node

func (*GoValueNode) IsArray added in v1.6.0

func (node *GoValueNode) IsArray() bool

IsArray to check if the underlying value is an array or not

func (*GoValueNode) IsBool added in v1.6.0

func (node *GoValueNode) IsBool() bool

IsBool will check if the underlying value is a type of boolean.

func (*GoValueNode) IsInteger added in v1.6.0

func (node *GoValueNode) IsInteger() bool

IsInteger will check if the underlying value is a type of int, or uint

func (*GoValueNode) IsMap added in v1.6.0

func (node *GoValueNode) IsMap() bool

IsMap will validate if the underlying value is a map.

func (*GoValueNode) IsObject added in v1.6.0

func (node *GoValueNode) IsObject() bool

IsObject will check if the underlying value is a struct or pointer to a struct

func (*GoValueNode) IsReal added in v1.6.0

func (node *GoValueNode) IsReal() bool

IsReal will check if the underlying value is a type of real number, float.

func (*GoValueNode) IsString added in v1.6.0

func (node *GoValueNode) IsString() bool

IsString will check if the underlying value is a type of string

func (*GoValueNode) IsTime added in v1.6.0

func (node *GoValueNode) IsTime() bool

IsTime will check if the underlying value is a time.Time

func (*GoValueNode) Length added in v1.6.0

func (node *GoValueNode) Length() (int, error)

Length will return the length of underlying value if its an array, slice, map or string

func (*GoValueNode) Parent added in v1.6.0

func (node *GoValueNode) Parent() ValueNode

Parent returns the value node of the parent value, if this node is a field, function, map, array, slice of another value

func (*GoValueNode) SetArrayValueAt added in v1.6.0

func (node *GoValueNode) SetArrayValueAt(index int, value reflect.Value) (err error)

SetArrayValueAt will set the value of specified array index on the current underlying array value.

func (*GoValueNode) SetMapValueAt added in v1.6.0

func (node *GoValueNode) SetMapValueAt(index, newValue reflect.Value) (err error)

SetMapValueAt will set the map value for the specified key, value argument

func (*GoValueNode) SetObjectValueByField added in v1.6.0

func (node *GoValueNode) SetObjectValueByField(field string, newValue reflect.Value) (err error)

SetObjectValueByField will set the underlying value's field with new value.

func (*GoValueNode) Value added in v1.6.0

func (node *GoValueNode) Value() reflect.Value

Value returns the underlying reflect.Value

type ValueNode added in v1.6.0

type ValueNode interface {
	IdentifiedAs() string
	Value() reflect.Value
	HasParent() bool
	Parent() ValueNode

	ContinueWithValue(value reflect.Value, identifiedAs string) ValueNode
	GetValue() (reflect.Value, error)
	GetType() (reflect.Type, error)

	IsArray() bool
	GetArrayType() (reflect.Type, error)
	GetArrayValueAt(index int) (reflect.Value, error)
	GetChildNodeByIndex(index int) (ValueNode, error)
	SetArrayValueAt(index int, value reflect.Value) error
	AppendValue(value []reflect.Value) error
	Length() (int, error)

	IsMap() bool
	GetMapValueAt(index reflect.Value) (reflect.Value, error)
	SetMapValueAt(index, newValue reflect.Value) error
	GetChildNodeBySelector(index reflect.Value) (ValueNode, error)

	IsObject() bool
	GetObjectValueByField(field string) (reflect.Value, error)
	GetObjectTypeByField(field string) (reflect.Type, error)
	SetObjectValueByField(field string, newValue reflect.Value) error
	CallFunction(funcName string, args ...reflect.Value) (reflect.Value, error)
	GetChildNodeByField(field string) (ValueNode, error)

	IsTime() bool
	IsInteger() bool
	IsReal() bool
	IsBool() bool
	IsString() bool
}

ValueNode is an abstraction layer to access underlying dom style data. the node have tree kind of structure which each node are tied to an underlying data node.

func NewGoValueNode added in v1.6.0

func NewGoValueNode(value reflect.Value, identifiedAs string) ValueNode

NewGoValueNode creates new instance of ValueNode backed by golang reflection

Jump to

Keyboard shortcuts

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