data

package
v1.0.6-10 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 9 Imported by: 92

Documentation

Index

Constants

View Source
const DefaultSkip int64 = 0
View Source
const DefaultTake int64 = 50
View Source
const EmptyTokenValue string = ""
View Source
const EmptyTotalValue int = -1

Variables

View Source
var IdGenerator = &_TIdGenerator{}

IdGenerator Helper class to generate unique object IDs. It supports two types of IDs: long and short.

Long IDs are string GUIDs. They are globally unique and 32-character long.
ShortIDs are just 9-digit random numbers. They are not guaranteed be unique.
Example:
	IdGenerator.NextLong();      // Possible result: "234ab342c56a2b49c2ab42bf23ff991ac"
	IdGenerator.NextShort();     // Possible result: "23495247"
View Source
var TagsProcessor = &_TTagsProcessor{}

TagsProcessor Helper class to extract and process search tags from objects. The search tags can be kept individually or embedded as hash tags inside text like "This text has #hash_tag that can be used for search."

Functions

This section is empty.

Types

type AnyValue

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

AnyValue Cross-language implementation of dynamic object what can hold value of any type. The stored value can be converted to different types using variety of accessor methods.

Example:
	value := data.NewAnyValue("123.456")

	value.GetAsInteger() // Result: 123
	value.GetAsString()  // Result: "123.456"
	value.GetAsFloat()   // Result: 123.456

func NewAnyValue

func NewAnyValue(value any) *AnyValue

NewAnyValue creates a new instance of the object and assigns its value.

Parameters: "value" - value to initialize this object.
Returns: new object.

func NewEmptyAnyValue

func NewEmptyAnyValue() *AnyValue

NewEmptyAnyValue creates a new empty instance of the object

Returns: new empty object

func (*AnyValue) Clone

func (c *AnyValue) Clone() *AnyValue

Clone creates a binary clone of this object.

Returns: a clone of this object.

func (*AnyValue) Equals

func (c *AnyValue) Equals(obj any) bool

Equals compares this object value to specified specified value. When direct comparison gives negative results it tries to compare values as strings.

Parameters: "obj" - the value to be compared with.
Returns: true when objects are equal and false otherwise.

func (*AnyValue) EqualsAsType

func (c *AnyValue) EqualsAsType(typ convert.TypeCode, obj any) bool

EqualsAsType compares this object value to specified specified value. When direct comparison gives negative results it converts values to type specified by type code and compare them again.

	Parameters:
 	"typ" - the TypeCode that defined the type of the result.
 	"obj" - the value to be compared with.
	Returns: true when objects are equal and false otherwise.

func (*AnyValue) GetAsArray

func (c *AnyValue) GetAsArray() *AnyValueArray

GetAsArray converts object value into an AnyArray or returns empty AnyArray if conversion is not possible.

Returns: AnyArray value or empty AnyArray if conversion is not supported.

func (*AnyValue) GetAsBoolean

func (c *AnyValue) GetAsBoolean() bool

GetAsBoolean converts object value into a boolean or returns false if conversion is not possible.

Returns: string value or false if conversion is not supported.

func (*AnyValue) GetAsBooleanWithDefault

func (c *AnyValue) GetAsBooleanWithDefault(defaultValue bool) bool

GetAsBooleanWithDefault converts object value into a boolean or returns default value if conversion is not possible.

Parameters: "defaultValue" - the default value.
Returns: boolean value or default if conversion is not supported.

func (*AnyValue) GetAsDateTime

func (c *AnyValue) GetAsDateTime() time.Time

GetAsDateTime converts object value into a Date or returns current date if conversion is not possible.

Returns: DateTime value or current date if conversion is not supported.

func (*AnyValue) GetAsDateTimeWithDefault

func (c *AnyValue) GetAsDateTimeWithDefault(defaultValue time.Time) time.Time

GetAsDateTimeWithDefault converts object value into a Date or returns default value if conversion is not possible.

Parameters: "defaultValue" - the default value
Returns: DateTime value or default if conversion is not supported.

func (*AnyValue) GetAsDouble

func (c *AnyValue) GetAsDouble() float64

GetAsDouble converts object value into a double or returns 0 if conversion is not possible.

Returns: double value or 0 if conversion is not supported.

func (*AnyValue) GetAsDoubleWithDefault

func (c *AnyValue) GetAsDoubleWithDefault(defaultValue float64) float64

GetAsDoubleWithDefault converts object value into a double or returns default value if conversion is not possible.

Parameters: "defaultValue" - the default value
Returns: double value or default if conversion is not supported.

func (*AnyValue) GetAsDuration

func (c *AnyValue) GetAsDuration() time.Duration

GetAsDuration converts object value into a Duration or returns current date if conversion is not possible.

Returns: Duration value or current date if conversion is not supported.

func (*AnyValue) GetAsDurationWithDefault

func (c *AnyValue) GetAsDurationWithDefault(defaultValue time.Duration) time.Duration

GetAsDurationWithDefault converts object value into a Duration or returns default value if conversion is not possible. Parameters: "defaultValue" - the default value Returns: Duration value or default if conversion is not supported.

func (*AnyValue) GetAsFloat

func (c *AnyValue) GetAsFloat() float32

GetAsFloat converts object value into a float or returns 0 if conversion is not possible.

Returns: float value or 0 if conversion is not supported.

func (*AnyValue) GetAsFloatWithDefault

func (c *AnyValue) GetAsFloatWithDefault(defaultValue float32) float32

GetAsFloatWithDefault converts object value into a float or returns default value if conversion is not possible.

Parameters: "defaultValue" - the default value
Returns: float value or default if conversion is not supported.

func (*AnyValue) GetAsInteger

func (c *AnyValue) GetAsInteger() int

GetAsInteger converts object value into an integer or returns 0 if conversion is not possible.

Returns: integer value or 0 if conversion is not supported.

func (*AnyValue) GetAsIntegerWithDefault

func (c *AnyValue) GetAsIntegerWithDefault(defaultValue int) int

GetAsIntegerWithDefault converts object value into a integer or returns default value if conversion is not possible.

Parameters: "defaultValue" - the default value
Returns: integer value or default if conversion is not supported.

func (*AnyValue) GetAsLong

func (c *AnyValue) GetAsLong() int64

GetAsLong converts object value into a long or returns 0 if conversion is not possible.

Returns: string value or 0 if conversion is not supported.

func (*AnyValue) GetAsLongWithDefault

func (c *AnyValue) GetAsLongWithDefault(defaultValue int64) int64

GetAsLongWithDefault converts object value into a long or returns default value if conversion is not possible.

Parameters: "defaultValue" - the default value
Returns: long value or default if conversion is not supported.

func (*AnyValue) GetAsMap

func (c *AnyValue) GetAsMap() *AnyValueMap

GetAsMap converts object value into AnyMap or returns empty AnyMap if conversion is not possible.

Returns: AnyMap value or empty AnyMap if conversion is not supported.

func (*AnyValue) GetAsNullableBoolean

func (c *AnyValue) GetAsNullableBoolean() (bool, bool)

GetAsNullableBoolean converts object value into a boolean or returns null if conversion is not possible.

Returns: boolean value and true or false and false if conversion is not supported.

func (*AnyValue) GetAsNullableDateTime

func (c *AnyValue) GetAsNullableDateTime() (time.Time, bool)

GetAsNullableDateTime converts object value into a Date or returns null if conversion is not possible.

Returns: DateTime value and true or zero time and false if conversion is not supported.

func (*AnyValue) GetAsNullableDouble

func (c *AnyValue) GetAsNullableDouble() (float64, bool)

GetAsNullableDouble converts object value into a double or returns null if conversion is not possible.

Returns: double value and true or 0.0 and false if conversion is not supported.

func (*AnyValue) GetAsNullableDuration

func (c *AnyValue) GetAsNullableDuration() (time.Duration, bool)

GetAsNullableDuration converts object value into a Duration or returns null if conversion is not possible.

Returns: Duration value and true or 0 and false if conversion is not supported.

func (*AnyValue) GetAsNullableFloat

func (c *AnyValue) GetAsNullableFloat() (float32, bool)

GetAsNullableFloat converts object value into a float or returns null if conversion is not possible.

Returns: float value and true or 0.0 and false if conversion is not supported.

func (*AnyValue) GetAsNullableInteger

func (c *AnyValue) GetAsNullableInteger() (int, bool)

GetAsNullableInteger converts object value into an integer or returns null if conversion is not possible.

Returns: integer value and true or 0 and false if conversion is not supported.

func (*AnyValue) GetAsNullableLong

func (c *AnyValue) GetAsNullableLong() (int64, bool)

GetAsNullableLong converts object value into a long or returns null if conversion is not possible.

Returns: long value and true or 0 and false if conversion is not supported.

func (*AnyValue) GetAsNullableString

func (c *AnyValue) GetAsNullableString() (string, bool)

GetAsNullableString converts object value into a string or returns null if conversion is not possible.

Returns: string and true value or "" and false if conversion is not supported.

func (*AnyValue) GetAsNullableType

func (c *AnyValue) GetAsNullableType(typ convert.TypeCode) (any, bool)

GetAsNullableType converts object value into a value defined by specied typecode. If conversion is not possible it returns null.

Parameters: "typ" - the TypeCode that defined the type of the result.
Returns: value defined by the typecode and true or null and false if conversion is not supported.

func (*AnyValue) GetAsNullableUInteger added in v1.0.4

func (c *AnyValue) GetAsNullableUInteger() (uint, bool)

GetAsNullableUInteger converts object value into an unsigned integer or returns default value if conversion is not possible.

Parameters: "defaultValue" - the default value
Returns: integer value or default if conversion is not supported.

func (*AnyValue) GetAsNullableULong added in v1.0.4

func (c *AnyValue) GetAsNullableULong() (uint64, bool)

GetAsNullableULong converts object value into an unsigned long or returns default value if conversion is not possible.

Parameters: "defaultValue" - the default value
Returns: long value or default if conversion is not supported.

func (*AnyValue) GetAsObject

func (c *AnyValue) GetAsObject() any

GetAsObject gets the value stored in this object without any conversions.

Returns: the object value.

func (*AnyValue) GetAsString

func (c *AnyValue) GetAsString() string

GetAsString converts object value into a string or returns "" if conversion is not possible. Returns: string value or "" if conversion is not supported.

func (*AnyValue) GetAsStringWithDefault

func (c *AnyValue) GetAsStringWithDefault(defaultValue string) string

GetAsStringWithDefault converts object value into a string or returns default value if conversion is not possible.

Parameters: "defaultValue" - the default value.
Returns: string value or default if conversion is not supported.

func (*AnyValue) GetAsType

func (c *AnyValue) GetAsType(typ convert.TypeCode) any

GetAsType converts object value into a value defined by specied typecode. If conversion is not possible it returns default value for the specified type.

Parameters: "typ" - the TypeCode that defined the type of the result.
Returns: value defined by the typecode or type default value if conversion is not supported.

func (*AnyValue) GetAsTypeWithDefault

func (c *AnyValue) GetAsTypeWithDefault(typ convert.TypeCode, defaultValue any) any

GetAsTypeWithDefault converts object value into a value defined by specied typecode. If conversion is not possible it returns default value.

	Parameters:
 	"typ" - the TypeCode that defined the type of the result;
 	"defaultValue" - the default value.
	Returns: value defined by the typecode or type default value if conversion is not supported.

func (*AnyValue) GetAsUInteger added in v1.0.4

func (c *AnyValue) GetAsUInteger() uint

GetAsUInteger converts object value into an unsigned integer or returns 0 if conversion is not possible.

Returns: unsigned integer value or 0 if conversion is not supported.

func (*AnyValue) GetAsUIntegerWithDefault added in v1.0.4

func (c *AnyValue) GetAsUIntegerWithDefault(defaultValue uint) uint

GetAsUIntegerWithDefault converts object value into a unsigned integer or returns default value if conversion is not possible.

Parameters: "defaultValue" - the default value
Returns: unsigned integer value or default if conversion is not supported.

func (*AnyValue) GetAsULong added in v1.0.4

func (c *AnyValue) GetAsULong() uint64

GetAsULong converts object value into an unsigned long or returns 0 if conversion is not possible.

Returns: unsigned long value or 0 if conversion is not supported.

func (*AnyValue) GetAsULongWithDefault added in v1.0.4

func (c *AnyValue) GetAsULongWithDefault(defaultValue uint64) uint64

GetAsULongWithDefault converts object value into a unsiged long or returns default value if conversion is not possible.

Parameters: "defaultValue" - the default value
Returns: unsigned long value or default if conversion is not supported.

func (*AnyValue) InnerValue

func (c *AnyValue) InnerValue() any

InnerValue gets the value stored in this object without any conversions.

Returns: the object value.

func (*AnyValue) SetAsObject

func (c *AnyValue) SetAsObject(value any)

SetAsObject sets a new value for this object.

Parameters: "value" - the new object value.

func (*AnyValue) String

func (c *AnyValue) String() string

String gets a string representation of the object.

Returns: a string representation of the object.

func (*AnyValue) TypeCode

func (c *AnyValue) TypeCode() convert.TypeCode

TypeCode gets type code for the value stored in this object.

Returns: type code of the object value.

func (*AnyValue) Value

func (c *AnyValue) Value() any

Value gets the value stored in this object without any conversions.

Returns: the object value.

type AnyValueArray

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

AnyValueArray Cross-language implementation of dynamic object array what can hold values of any type. The stored values can be converted to different types using variety of accessor methods.

Example:
	value1 := NewAnyValueArray([1, "123.456", "2018-01-01"]);
	value1.GetAsBoolean(0);   // Result: true
	value1.GetAsInteger(1);   // Result: 123
	value1.GetAsFloat(1);     // Result: 123.456
	value1.GetAsDateTime(2);  // Result: new Date(2018,0,1)

see convert.StringConverter
see convert.TypeConverter
see convert.BooleanConverter
see convert.IntegerConverter
see convert.LongConverter
see convert.DoubleConverter
see convert.FloatConverter
see convert.DateTimeConverter
see ICloneable

func NewAnyValueArray

func NewAnyValueArray(values []any) *AnyValueArray

NewAnyValueArray creates a new instance of the array and assigns its value.

Parameters:
	values []any
Returns: *AnyValueArray

func NewAnyValueArrayFromString

func NewAnyValueArrayFromString(values string, separator string, removeDuplicates bool) *AnyValueArray

NewAnyValueArrayFromString splits specified string into elements using a separator and assigns the elements to a newly created AnyValueArray.

Parameters:
	- values string a string value to be split and assigned to AnyValueArray
	separator string a separator to split the string
	- removeDuplicates bool	true to remove duplicated elements
Returns *AnyValueArray a newly created AnyValueArray.

func NewAnyValueArrayFromValue

func NewAnyValueArrayFromValue(value any) *AnyValueArray

NewAnyValueArrayFromValue converts specified value into AnyValueArray.

see convertor.ArrayConverter.ToArray
Parameters: value any value to be converted
Returns: *AnyValueArray a newly created AnyValueArray.

func NewAnyValueArrayFromValues

func NewAnyValueArrayFromValues(values ...any) *AnyValueArray

NewAnyValueArrayFromValues creates a new AnyValueArray from a list of values

Parameters: values ...values any a list of values to initialize the created AnyValueArray
Returns: *AnyValueArray a newly created AnyValueArray.

func NewEmptyAnyValueArray

func NewEmptyAnyValueArray() *AnyValueArray

NewEmptyAnyValueArray creates a new instance of the empty array.

Returns *AnyValueArray

func (*AnyValueArray) Append

func (c *AnyValueArray) Append(elements []any)

Append new elements to this array.

Parameters:
	elements []any a list of elements to be added.

func (*AnyValueArray) Clear

func (c *AnyValueArray) Clear()

Clear this array by removing all its elements.

func (*AnyValueArray) Clone

func (c *AnyValueArray) Clone() *AnyValueArray

Clone creates a binary clone of this object.

Returns: any a clone of this object.

func (*AnyValueArray) Contains

func (c *AnyValueArray) Contains(value any) bool

Contains checks if this array contains a value. The check uses direct comparison between elements and the specified value.

Parameters: value any a value to be checked
Returns: bool true if this array contains the value or false otherwise.

func (*AnyValueArray) ContainsAsType

func (c *AnyValueArray) ContainsAsType(typ convert.TypeCode, value any) bool

ContainsAsType checks if this array contains a value.

The check before comparison converts elements and the value to type specified by type code.
see convert.TypeConverter.ToType
see convert.TypeConverter.ToNullableType
Parameters:
	- typeCode TypeCode a type code that defines a type to convert values before comparison
	- value any a value to be checked
Returns: bool true if this array contains the value or false otherwise.

func (*AnyValueArray) Get

func (c *AnyValueArray) Get(index int) (any, bool)

Get an array element specified by its index.

Parameters:
	index int an index of the element to get.
Returns: value and true or nil and false if index is not valid

func (*AnyValueArray) GetAsArray

func (c *AnyValueArray) GetAsArray(index int) *AnyValueArray

GetAsArray converts array element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible.

see NewAnyValueArrayFromValue
Parameters: index int an index of element to get.
Returns *AnyValueArray value of the element and true or empty AnyValueArray and false if conversion is not supported or index is ivalid.

func (*AnyValueArray) GetAsArrayWithDefault

func (c *AnyValueArray) GetAsArrayWithDefault(index int, defaultValue *AnyValueArray) *AnyValueArray

GetAsArrayWithDefault converts array element into an AnyValueArray or returns default value if conversion is not possible.

see GetAsNullableArray
Parameters:
	- index int an index of element to get.
	- defaultValue *AnyValueArray the default value
Returns: *AnyValueArray value of the element or default value if conversion is not supported.

func (*AnyValueArray) GetAsBoolean

func (c *AnyValueArray) GetAsBoolean(index int) bool

GetAsBoolean converts array element into a boolean or returns false if conversion is not possible.

see GetAsBooleanWithDefault
Parameters:
	index int an index of element to get.
Returns: boolean value ot the element or false if conversion is not supported.

func (*AnyValueArray) GetAsBooleanWithDefault

func (c *AnyValueArray) GetAsBooleanWithDefault(index int, defaultValue bool) bool

GetAsBooleanWithDefault converts array element into a boolean or returns default value if conversion is not possible.

see convert.BooleanConverter.toBooleanWithDefault
Parameters:
	index int an index of element to get.
	defaultValue: boolean the default value
Returns: boolean value ot the element or default value if conversion is not supported.

func (*AnyValueArray) GetAsDateTime

func (c *AnyValueArray) GetAsDateTime(index int) time.Time

GetAsDateTime converts array element into a time.Time or returns the current date if conversion is not possible.

see GetAsDateTimeWithDefault
Parameters: index int an index of element to get.
Returns: time.Time value ot the element or the current date if conversion is not supported.

func (*AnyValueArray) GetAsDateTimeWithDefault

func (c *AnyValueArray) GetAsDateTimeWithDefault(index int, defaultValue time.Time) time.Time

GetAsDateTimeWithDefault converts array element into a time.Time or returns default value if conversion is not possible.

see covert.DateTimeConverter.toDateTimeWithDefault
Parameters:
	- index int an index of element to get.
	- defaultValue: time.Time the default value.
Returns: time.time value ot the element or default value if conversion is not supported.

func (*AnyValueArray) GetAsDouble

func (c *AnyValueArray) GetAsDouble(index int) float64

GetAsDouble converts array element into a double or returns 0 if conversion is not possible.

see GetAsDoubleWithDefault
Parameters: index int an index of element to get.
Returns: double value ot the element or 0 if conversion is not supported.

func (*AnyValueArray) GetAsDoubleWithDefault

func (c *AnyValueArray) GetAsDoubleWithDefault(index int, defaultValue float64) float64

GetAsDoubleWithDefault converts array element into a double or returns default value if conversion is not possible.

see convert.DoubleConverter.ToDoubleWithDefault
Parameters:
	- index int an index of element to get.
	- defaultValue: float64 the default value.
Returns: double value ot the element or default value if conversion is not supported.

func (*AnyValueArray) GetAsDuration

func (c *AnyValueArray) GetAsDuration(index int) time.Duration

GetAsDuration converts array element into a time.Duration or returns the current date if conversion is not possible.

see GetAsDurationWithDefault
Parameters: index int an index of element to get.
Returns: time.Duration value ot the element or the current date if conversion is not supported.

func (*AnyValueArray) GetAsDurationWithDefault

func (c *AnyValueArray) GetAsDurationWithDefault(index int, defaultValue time.Duration) time.Duration

GetAsDurationWithDefault converts array element into a time.Duration or returns default value if conversion is not possible.

see convert.DateTimeConverter.toDateTimeWithDefault
Parameters:
	- index int an index of element to get.
	- defaultValue: time.Duration the default value
Returns: time.Duration value ot the element or default value if conversion is not supported.

func (*AnyValueArray) GetAsFloat

func (c *AnyValueArray) GetAsFloat(index int) float32

GetAsFloat converts array element into a float or returns 0 if conversion is not possible.

see GetAsFloatWithDefault
Parameters: index int an index of element to get.
Returns: float value ot the element or 0 if conversion is not supported.

func (*AnyValueArray) GetAsFloatWithDefault

func (c *AnyValueArray) GetAsFloatWithDefault(index int, defaultValue float32) float32

GetAsFloatWithDefault converts array element into a float or returns default value if conversion is not possible.

see convert.FloatConverter.toFloatWithDefault
Parameters:
	- index int an index of element to get.
	- defaultValue: number the default value
Returns: number float value ot the element or default value if conversion is not supported.

func (*AnyValueArray) GetAsInteger

func (c *AnyValueArray) GetAsInteger(index int) int

GetAsInteger converts array element into an integer or returns 0 if conversion is not possible.

see GetAsIntegerWithDefault
Parameters:
	index int an index of element to get.
Returns: integer value ot the element or 0 if conversion is not supported.

func (*AnyValueArray) GetAsIntegerWithDefault

func (c *AnyValueArray) GetAsIntegerWithDefault(index int, defaultValue int) int

GetAsIntegerWithDefault converts array element into an integer or returns default value if conversion is not possible.

see convert.IntegerConverter.toIntegerWithDefault
Parameters:
	index int an index of element to get.
	defaultValue int the default value
Returns: integer value ot the element or default value if conversion is not supported.

func (*AnyValueArray) GetAsLong

func (c *AnyValueArray) GetAsLong(index int) int64

GetAsLong converts array element into a long or returns 0 if conversion is not possible.

see GetAsLongWithDefault
Parameters: index int an index of element to get.
Returns: int64 value ot the element or 0 if conversion is not supported.

func (*AnyValueArray) GetAsLongWithDefault

func (c *AnyValueArray) GetAsLongWithDefault(index int, defaultValue int64) int64

GetAsLongWithDefault converts array element into a long or returns default value if conversion is not possible.

see convert.LongConverter.ToLongWithDefault
Parameters:
	- index int an index of element to get.
	- defaultValue int64 the default value.
Returns: int64 value ot the element or default value if conversion is not supported.

func (*AnyValueArray) GetAsMap

func (c *AnyValueArray) GetAsMap(index int) *AnyValueMap

GetAsMap converts array element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.

see AnyValueMap
see NewAnyValueMapFromValue
Parameters: index int an index of element to get.
Returns: *AnyValueMap

func (*AnyValueArray) GetAsMapWithDefault

func (c *AnyValueArray) GetAsMapWithDefault(index int, defaultValue *AnyValueMap) *AnyValueMap

GetAsMapWithDefault converts array element into an AnyValueMap or returns default value if conversion is not possible.

see GetAsNullableMap
Parameters
	- index int an index of element to get.
	- defaultValue *AnyValueMap the default value
Returns *AnyValueMap value of the element or default value if conversion is not supported.

func (*AnyValueArray) GetAsNullableArray

func (c *AnyValueArray) GetAsNullableArray(index int) (*AnyValueArray, bool)

GetAsNullableArray converts array element into an AnyValueArray or returns nil if conversion is not possible.

see NewAnyValueArrayFromValue
Parameters: index int an index of element to get.
Returns: *AnyValueArray value of the element and true or nil and false if conversion is not supported or index is invalid.

func (*AnyValueArray) GetAsNullableBoolean

func (c *AnyValueArray) GetAsNullableBoolean(index int) (bool, bool)

GetAsNullableBoolean converts array element into a boolean or returns nil if conversion is not possible. see convert.BooleanConverter.toNullableBoolean

Parameters:
	index int an index of element to get.
Returns: boolean value of the element and true or false and false if conversion is not supported or index is invalid.

func (*AnyValueArray) GetAsNullableDateTime

func (c *AnyValueArray) GetAsNullableDateTime(index int) (time.Time, bool)

GetAsNullableDateTime converts array element into a time.Time or returns nil if conversion is not possible.

see convert.DateTimeConverter.ToNullableDateTime
Parameters: index int an index of element to get.
Returns: time.Time value of the element and true or zero time and false if conversion is not supported or index is invalid.

func (*AnyValueArray) GetAsNullableDouble

func (c *AnyValueArray) GetAsNullableDouble(index int) (float64, bool)

GetAsNullableDouble converts array element into a double or returns nil if conversion is not possible.

see convert.DoubleConverter.toNullableDouble
Parameters: index int an index of element to get.
Returns: float64 value of the element and true or 0 and false if conversion is not supported or index is invalid.

func (*AnyValueArray) GetAsNullableDuration

func (c *AnyValueArray) GetAsNullableDuration(index int) (time.Duration, bool)

GetAsNullableDuration converts array element into a time.Duration or returns nil if conversion is not possible.

see convert.DateTimeConverter.toNullableDateTime
Parameters: index int an index of element to get.
Returns: time.Duration value of the element and true or 0 and false if conversion is not supported or index is ivalid.

func (*AnyValueArray) GetAsNullableFloat

func (c *AnyValueArray) GetAsNullableFloat(index int) (float32, bool)

GetAsNullableFloat converts array element into a float or returns nil if conversion is not possible.

see convert.FloatConverter.ToNullableFloat
Parameters: index int an index of element to get.
Returns: float64 value of the element and true or 0 and false if conversion is not supported or index is invalid.

func (*AnyValueArray) GetAsNullableInteger

func (c *AnyValueArray) GetAsNullableInteger(index int) (int, bool)

GetAsNullableInteger converts array element into an integer or returns nil if conversion is not possible.

see convert.IntegerConverter.toNullableInteger
Parameters:
	index int an index of element to get.
Returns: integer value of the element and true or 0 and false if conversion is not supported or index is invalid.

func (*AnyValueArray) GetAsNullableLong

func (c *AnyValueArray) GetAsNullableLong(index int) (int64, bool)

GetAsNullableLong converts array element into a long or returns nil if conversion is not possible.

see convert.LongConverter.ToNullableLong
Parameters:
	index int an index of element to get.
Returns: int64 value of the element and true or 0 and false if conversion is not supported or index is invalid.

func (*AnyValueArray) GetAsNullableMap

func (c *AnyValueArray) GetAsNullableMap(index int) (*AnyValueMap, bool)

GetAsNullableMap converts array element into an AnyValueMap or returns nil if conversion is not possible.

see AnyValueMap
see NewAnyValueMapFromValue
Parameters: index int an index of element to get.
Returns: *AnyValueMap value of the element and true or nil and false if conversion is not supported or index is invalid.

func (*AnyValueArray) GetAsNullableString

func (c *AnyValueArray) GetAsNullableString(index int) (string, bool)

GetAsNullableString converts array element into a string or returns nil if conversion is not possible.

see convert.StringConverter.ToNullableString
Parameters:
	index int an index of element to get.
Returns: string value of the element and true or "" and false if conversion is not supported or index is invalid.

func (*AnyValueArray) GetAsNullableType

func (c *AnyValueArray) GetAsNullableType(typ convert.TypeCode, index int) (any, bool)

GetAsNullableType converts array element into a value defined by specied typecode. If conversion is not possible it returns nil.

see convert.TypeConverter.ToNullableType
Parameters
	- type: TypeCode the TypeCode that defined the type of the result
	- index int an index of element to get.
Returns: any element value defined by the typecode and true or nil and false if conversion is not supported or index is invalid.

func (*AnyValueArray) GetAsNullableUInteger added in v1.0.4

func (c *AnyValueArray) GetAsNullableUInteger(index int) (uint, bool)

GetAsNullableUInteger converts array element into an unsigned integer or returns nil if conversion is not possible.

see convert.IntegerConverter.ToNullableUInteger
Parameters:
	index int an index of element to get.
Returns: unsigned integer value of the element and true or
	0 and false if conversion is not supported or index is invalid.

func (*AnyValueArray) GetAsNullableULong added in v1.0.4

func (c *AnyValueArray) GetAsNullableULong(index int) (uint64, bool)

GetAsNullableULong converts array element into a unsigned long or returns nil if conversion is not possible.

see convert.LongConverter.ToNullableULong
Parameters:
	index int an index of element to get.
Returns: uint64 value of the element and true or 0 and false if conversion is not supported or index is invalid.

func (*AnyValueArray) GetAsObject

func (c *AnyValueArray) GetAsObject(index int) (any, bool)

GetAsObject gets the value stored in array element without any conversions. When element index is not defined it returns the entire array value.

Parameters
	indexint an index of the element to get
Returns: any the element value or value of the array when index is not defined.

func (*AnyValueArray) GetAsSingleObject

func (c *AnyValueArray) GetAsSingleObject() any

GetAsSingleObject inflate AnyValueArray as single object

Returns: any

func (*AnyValueArray) GetAsString

func (c *AnyValueArray) GetAsString(index int) string

GetAsString converts array element into a string or returns "" if conversion is not possible.

see GetAsStringWithDefault
Parameters:
	index int an index of element to get.
Returns: string value ot the element or "" if conversion is not supported.

func (*AnyValueArray) GetAsStringWithDefault

func (c *AnyValueArray) GetAsStringWithDefault(index int, defaultValue string) string

GetAsStringWithDefault converts array element into a string or returns default value if conversion is not possible. see convert.StringConverter.ToStringWithDefault

Parameters:
	index int an index of element to get.
	defaultValue: string the default value
Returns: string value ot the element or default value if conversion is not supported.

func (*AnyValueArray) GetAsType

func (c *AnyValueArray) GetAsType(typ convert.TypeCode, index int) any

GetAsType converts array element into a value defined by specied typecode. If conversion is not possible it returns default value for the specified type.

see GetAsTypeWithDefault
Parameters:
	- type TypeCode the TypeCode that defined the type of the result
	- index int an index of element to get.
Returns: any element value defined by the typecode or default if conversion is not supported.

func (*AnyValueArray) GetAsTypeWithDefault

func (c *AnyValueArray) GetAsTypeWithDefault(typ convert.TypeCode, index int, defaultValue any) any

GetAsTypeWithDefault converts array element into a value defined by specied typecode. If conversion is not possible it returns default value.

see convert.TypeConverter.ToTypeWithDefault
Parameters:
	- type TypeCode the TypeCode that defined the type of the result
	- index int an index of element to get.
	- defaultValue any the default value
Returns: any element value defined by the typecode or default value if conversion is not supported.

func (*AnyValueArray) GetAsUInteger added in v1.0.4

func (c *AnyValueArray) GetAsUInteger(index int) uint

GetAsUInteger converts array element into an unsigned integer or returns 0 if conversion is not possible.

see GetAsIntegerWithDefault
Parameters: index int an index of element to get.
Returns: uint unsigned integer value ot the element or 0 if conversion is not supported.

func (*AnyValueArray) GetAsUIntegerWithDefault added in v1.0.4

func (c *AnyValueArray) GetAsUIntegerWithDefault(index int, defaultValue uint) uint

GetAsUIntegerWithDefault converts array element into an integer or returns default value if conversion is not possible. see IntegerConverter.ToIntegerWithDefault

Parameters:
	- index int an index of element to get.
	- defaultValue uint the default value
Returns: uint unsigned integer value ot the element or default value if conversion is not supported.

func (*AnyValueArray) GetAsULong added in v1.0.4

func (c *AnyValueArray) GetAsULong(index int) uint64

GetAsULong converts array element into a unsigned long or returns 0 if conversion is not possible. see GetAsLongWithDefault

Parameters: index int an index of element to get.
Returns: uint64 value ot the element or 0 if conversion is not supported.

func (*AnyValueArray) GetAsULongWithDefault added in v1.0.4

func (c *AnyValueArray) GetAsULongWithDefault(index int, defaultValue uint64) uint64

GetAsULongWithDefault converts array element into a unsigned long or returns default value if conversion is not possible.

see convert.LongConverter.ToLongWithDefault
Parameters:
	- index int an index of element to get.
	- defaultValue int64 the default value
Returns: uint64 value ot the element or default value if conversion is not supported.

func (*AnyValueArray) GetAsValue

func (c *AnyValueArray) GetAsValue(index int) (*AnyValue, bool)

GetAsValue converts array element into an AnyValue or returns an empty AnyValue if conversion is not possible.

see AnyValue
see AnyValue.constructor
Parameters: index int an index of element to get.
Returns: AnyValue value of the element and true or empty AnyValue and false if conversion is not supported or index is invalid.

func (*AnyValueArray) InnerValue

func (c *AnyValueArray) InnerValue() any

InnerValue return inner value of array as any

func (*AnyValueArray) IsValidIndex

func (c *AnyValueArray) IsValidIndex(index int) bool

IsValidIndex checks that 0 <= index < len.

Parameters:
	index int an index of the element to get.

Returns: bool

func (*AnyValueArray) Len

func (c *AnyValueArray) Len() int

Len returns length of array

func (*AnyValueArray) Push

func (c *AnyValueArray) Push(value any)

Push element in the end of array

Parameters:
	value any an value what need to insert

func (*AnyValueArray) Put

func (c *AnyValueArray) Put(index int, value any) bool

Put a new value into array element specified by its index.

Parameters:
	index int an index of the element to put.
	value any a new value for array element.
Returns: true or false if index is invalid

func (*AnyValueArray) Remove

func (c *AnyValueArray) Remove(index int) bool

Remove an array element specified by its index

Parameters:
	index int an index of the element to remove.

func (*AnyValueArray) SetAsObject

func (c *AnyValueArray) SetAsObject(index int, value any) bool

SetAsObject sets a new value to array element specified by its index. When the index is not defined, it resets the entire array value.

see convert.ArrayConverter.ToArray
Parameters:
	index int an index of the element to set
	value any a new element or array value.

func (*AnyValueArray) SetAsSingleObject

func (c *AnyValueArray) SetAsSingleObject(value any)

SetAsSingleObject sets AnyValueArray from input object

Parameters:
	value any input object

func (*AnyValueArray) String

func (c *AnyValueArray) String() string

String converts array to string with coma separator

func (*AnyValueArray) Value

func (c *AnyValueArray) Value() []any

Value returns array of elements []any

type AnyValueMap

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

AnyValueMap is a Cross-language implementation of dynamic object map (dictionary) what can hold values of any type. The stored values can be converted to different types using variety of accessor methods.

Example
	value1 := AnyValueMap({ key1: 1, key2: "123.456", key3: "2018-01-01" });

	value1.GetAsBoolean("key1");   // Result: true
	value1.GetAsInteger("key2");   // Result: 123
	value1.getAsFloat("key2");     // Result: 123.456
	value1.GetAsDateTime("key3");  // Result: new Date(2018,0,1)

see convert.StringConverter
see convert.TypeConverter
see convert.BooleanConverter
see convert.IntegerConverter
see convert.LongConverter
see convert.DoubleConverter
see convert.FloatConverter
see convert.DateTimeConverter
see ICloneable

func InheritAnyValueMap

func InheritAnyValueMap(base IMap) *AnyValueMap

InheritAnyValueMap creates a new instance of the map and assigns base methods from interface.

Parameters: base IMap
Returns: *AnyValueMap

func NewAnyValueMap

func NewAnyValueMap(value map[string]any) *AnyValueMap

NewAnyValueMap creates a new instance of the map and assigns its value. Parameters:

  • values map[string]any

Returns *AnyValueMap

func NewAnyValueMapFromMaps

func NewAnyValueMapFromMaps(maps ...map[string]any) *AnyValueMap

NewAnyValueMapFromMaps creates a new AnyValueMap by merging two or more maps. Maps defined later in the list override values from previously defined maps.

Parameters: maps ...maps: any[] an array of maps to be merged
Returns: *AnyValueMap a newly created AnyValueMap.

func NewAnyValueMapFromTuples

func NewAnyValueMapFromTuples(tuples ...any) *AnyValueMap

NewAnyValueMapFromTuples Creates a new AnyValueMap from a list of key-value pairs called tuples.

see NewAnyValueMapFromTuplesArray
Parameters: tuples ...tuples: any a list of values where odd elements
	are keys and the following even elements are values
Returns: *AnyValueMap a newly created AnyValueArray.

func NewAnyValueMapFromTuplesArray

func NewAnyValueMapFromTuplesArray(tuples []any) *AnyValueMap

NewAnyValueMapFromTuplesArray creates a new AnyValueMap from a list of key-value pairs called tuples. The method is similar to fromTuples but tuples are passed as array instead of parameters.

Parameters: tuples: []any a list of values where odd elements are keys and
the following even elements are values
Returns: *AnyValueMap a newly created AnyValueArray.

func NewAnyValueMapFromValue

func NewAnyValueMapFromValue(value any) *AnyValueMap

NewAnyValueMapFromValue Converts specified value into AnyValueMap.

see SetAsSingleObject
Parameters: value any value to be converted
Returns: *AnyValueMap a newly created AnyValueMap.

func NewEmptyAnyValueMap

func NewEmptyAnyValueMap() *AnyValueMap

NewEmptyAnyValueMap creates a new empty instance of the map.

Returns: *AnyValueMap

func (*AnyValueMap) Append

func (c *AnyValueMap) Append(value map[string]any)

Append new elements to this map.

Parameters: value: map[string]any a map of elements to be added.

func (*AnyValueMap) Clear

func (c *AnyValueMap) Clear()

Clear this map by removing all its elements.

func (*AnyValueMap) Clone

func (c *AnyValueMap) Clone() *AnyValueMap

Clone creates a binary clone of this object.

Returns: any a clone of this object.

func (*AnyValueMap) Contains

func (c *AnyValueMap) Contains(key string) bool

Contains checks if this map contains a key. The check uses direct comparison between key and the specified key value.

Parameters: key string a value to be checked
Returns: bool true if this map contains the key or false otherwise.

func (*AnyValueMap) Get

func (c *AnyValueMap) Get(key string) (any, bool)

Get a map element specified by its key.

Parameters: key string a key of the element to get.
Returns: any the value of the map element.

func (*AnyValueMap) GetAsArray

func (c *AnyValueMap) GetAsArray(key string) *AnyValueArray

GetAsArray converts map element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible.

see AnyValueArray
see NewAnyValueArrayFromValue
Parameters: key string a key of element to get.
Returns: *AnyValueArray value of the element or empty AnyValueArray if conversion is not supported.

func (*AnyValueMap) GetAsArrayWithDefault

func (c *AnyValueMap) GetAsArrayWithDefault(key string, defaultValue *AnyValueArray) *AnyValueArray

GetAsArrayWithDefault converts map element into an AnyValueArray or returns default value if conversion is not possible.

see AnyValueArray
see GetAsNullableArray
Parameters:
	- key string a key of element to get.
	- defaultValue: *AnyValueArray the default value
Returns: *AnyValueArray value of the element or default value if conversion is not supported.

func (*AnyValueMap) GetAsBoolean

func (c *AnyValueMap) GetAsBoolean(key string) bool

GetAsBoolean converts map element into a boolean or returns false if conversion is not possible.

see GetAsBooleanWithDefault
Parameters: key: string a key of element to get.
Returns: bool value of the element or false if conversion is not supported.

func (*AnyValueMap) GetAsBooleanWithDefault

func (c *AnyValueMap) GetAsBooleanWithDefault(key string, defaultValue bool) bool

GetAsBooleanWithDefault converts map element into a boolean or returns default value if conversion is not possible.

see convert.BooleanConverter.toBooleanWithDefault
Parameters:
	- key string a key of element to get.
	- defaultValue bool the default value
Returns: bool value of the element or default value if conversion is not supported.

func (*AnyValueMap) GetAsDateTime

func (c *AnyValueMap) GetAsDateTime(key string) time.Time

GetAsDateTime converts map element into a time.Time or returns the current date if conversion is not possible.

see GetAsDateTimeWithDefault
Parameters: key string a key of element to get.
Returns: time.Time value of the element or the current date if conversion is not supported.

func (*AnyValueMap) GetAsDateTimeWithDefault

func (c *AnyValueMap) GetAsDateTimeWithDefault(key string, defaultValue time.Time) time.Time

GetAsDateTimeWithDefault converts map element into a time.Time or returns default value if conversion is not possible.

see convert.DateTimeConverter.toDateTimeWithDefault
Parameters:
	- key: string a key of element to get.
	- defaultValue: Date the default value
Returns: time.Time value of the element or default value if conversion is not supported.

func (*AnyValueMap) GetAsDouble

func (c *AnyValueMap) GetAsDouble(key string) float64

GetAsDouble converts map element into a double or returns 0 if conversion is not possible.

see GetAsDoubleWithDefault
Parameters: key string a key of element to get.
Returns: float64 value of the element or 0 if conversion is not supported.

func (*AnyValueMap) GetAsDoubleWithDefault

func (c *AnyValueMap) GetAsDoubleWithDefault(key string, defaultValue float64) float64

GetAsDoubleWithDefault converts map element into a double or returns default value if conversion is not possible. see convert.DoubleConverter.ToDoubleWithDefault

Parameters:
	- key string a key of element to get.
	- defaultValue float64 the default value
Returns: float64 value of the element or default value if conversion is not supported.

func (*AnyValueMap) GetAsDuration

func (c *AnyValueMap) GetAsDuration(key string) time.Duration

GetAsDuration converts map element into a time.Duration or returns the current date if conversion is not possible.

see GetAsDurationWithDefault
Parameters: key string a key of element to get.
Returns: time.Duration value of the element or the current date if conversion is not supported.

func (*AnyValueMap) GetAsDurationWithDefault

func (c *AnyValueMap) GetAsDurationWithDefault(key string, defaultValue time.Duration) time.Duration

GetAsDurationWithDefault converts map element into a time.Duration or returns default value if conversion is not possible.

see convert.DurationConverter.toDateTimeWithDefault
Parameters:
	- key: string a key of element to get.
	- defaultValue: Date the default value
Returns: time.Duration value of the element or default value if conversion is not supported.

func (*AnyValueMap) GetAsFloat

func (c *AnyValueMap) GetAsFloat(key string) float32

GetAsFloat converts map element into a float or returns 0 if conversion is not possible.

see GetAsFloatWithDefault
Parameters: key string a key of element to get.
Returns: float32 value of the element or 0 if conversion is not supported.

func (*AnyValueMap) GetAsFloatWithDefault

func (c *AnyValueMap) GetAsFloatWithDefault(key string, defaultValue float32) float32

GetAsFloatWithDefault converts map element into a flot or returns default value if conversion is not possible.

see convert.FloatConverter.toFloatWithDefault
Parameters:
	- key string a key of element to get.
	- defaultValue float32 the default value
Returns: float32 value of the element or default value if conversion is not supported.

func (*AnyValueMap) GetAsInteger

func (c *AnyValueMap) GetAsInteger(key string) int

GetAsInteger converts map element into an integer or returns 0 if conversion is not possible.

see GetAsIntegerWithDefault
Parameters: key string a key of element to get.
Returns: integer value of the element or 0 if conversion is not supported.

func (*AnyValueMap) GetAsIntegerWithDefault

func (c *AnyValueMap) GetAsIntegerWithDefault(key string, defaultValue int) int

GetAsIntegerWithDefault converts map element into an integer or returns default value if conversion is not possible.

see convert.IntegerConverter.toIntegerWithDefault
Parameters:
	- key string a key of element to get.
	-defaultValue int the default value
Returns: integer value of the element or default value if conversion is not supported.

func (*AnyValueMap) GetAsLong

func (c *AnyValueMap) GetAsLong(key string) int64

GetAsLong converts map element into a long or returns 0 if conversion is not possible.

see GetAsLongWithDefault
Parameters: key string a key of element to get.
Returns: int64 value of the element or 0 if conversion is not supported.

func (*AnyValueMap) GetAsLongWithDefault

func (c *AnyValueMap) GetAsLongWithDefault(key string, defaultValue int64) int64

GetAsLongWithDefault converts map element into a long or returns default value if conversion is not possible.

see convert.LongConverter.toLongWithDefault
Parameters:
	-key string a key of element to get.
	- defaultValue int64 the default value
Returns: int64 value of the element or default value if conversion is not supported.

func (*AnyValueMap) GetAsMap

func (c *AnyValueMap) GetAsMap(key string) *AnyValueMap

GetAsMap converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.

see NewAnyValueMapFromValue
Parameters: key string a key of element to get.
Returns: *AnyValueMap value of the element or empty AnyValueMap if conversion is not supported.

func (*AnyValueMap) GetAsMapWithDefault

func (c *AnyValueMap) GetAsMapWithDefault(key string, defaultValue *AnyValueMap) *AnyValueMap

GetAsMapWithDefault converts map element into an AnyValueMap or returns default value if conversion is not possible.

see GetAsNullableMap
Parameters:
	- key string a key of element to get.
	- defaultValue *AnyValueMap the default value
Returns: *AnyValueMap value of the element or default value if conversion is not supported.

func (*AnyValueMap) GetAsNullableArray

func (c *AnyValueMap) GetAsNullableArray(key string) (*AnyValueArray, bool)

GetAsNullableArray converts map element into an AnyValueArray or returns null if conversion is not possible.

see AnyValueArray
see NewAnyValueArrayFromValue
Parameters:  key string a key of element to get.
Returns: *AnyValueArray value of the element or null if conversion is not supported.

func (*AnyValueMap) GetAsNullableBoolean

func (c *AnyValueMap) GetAsNullableBoolean(key string) (bool, bool)

GetAsNullableBoolean converts map element into a boolean or returns null if conversion is not possible. see convert.BooleanConverter.toNullableBoolean

Parameters: key string a key of element to get.
Returns: bool value of the element or null if conversion is not supported.

func (*AnyValueMap) GetAsNullableDateTime

func (c *AnyValueMap) GetAsNullableDateTime(key string) (time.Time, bool)

GetAsNullableDateTime converts map element into a time.Time or returns null if conversion is not possible.

see convert.DateTimeConverter.ToNullableDateTime
Parameters: key string a key of element to get.
Returns: time.Time value of the element or null if conversion is not supported.

func (*AnyValueMap) GetAsNullableDouble

func (c *AnyValueMap) GetAsNullableDouble(key string) (float64, bool)

GetAsNullableDouble converts map element into a double or returns null if conversion is not possible.

see convert.DoubleConverter.toNullableDouble
Parameters: key string a key of element to get.
Returns: float64 value of the element or null if conversion is not supported.

func (*AnyValueMap) GetAsNullableDuration

func (c *AnyValueMap) GetAsNullableDuration(key string) (time.Duration, bool)

GetAsNullableDuration converts map element into a time.Duration or returns null if conversion is not possible.

see convert.DurationConverter.toNullableDateTime
Parameters: key string a key of element to get.
Returns: time.Duration value of the element or null if conversion is not supported.

func (*AnyValueMap) GetAsNullableFloat

func (c *AnyValueMap) GetAsNullableFloat(key string) (float32, bool)

GetAsNullableFloat converts map element into a float or returns null if conversion is not possible.

see convert.FloatConverter.toNullableFloat
Parameters: key string a key of element to get.
Returns: float32 value of the element or null if conversion is not supported.

func (*AnyValueMap) GetAsNullableInteger

func (c *AnyValueMap) GetAsNullableInteger(key string) (int, bool)

GetAsNullableInteger converts map element into an integer or returns null if conversion is not possible.

see convert.IntegerConverter.toNullableInteger
Parameters: key string a key of element to get.
Returns: value of the element or null if conversion is not supported.

func (*AnyValueMap) GetAsNullableLong

func (c *AnyValueMap) GetAsNullableLong(key string) (int64, bool)

GetAsNullableLong converts map element into a long or returns null if conversion is not possible.

see convert.LongConverter.toNullableLong
Parameters: key string a key of element to get.
Returns: int64 value of the element or null if conversion is not supported.

func (*AnyValueMap) GetAsNullableMap

func (c *AnyValueMap) GetAsNullableMap(key string) (*AnyValueMap, bool)

GetAsNullableMap converts map element into an AnyValueMap or returns null if conversion is not possible.

see NewAnyValueMapFromValue
Parameters: key string  a key of element to get.
Returns: *AnyValueMap value of the element or null if conversion is not supported.

func (*AnyValueMap) GetAsNullableString

func (c *AnyValueMap) GetAsNullableString(key string) (string, bool)

GetAsNullableString converts map element into a string or returns null if conversion is not possible. see convert.StringConverter.ToNullableString

Parameters: key string a key of element to get.
Returns: string value of the element or null if conversion is not supported.

func (*AnyValueMap) GetAsNullableType

func (c *AnyValueMap) GetAsNullableType(typ convert.TypeCode, key string) (any, bool)

GetAsNullableType converts map element into a value defined by specied typecode. If conversion is not possible it returns null.

see TypeConverter.ToNullableType
Parameters:
	- type TypeCode the TypeCode that defined the type of the result
	- key string a key of element to get.
Returns: any element value defined by the typecode or null if conversion is not supported.

func (*AnyValueMap) GetAsNullableUInteger added in v1.0.4

func (c *AnyValueMap) GetAsNullableUInteger(key string) (uint, bool)

GetAsNullableUInteger converts map element into an unsigned integer or returns false if conversion is not possible.

see convert.IntegerConverter.toNullableUInteger
Parameters: key string a key of element to get.
Returns: value of the element or false if conversion is not supported.

func (*AnyValueMap) GetAsNullableULong added in v1.0.4

func (c *AnyValueMap) GetAsNullableULong(key string) (uint64, bool)

GetAsNullableULong converts map element into a long or returns null if conversion is not possible.

see convert.LongConverter.toNullableLong
Parameters: key string a key of element to get.
Returns: int64 value of the element or null if conversion is not supported.

func (*AnyValueMap) GetAsObject

func (c *AnyValueMap) GetAsObject(key string) (any, bool)

GetAsObject gets the value stored in map element without any conversions. When element key is not defined it returns the entire map value.

Parameters: key string a key of the element to get
Returns: any the element value or value of the map when index is not defined.

func (*AnyValueMap) GetAsSingleObject

func (c *AnyValueMap) GetAsSingleObject() any

GetAsSingleObject gets the value stored in map element without any conversions. When element index is not defined it returns the entire array value.

Returns: any the element value or value of the array when index is not defined.

func (*AnyValueMap) GetAsString

func (c *AnyValueMap) GetAsString(key string) string

GetAsString converts map element into a string or returns "" if conversion is not possible.

see GetAsStringWithDefault
Parameters: key string a key of element to get.
Returns: string value of the element or "" if conversion is not supported.

func (*AnyValueMap) GetAsStringWithDefault

func (c *AnyValueMap) GetAsStringWithDefault(key string, defaultValue string) string

GetAsStringWithDefault converts map element into a string or returns default value if conversion is not possible. see convert.StringConverter.ToStringWithDefault

Parameters:
	- key string a key of element to get.
	- defaultValue string the default value
Returns: string value of the element or default value if conversion is not supported.

func (*AnyValueMap) GetAsType

func (c *AnyValueMap) GetAsType(typ convert.TypeCode, key string) any

GetAsType converts map element into a value defined by specied typecode. If conversion is not possible it returns default value for the specified type.

see GetAsTypeWithDefault
Parameters:
	- type TypeCode the TypeCode that defined the type of the result
	- key string a key of element to get.
Returns: any element value defined by the typecode or default if conversion is not supported.

func (*AnyValueMap) GetAsTypeWithDefault

func (c *AnyValueMap) GetAsTypeWithDefault(typ convert.TypeCode, key string, defaultValue any) any

GetAsTypeWithDefault converts map element into a value defined by specied typecode. If conversion is not possible it returns default value.

see convert.TypeConverter.toTypeWithDefault
Parameters:
	- type TypeCode the TypeCode that defined the type of the result
	- key string a key of element to get.
	- defaultValue any the default value
Returns: any element value defined by the typecode or default value if conversion is not supported.

func (*AnyValueMap) GetAsUInteger added in v1.0.4

func (c *AnyValueMap) GetAsUInteger(key string) uint

GetAsUInteger converts map element into an integer or returns 0 if conversion is not possible.

see GetAsIntegerWithDefault
Parameters: key string a key of element to get.
Returns: unsigned integer value of the element or 0 if conversion is not supported.

func (*AnyValueMap) GetAsUIntegerWithDefault added in v1.0.4

func (c *AnyValueMap) GetAsUIntegerWithDefault(key string, defaultValue uint) uint

GetAsUIntegerWithDefault converts map element into an unsigned integer or returns default value if conversion is not possible.

see IntegerConverter.ToUIntegerWithDefault
Parameters:
	- key string a key of element to get.
	-defaultValue int the default value
Returns: unsigned integer value of the element or default value if conversion is not supported.

func (*AnyValueMap) GetAsULong added in v1.0.4

func (c *AnyValueMap) GetAsULong(key string) uint64

GetAsULong converts map element into a unsigned long or returns 0 if conversion is not possible.

see GetAsLongWithDefault
Parameters: key string a key of element to get.
Returns: uint64 value of the element or 0 if conversion is not supported.

func (*AnyValueMap) GetAsULongWithDefault added in v1.0.4

func (c *AnyValueMap) GetAsULongWithDefault(key string, defaultValue uint64) uint64

GetAsULongWithDefault converts map element into a unsigned long or returns default value if conversion is not possible.

see convert.LongConverter.ToLongWithDefault

Parameters:

  • key string a key of element to get.
  • defaultValue int64 the default value Returns: uint64 value of the element or default value if conversion is not supported.

func (*AnyValueMap) GetAsValue

func (c *AnyValueMap) GetAsValue(key string) *AnyValue

GetAsValue converts map element into an AnyValue or returns an empty AnyValue if conversion is not possible.

see AnyValue
see NewAnyValue
Parameters: key string a key of element to get.
Returns: *AnyValue value of the element or empty AnyValue if conversion is not supported.

func (*AnyValueMap) InnerValue

func (c *AnyValueMap) InnerValue() any

InnerValue return inner values of map as any

func (*AnyValueMap) Keys

func (c *AnyValueMap) Keys() []string

Keys gets keys of all elements stored in this map.

Returns: []string a list with all map keys.

func (*AnyValueMap) Len

func (c *AnyValueMap) Len() int

Len gets a number of elements stored in this map.

Returns: int the number of elements in this map.

func (*AnyValueMap) Put

func (c *AnyValueMap) Put(key string, value any)

Put a new value into map element specified by its key.

Parameters:
	- key string a key of the element to put.
	- value any a new value for map element.
Returns: any

func (*AnyValueMap) Remove

func (c *AnyValueMap) Remove(key string)

Remove a map element specified by its key

Parameters: key string a key of the element to remove.

func (*AnyValueMap) SetAsObject

func (c *AnyValueMap) SetAsObject(key string, value any)

SetAsObject sets a new value to map element specified by its index. When the index is not defined, it resets the entire map value.

see convert.MapConverter.ToMap
Parameters:
	- key string a key of the element to set
	- value any a new element or map value.

func (*AnyValueMap) SetAsSingleObject

func (c *AnyValueMap) SetAsSingleObject(value any)

SetAsSingleObject sets a new value to map. see convert.MapConverter.ToMap

Parameters: value any a new element or array value.

func (*AnyValueMap) String

func (c *AnyValueMap) String() string

String gets a string representation of the object. The result is a semicolon-separated list of key-value pairs as "key1=value1;key2=value2;key=value3" Returns: string a string representation of the object.

func (*AnyValueMap) Value

func (c *AnyValueMap) Value() map[string]any

Value returns map of elements as map[string]any

type DataPage

type DataPage[T any] struct {
	Total int `json:"total"`
	Data  []T `json:"data"`
}

DataPage is a transfer object that is used to pass results of paginated queries. It contains items of retrieved page and optional total number of items. Most often this object type is used to send responses to paginated queries. Pagination parameters are defined by PagingParams object. The skip parameter in the PagingParams there means how many items to skip. The takes parameter sets number of items to return in the page. And the optional total parameter tells to return total number of items in the query. Remember: not all implementations support the total parameter because its generation may lead to severe performance implications.

	see PagingParams

	Example:
		page, err := myDataClient.GetDataByFilter(
			context.Background(),
     	"123",
     	FilterParams.fromTuples("completed": true),
     	NewPagingParams(0, 100, true),
 	);

 	if err != nil {
 		panic(err)
 	}
 	for item range page.Data {
         fmt.Println(item);
     }
 );

func NewDataPage

func NewDataPage[T any](data []T, total int) *DataPage[T]

NewDataPage creates a new instance of data page and assigns its values.

Parameters:
	- value data a list of items from the retrieved page.
	- total int
Returns: *DataPage

func NewEmptyDataPage

func NewEmptyDataPage[T any]() *DataPage[T]

NewEmptyDataPage creates a new empty instance of data page.

Returns: *DataPage

func (*DataPage[T]) HasData

func (d *DataPage[T]) HasData() bool

HasData method check if data exists

func (*DataPage[T]) HasTotal

func (d *DataPage[T]) HasTotal() bool

HasTotal method check if total exists and valid

func (DataPage[T]) MarshalJSON

func (d DataPage[T]) MarshalJSON() ([]byte, error)

type FilterParams

type FilterParams struct {
	StringValueMap
}

FilterParams is a data transfer object used to pass filter parameters as simple key-value pairs.

see StringValueMap

Example:
	filter := NewFilterParamsFromTuples(
		"type", "Type1",
		"from_create_time", new Date(2000, 0, 1),
		"to_create_time", new Date(),
		"completed", true
	);
	paging = NewPagingParams(0, 100);

	err, page = myDataClient.getDataByFilter(filter, paging);

func NewEmptyFilterParams

func NewEmptyFilterParams() *FilterParams

NewEmptyFilterParams сreates a new instance.

Returns: *FilterParams

func NewFilterParams

func NewFilterParams(values map[string]string) *FilterParams

NewFilterParams creates a new instance and initialize it with elements from the specified map.

Parameters:
	- value map[string]string a map to initialize this instance.
Returns: *FilterParams

func NewFilterParamsFromString

func NewFilterParamsFromString(line string) *FilterParams

NewFilterParamsFromString parses semicolon-separated key-value pairs and returns them as a FilterParams. see StringValueMap.FromString

Parameters:
	- line string semicolon-separated key-value list to initialize FilterParams.
Returns: *FilterParams

func NewFilterParamsFromTuples

func NewFilterParamsFromTuples(tuples ...any) *FilterParams

NewFilterParamsFromTuples creates a new FilterParams from a list of key-value pairs called tuples.

Parameters:
	- tuples ...any a list of values where odd
	elements are keys and the following even elements are values
Returns: *FilterParams a newly created FilterParams.

func NewFilterParamsFromValue

func NewFilterParamsFromValue(value any) *FilterParams

NewFilterParamsFromValue converts specified value into FilterParams.

Parameters:
	- value interface value to be converted
Returns: a newly created FilterParams.

type ICloneable

type ICloneable[T any] interface {
	// Clone creates a binary clone of this object.
	// returns: a clone of this object.
	Clone() T
}

ICloneable Interface for data objects that are able to create their full binary copy.

Example
	type MyStruct struct {
		...
	}

	func (c *MyStruct) Clone() *MyStruct {
		cloneObj := new(MyStruct)
		// Copy every attribute from this to cloneObj here.
		...
		return cloneObj
	}

type IEquatable

type IEquatable[T any] interface {
	Equals(T) bool
}

type IIdentifiable added in v1.0.3

type IIdentifiable[K any] interface {
	GetId() K
}

IIdentifiable interface for data objects to operate with ids.

Example
	type MyStruct struct {
		...
		id string
	}

	func (c *MyStruct) GetId() string {
		return c.id
	}
	func (c *MyStruct) SetId(id string) {
		c.id = id
	}

type IIdentifier added in v1.0.5

type IIdentifier[K any] interface {
	Empty() bool
	Equals(K) bool
}

type IMap

type IMap interface {
	Get(key string) (any, bool)
	Put(key string, value any)
	Remove(key string)
	Contains(key string) bool
	Len() int
}

type IStringIdentifiable added in v1.0.5

type IStringIdentifiable interface {
	GetId() string
	SetId(string)
}

IStringIdentifiable interface for data objects to operate with ids.

Example
	type MyStruct struct {
		...
		id string
	}

	func (c *MyStruct) GetId() string {
		return c.id
	}
	func (c *MyStruct) SetId(id string) {
		c.id = id
	}

type MultiString

type MultiString map[string]string

MultiString An object that contains string translations for multiple languages. Language keys use two-letter codes like: 'en', 'sp', 'de', 'ru', 'fr', 'pr'. When translation for specified language does not exists it defaults to English ('en'). When English does not exists it falls back to the first defined language.

Example:
	values := MultiString.FromTuples(
		"en", "Hello World!",
		"ru", "Привет мир!"
	);

value1 := values.Get('ru'); // Result: "Привет мир!"
value2 := values.Get('pt'); // Result: "Hello World!"

type PagingParams

type PagingParams struct {
	Skip  int64 `json:"skip"`
	Take  int64 `json:"take"`
	Total bool  `json:"total"`
}

PagingParams is a data transfer object to pass paging parameters for queries.

The page is defined by two parameters:
	the skip parameter defines number of items to skip.
	the take parameter sets how many items to return in a page.
additionally, the optional total parameter tells to return total number of items in the query.
Remember: not all implementations support the total parameter because its generation may lead to
severe performance implications.

Example:
	filter := NewFilterParamsFromTuples("type", "Type1");
	paging := NewPagingParams(0, 100);

	err, page = myDataClient.getDataByFilter(filter, paging);

func NewEmptyPagingParams

func NewEmptyPagingParams() *PagingParams

NewEmptyPagingParams creates a new instance. Returns: *PagingParams

func NewPagingParams

func NewPagingParams(skip, take int64, total bool) *PagingParams

NewPagingParams creates a new instance and sets its values. Parameters:

  • skip the number of items to skip.
  • take the number of items to return.
  • total true to return the total number of items.

Returns: *PagingParams

func NewPagingParamsFromMap

func NewPagingParamsFromMap(value *AnyValueMap) *PagingParams

NewPagingParamsFromMap creates a new PagingParams and sets it parameters from the specified map

Parameters: value AnyValueMap or StringValueMap to initialize this PagingParams
Returns: *PagingParams a newly created PagingParams.

func NewPagingParamsFromTuples

func NewPagingParamsFromTuples(tuples ...any) *PagingParams

NewPagingParamsFromTuples creates a new PagingParams from a list of key-value pairs called tuples.

Parameters: tuples ...any a list of values where odd elements are
	keys and the following even elements are values
Returns: *PagingParams a newly created PagingParams.

func NewPagingParamsFromValue

func NewPagingParamsFromValue(value any) *PagingParams

NewPagingParamsFromValue converts specified value into PagingParams.

Parameters: value any value to be converted
Returns: *PagingParams a newly created PagingParams.

func (*PagingParams) GetSkip

func (c *PagingParams) GetSkip(minSkip int64) int64

GetSkip gets the number of items to skip.

Parameters: minSkip int64 the minimum number of items to skip.
Returns: int64 the number of items to skip.

func (*PagingParams) GetTake

func (c *PagingParams) GetTake(maxTake int64) int64

GetTake gets the number of items to return in a page.

Parameters: maxTake int64 the maximum number of items to return.
Returns int64 the number of items to return.

type ProjectionParams

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

ProjectionParams defines projection parameters with list if fields to include into query results. The parameters support two formats: dot format and nested format. The dot format is the standard way to define included fields and subfields using dot object notation: "field1,field2.field21,field2.field22.field221". As alternative the nested format offers a more compact representation: "field1,field2(field21,field22(field221))".

Example:
	filter := NewFilterParamsFromTuples("type", "Type1");
	paging := NewPagingParams(0, 100);
	projection = NewProjectionParamsFromString("field1,field2(field21,field22)")

	err, page := myDataClient.getDataByFilter(filter, paging, projection);

func NewEmptyProjectionParams

func NewEmptyProjectionParams() *ProjectionParams

NewEmptyProjectionParams creates a new instance of the projection parameters and assigns its value.

Returns: *ProjectionParams

func NewProjectionParamsFromAnyArray

func NewProjectionParamsFromAnyArray(values *AnyValueArray) *ProjectionParams

NewProjectionParamsFromAnyArray creates a new instance of the projection parameters and assigns its from AnyValueArray values.

Parameters: values *AnyValueArray
Returns: *ProjectionParams

func NewProjectionParamsFromStrings

func NewProjectionParamsFromStrings(values []string) *ProjectionParams

NewProjectionParamsFromStrings creates a new instance of the projection parameters and assigns its from string value.

Parameters: values []string
Returns: *ProjectionParams

func NewProjectionParamsFromValue

func NewProjectionParamsFromValue(value any) *ProjectionParams

NewProjectionParamsFromValue converts specified value into ProjectionParams.

see AnyValueArray.fromValue
Parameters: value any value to be converted
Returns: *ProjectionParams a newly created ProjectionParams.

func ParseProjectionParams

func ParseProjectionParams(values ...string) *ProjectionParams

ParseProjectionParams create new ProjectionParams and set values from values

Parameters: values ...string a values to parse
Returns: *ProjectionParams

func (*ProjectionParams) Append

func (c *ProjectionParams) Append(elements []string)

Append new elements to an array.

Parameters: value []string

func (*ProjectionParams) Clear

func (c *ProjectionParams) Clear()

Clear elements

func (*ProjectionParams) Get

func (c *ProjectionParams) Get(index int) (any, bool)

Get value by index Parameters:

  • index int an index of element

Return string

func (*ProjectionParams) IsValidIndex

func (c *ProjectionParams) IsValidIndex(index int) bool

IsValidIndex checks that 0 <= index < len.

Parameters:
	index int an index of the element to get.

Returns: bool

func (*ProjectionParams) Len

func (c *ProjectionParams) Len() int

Len gets or sets the length of the array. This is a number one higher than the highest element defined in an array.

func (*ProjectionParams) Push

func (c *ProjectionParams) Push(value string)

Push new element to an array.

Parameters: value string

func (*ProjectionParams) Put

func (c *ProjectionParams) Put(index int, value string) bool

Put value in index position

Parameters:
	- index int an index of element
	- value string value

func (*ProjectionParams) Remove

func (c *ProjectionParams) Remove(index int)

Remove element by index Parameters:

  • index int an index of remove element

func (*ProjectionParams) String

func (c *ProjectionParams) String() string

String returns a string representation of an array.

Returns: string

func (*ProjectionParams) Value

func (c *ProjectionParams) Value() []string

Value return raw values []string

type SortField

type SortField struct {
	Name      string `json:"name"`
	Ascending bool   `json:"ascending"`
}

SortField Defines a field name and order used to sort query results.

see SortParams

Example:
	filter := NewFilterParamsFromTuples("type", "Type1");
	paging := NewPagingParams(0, 100);
	sorting := NewSortingParams(NewSortField("create_time", true));

	err, page = myDataClient.getDataByFilter(filter, paging, sorting);

func NewEmptySortField

func NewEmptySortField() SortField

NewEmptySortField creates a new empty instance. Returns SortField

func NewSortField

func NewSortField(name string, ascending bool) SortField

NewSortField creates a new instance and assigns its values.

Parameters:
	- name string the name of the field to sort by.
	- ascending: bool true to sort in ascending order, and false to sort in descending order.
Returns: SortField

type SortParams

type SortParams []SortField

SortParams Defines a field name and order used to sort query results.

see SortField

Example:
	filter := NewFilterParamsFromTuples("type", "Type1");
	paging := NewPagingParams(0, 100);
	sorting := NewSortingParams(NewSortField("create_time", true));

	myDataClient.getDataByFilter(filter, paging, sorting, (err, page) => {...});

func NewEmptySortParams

func NewEmptySortParams() *SortParams

NewEmptySortParams creates a new instance.

Returns: *SortParams

func NewSortParams

func NewSortParams(fields []SortField) *SortParams

NewSortParams creates a new instance and initializes it with specified sort fields.

Parameters
	- fields []SortField a list of fields to sort by.
Returns: *SortParams

type StringValueMap

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

StringValueMap Cross-language implementation of a map (dictionary) where all keys and values are strings. The stored values can be converted to different types using variety of accessor methods. The string map is highly versatile. It can be converted into many formats, stored and sent over the wire.

This class is widely used in Pip.Services as a basis for variety of classes, such as ConfigParams, ConnectionParams, CredentialParams and others.

Example:
	value1 := NewStringValueMapFromString("key1=1;key2=123.456;key3=2018-01-01");

	value1.getAsBoolean("key1");   // Result: true
	value1.getAsInteger("key2");   // Result: 123
	value1.getAsFloat("key2");     // Result: 123.456
	value1.getAsDateTime("key3");  // Result: new Date(2018,0,1)
	see StringConverter
	see TypeConverter
	see BooleanConverter
	see IntegerConverter
	see LongConverter
	see DoubleConverter
	see FloatConverter
	see DateTimeConverter

func NewEmptyStringValueMap

func NewEmptyStringValueMap() *StringValueMap

NewEmptyStringValueMap creates a new instance of the map.

func NewStringValueMap

func NewStringValueMap(value map[string]string) *StringValueMap

NewStringValueMap creates a new instance of the map and assigns its value.

Parameters: value map[string]string
Returns: *StringValueMap

func NewStringValueMapFromMaps

func NewStringValueMapFromMaps(maps ...map[string]string) *StringValueMap

NewStringValueMapFromMaps creates a new AnyValueMap by merging two or more maps. Maps defined later in the list override values from previously defined maps.

Parameters: maps...map[string]string an array of maps to be merged
Returns: StringValueMap a newly created AnyValueMap.

func NewStringValueMapFromString

func NewStringValueMapFromString(line string) *StringValueMap

NewStringValueMapFromString parses semicolon-separated key-value pairs and returns them as a StringValueMap.

Parameters: line string semicolon-separated key-value list to initialize StringValueMap.
Returns: *StringValueMap a newly created StringValueMap.

func NewStringValueMapFromTuples

func NewStringValueMapFromTuples(tuples ...any) *StringValueMap

NewStringValueMapFromTuples creates a new StringValueMap from a list of key-value pairs called tuples.

see NewStringValueMapFromTuplesArray
Parameters: tuples ...any a list of values where odd elements
	are keys and the following even elements are values
Returns: *StringValueMap a newly created StringValueMap.

func NewStringValueMapFromTuplesArray

func NewStringValueMapFromTuplesArray(tuples []any) *StringValueMap

NewStringValueMapFromTuplesArray creates a new StringValueMap from a list of key-value pairs called tuples. The method is similar to fromTuples but tuples are passed as array instead of parameters.

Parameters: tuples: []any a list of values where odd elements
	are keys and the following even elements are values
Returns: *StringValueMap a newly created StringValueMap.

func NewStringValueMapFromValue

func NewStringValueMapFromValue(value any) *StringValueMap

NewStringValueMapFromValue converts specified value into StringValueMap.

see SetAsSingleObject
Parameters: value any value to be converted
Returns: *StringValueMap a newly created StringValueMap.

func (*StringValueMap) Append

func (c *StringValueMap) Append(values map[string]string)

Append new elements to this map.

Parameters: values map[string]string a map with elements to be added.

func (*StringValueMap) AppendAny

func (c *StringValueMap) AppendAny(values map[string]any)

AppendAny new elements to this map.

Parameters: values map[string]any a map with elements to be added.

func (*StringValueMap) Clear

func (c *StringValueMap) Clear()

Clear this map by removing all its elements.

func (*StringValueMap) Clone

func (c *StringValueMap) Clone() *StringValueMap

Clone creates a binary clone of this object.

Returns any a clone of this object.

func (*StringValueMap) Contains

func (c *StringValueMap) Contains(key string) bool

Contains checks if this map contains a key. The check uses direct comparison between key and the specified key value. Parameters

  • key string a value to be checked

Returns bool true if this map contains the key or false otherwise.

func (*StringValueMap) Get

func (c *StringValueMap) Get(key string) (any, bool)

Get a map element specified by its key.

Parameters: key string a key of the element to get.
Returns string the value of the map element.

func (*StringValueMap) GetAsArray

func (c *StringValueMap) GetAsArray(key string) *AnyValueArray

GetAsArray converts map element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible.

see AnyValueArray
see NewAnyValueArrayFromValue
Parameters: key string a key of element to get.
Returns: *AnyValueArray value of the element or empty AnyValueArray if conversion is not supported.

func (*StringValueMap) GetAsArrayWithDefault

func (c *StringValueMap) GetAsArrayWithDefault(key string, defaultValue *AnyValueArray) *AnyValueArray

GetAsArrayWithDefault converts map element into an AnyValueArray or returns default value if conversion is not possible.

see AnyValueArray
see GetAsNullableArray
Parameters
	- key string a key of element to get.
	- defaultValue *AnyValueArray the default value
Returns: *AnyValueArray value of the element or default value if conversion is not supported.

func (*StringValueMap) GetAsBoolean

func (c *StringValueMap) GetAsBoolean(key string) bool

GetAsBoolean converts map element into a boolean or returns false if conversion is not possible.

see GetAsBooleanWithDefault
Parameters: key string a key of element to get.
Returns: boolean value of the element or false if conversion is not supported.

func (*StringValueMap) GetAsBooleanWithDefault

func (c *StringValueMap) GetAsBooleanWithDefault(key string, defaultValue bool) bool

GetAsBooleanWithDefault converts map element into a boolean or returns default value if conversion is not possible. see BooleanConverter.toBooleanWithDefault Parameters

  • key string a key of element to get.
  • defaultValue bool the default value

Returns bool boolean value of the element or default value if conversion is not supported.

func (*StringValueMap) GetAsDateTime

func (c *StringValueMap) GetAsDateTime(key string) time.Time

GetAsDateTime converts map element into a time.Time or returns the current date if conversion is not possible.

see GetAsDateTimeWithDefault
Parameters: key string a key of element to get.
Returns: time.Time value of the element or the current date if conversion is not supported.

func (*StringValueMap) GetAsDateTimeWithDefault

func (c *StringValueMap) GetAsDateTimeWithDefault(key string, defaultValue time.Time) time.Time

GetAsDateTimeWithDefault converts map element into a time.Time or returns default value if conversion is not possible.

see convert.DateTimeConverter.toDateTimeWithDefault
Parameters:
	- key string a key of element to get.
	- defaultValue time.Time the default value
Returns: time.Time value of the element or default value if conversion is not supported.

func (*StringValueMap) GetAsDouble

func (c *StringValueMap) GetAsDouble(key string) float64

GetAsDouble converts map element into a float64 or returns 0 if conversion is not possible.

see GetAsDoubleWithDefault
Parameters: key string a key of element to get.
Returns: value of the element or 0 if conversion is not supported.

func (*StringValueMap) GetAsDoubleWithDefault

func (c *StringValueMap) GetAsDoubleWithDefault(key string, defaultValue float64) float64

GetAsDoubleWithDefault converts map element into a float64 or returns default value if conversion is not possible.

see convert.DoubleConverter.toDoubleWithDefault
Parameters:
	- key string a key of element to get.
	- defaultValue float64 the default value
Returns: float64 value of the element or default value if conversion is not supported.

func (*StringValueMap) GetAsFloat

func (c *StringValueMap) GetAsFloat(key string) float32

GetAsFloat converts map element into a float32 or returns 0 if conversion is not possible.

see GetAsFloatWithDefault
Parameters: key string a key of element to get.
Returns: float32 value of the element or 0 if conversion is not supported.

func (*StringValueMap) GetAsFloatWithDefault

func (c *StringValueMap) GetAsFloatWithDefault(key string, defaultValue float32) float32

GetAsFloatWithDefault converts map element into a float32 or returns default value if conversion is not possible.

see convert.FloatConverter.toFloatWithDefault
Parameters:
	- key string a key of element to get.
	- defaultValue: float32 the default value
Returns: float32 value of the element or default value if conversion is not supported.

func (*StringValueMap) GetAsInteger

func (c *StringValueMap) GetAsInteger(key string) int

GetAsInteger converts map element into an integer or returns 0 if conversion is not possible.

see GetAsIntegerWithDefault
Parameters: key string a key of element to get.
Returns: int

func (*StringValueMap) GetAsIntegerWithDefault

func (c *StringValueMap) GetAsIntegerWithDefault(key string, defaultValue int) int

GetAsIntegerWithDefault converts map element into an integer or returns default value if conversion is not possible.

see convert.IntegerConverter.toIntegerWithDefault
Parameters:
	- key string a key of element to get.
	- defaultValue int the default value
Returns: integer value of the element or default value if conversion is not supported.

func (*StringValueMap) GetAsLong

func (c *StringValueMap) GetAsLong(key string) int64

GetAsLong converts map element into a int64 or returns 0 if conversion is not possible.

see GetAsLongWithDefault
Parameters: key string a key of element to get.
Returns: int64 value of the element or 0 if conversion is not supported.

func (*StringValueMap) GetAsLongWithDefault

func (c *StringValueMap) GetAsLongWithDefault(key string, defaultValue int64) int64

GetAsLongWithDefault converts map element into a int64 or returns default value if conversion is not possible.

see convert.LongConverter.toLongWithDefault
Parameters:
	- key string a key of element to get.
	- defaultValue int64 the default value
Returns: value of the element or default value if conversion is not supported.

func (*StringValueMap) GetAsMap

func (c *StringValueMap) GetAsMap(key string) *AnyValueMap

GetAsMap converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.

see NewAnyValueMapFromValue
Parameters: key string a key of element to get.
Returns: *AnyValueMap value of the element or empty AnyValueMap if conversion is not supported.

func (*StringValueMap) GetAsMapWithDefault

func (c *StringValueMap) GetAsMapWithDefault(key string, defaultValue *AnyValueMap) *AnyValueMap

GetAsMapWithDefault converts map element into an AnyValueMap or returns default value if conversion is not possible.

see GetAsNullableMap
Parameters:
	- key string a key of element to get.
	- defaultValue *AnyValueMap the default value
Returns: *AnyValueMap value of the element or default value if conversion is not supported.

func (*StringValueMap) GetAsNullableArray

func (c *StringValueMap) GetAsNullableArray(key string) (*AnyValueArray, bool)

GetAsNullableArray converts map element into an AnyValueArray or returns null if conversion is not possible.

see AnyValueArray
see NewAnyValueArrayFromValue
Parameters: key string a key of element to get.
Returns: *AnyValueArray value of the element or nil if conversion is not supported.

func (*StringValueMap) GetAsNullableBoolean

func (c *StringValueMap) GetAsNullableBoolean(key string) (bool, bool)

GetAsNullableBoolean converts map element into a boolean or returns null if conversion is not possible.

see convert.BooleanConverter.toNullableBoolean
Parameters:  key string a key of element to get.
Returns: boolean value of the element or null if conversion is not supported.

func (*StringValueMap) GetAsNullableDateTime

func (c *StringValueMap) GetAsNullableDateTime(key string) (time.Time, bool)

GetAsNullableDateTime converts map element into a time.Time or returns null if conversion is not possible.

see convert.DateTimeConverter.toNullableDateTime
Parameters: key string a key of element to get.
Returns: time.Time value of the element or null if conversion is not supported.

func (*StringValueMap) GetAsNullableDouble

func (c *StringValueMap) GetAsNullableDouble(key string) (float64, bool)

GetAsNullableDouble converts map element into a float64 or returns null if conversion is not possible.

see convert.DoubleConverter.toNullableDouble
Parameters: key string a key of element to get.
Returns: float64 value of the element or null if conversion is not supported.

func (*StringValueMap) GetAsNullableFloat

func (c *StringValueMap) GetAsNullableFloat(key string) (float32, bool)

GetAsNullableFloat converts map element into a float32 or returns null if conversion is not possible.

see convert.FloatConverter.toNullableFloat
Parameters: key string a key of element to get.
Returns: float32 value of the element or null if conversion is not supported.

func (*StringValueMap) GetAsNullableInteger

func (c *StringValueMap) GetAsNullableInteger(key string) (int, bool)

GetAsNullableInteger converts map element into an integer or returns null if conversion is not possible.

see convert.IntegerConverter.toNullableInteger
Parameters: key string a key of element to get.
Returns: integer value of the element or null if conversion is not supported.

func (*StringValueMap) GetAsNullableLong

func (c *StringValueMap) GetAsNullableLong(key string) (int64, bool)

GetAsNullableLong converts map element into a int64 or returns null if conversion is not possible.

see convert.LongConverter.toNullableLong
Parameters: key string a key of element to get.
Returns: int64 value of the element or null if conversion is not supported.

func (*StringValueMap) GetAsNullableMap

func (c *StringValueMap) GetAsNullableMap(key string) (*AnyValueMap, bool)

GetAsNullableMap converts map element into an AnyValueMap or returns null if conversion is not possible.

see NewAnyValueMapFromValue
Parameters: key string a key of element to get.
Returns: *AnyValueMap value of the element or nil if conversion is not supported.

func (*StringValueMap) GetAsNullableString

func (c *StringValueMap) GetAsNullableString(key string) (string, bool)

GetAsNullableString converts map element into a string or returns null if conversion is not possible.

see StringConverter.ToNullableString
Parameters: key string a key of element to get.
Returns: string value of the element or null if conversion is not supported.

func (*StringValueMap) GetAsNullableUInteger added in v1.0.4

func (c *StringValueMap) GetAsNullableUInteger(key string) (uint, bool)

GetAsNullableUInteger converts map element into an unsigned integer or returns null if conversion is not possible.

see IntegerConverter.ToNullableInteger
Parameters: key string a key of element to get.
Returns: unsigned integer value of the element or o and false if conversion is not supported.

func (*StringValueMap) GetAsNullableULong added in v1.0.4

func (c *StringValueMap) GetAsNullableULong(key string) (uint64, bool)

GetAsNullableULong converts map element into a uint64 or returns null if conversion is not possible. see convert.LongConverter.ToNullableLong

Parameters: key string a key of element to get.
Returns: int64 value of the element or false if conversion is not supported.

func (*StringValueMap) GetAsObject

func (c *StringValueMap) GetAsObject(key string) (any, bool)

GetAsObject gets the value stored in map element without any conversions. When element key is not defined it returns the entire map value.

Parameters: key string a key of the element to get
Returns: any the element value or value of the map when index is not defined.

func (*StringValueMap) GetAsSingleObject

func (c *StringValueMap) GetAsSingleObject() any

GetAsSingleObject Gets the value stored in map element without any conversions. When element index is not defined it returns the entire array value.

Returns: any the element value or value of the array when index is not defined.

func (*StringValueMap) GetAsString

func (c *StringValueMap) GetAsString(key string) string

GetAsString converts map element into a string or returns "" if conversion is not possible.

see GetAsStringWithDefault
Parameters: key string a key of element to get.
Returns: string value of the element or "" if conversion is not supported.

func (*StringValueMap) GetAsStringWithDefault

func (c *StringValueMap) GetAsStringWithDefault(key string, defaultValue string) string

GetAsStringWithDefault converts map element into a string or returns default value if conversion is not possible.

see convert.StringConverter.toStringWithDefault
Parameters:
	- key string a key of element to get.
	- defaultValue string the default value
Returns: string value of the element or default value if conversion is not supported.

func (*StringValueMap) GetAsUInteger added in v1.0.4

func (c *StringValueMap) GetAsUInteger(key string) uint

GetAsUInteger converts map element into an unsigned integer or returns 0 if conversion is not possible.

see GetAsIntegerWithDefault
Parameters: key string a key of element to get.
Returns uint

func (*StringValueMap) GetAsUIntegerWithDefault added in v1.0.4

func (c *StringValueMap) GetAsUIntegerWithDefault(key string, defaultValue uint) uint

GetAsUIntegerWithDefault converts map element into an unsigned integer or returns default value if conversion is not possible.

see IntegerConverter.ToIntegerWithDefault
Parameters:
	- key string a key of element to get.
	- defaultValue uint the default value
Returns uint integer value of the element or default value if conversion is not supported.

func (*StringValueMap) GetAsULong added in v1.0.4

func (c *StringValueMap) GetAsULong(key string) uint64

GetAsULong converts map element into a uint64 or returns 0 if conversion is not possible.

see GetAsULongWithDefault
Parameters: key string a key of element to get.
Returns: uint64 value of the element or 0 if conversion is not supported.

func (*StringValueMap) GetAsULongWithDefault added in v1.0.4

func (c *StringValueMap) GetAsULongWithDefault(key string, defaultValue uint64) uint64

GetAsULongWithDefault converts map element into a uint64 or returns default value if conversion is not possible.

see convert.LongConverter.ToULongWithDefault
Parameters:
	- key string a key of element to get.
	- defaultValue uint64 the default value
Returns: uint64 value of the element or default value if conversion is not supported.

func (*StringValueMap) GetAsValue

func (c *StringValueMap) GetAsValue(key string) *AnyValue

GetAsValue converts map element into an AnyValue or returns an empty AnyValue if conversion is not possible.

see AnyValue
Parameters: key string a key of element to get.
Returns: *AnyValue value of the element or empty AnyValue if conversion is not supported.

func (*StringValueMap) InnerValue

func (c *StringValueMap) InnerValue() any

InnerValue return inner values of map as any

func (*StringValueMap) Keys

func (c *StringValueMap) Keys() []string

Keys gets keys of all elements stored in this map.

Returns: []string a list with all map keys.

func (*StringValueMap) Len

func (c *StringValueMap) Len() int

Len gets a number of elements stored in this map.

Returns: int the number of elements in this map.

func (*StringValueMap) MarshalJSON

func (c *StringValueMap) MarshalJSON() ([]byte, error)

func (*StringValueMap) Put

func (c *StringValueMap) Put(key string, value any)

Put a new value into map element specified by its key.

Parameters:
	- key string a key of the element to put.
	- value any a new value for map element.

func (*StringValueMap) Remove

func (c *StringValueMap) Remove(key string)

Remove a map element specified by its key

Parameters: key string a key of the element to remove.

func (*StringValueMap) SetAsObject

func (c *StringValueMap) SetAsObject(key string, value any)

SetAsObject sets a new value to map element specified by its index. When the index is not defined, it resets the entire map value.

Parameters:
	- key any a key of the element to set
	- value any a new element or map value.

func (*StringValueMap) SetAsSingleObject

func (c *StringValueMap) SetAsSingleObject(value any)

SetAsSingleObject sets a new value to map.

Parameters: value any a new element or array value.

func (*StringValueMap) String

func (c *StringValueMap) String() string

String gets a string representation of the object. The result is a semicolon-separated list of key-value pairs as "key1=value1;key2=value2;key=value3"

Returns: a string representation of the object.

func (*StringValueMap) UnmarshalJSON

func (c *StringValueMap) UnmarshalJSON(data []byte) error

func (*StringValueMap) Value

func (c *StringValueMap) Value() map[string]string

Value returns map of elements as map[string]any

type TokenizedDataPage added in v1.0.4

type TokenizedDataPage[T any] struct {
	Token string `json:"token"`
	Data  []T    `json:"data"`
}

TokenizedDataPage is a data transfer object that is used to pass results of paginated queries. It contains items of retrieved page and optional total number of items. Most often this object type is used to send responses to paginated queries. Pagination parameters are defined by TokenizedPagingParams object. The token parameter in the TokenizedPagingParams there determines a starting point for a new search. It is received in the TokenizedDataPage from the previous search. The takes parameter sets number of items to return to the page. And the optional total parameter tells to return total number of items in the query. Remember: not all implementations support the total parameter because its generation may lead to severe performance implications.

see TokenizedPagingParams

Example:
	page, err := myDataClient.GetDataByFilter(
		context.Background(),
		"123",
		FilterParams.fromTuples("completed": true),
		NewTokenizedPagingParams("", 100, true),
	);

	if err != nil {
		panic(err)
	}
	for item range page.Data {
		fmt.Println(item);
	}

func NewEmptyTokenizedDataPage added in v1.0.4

func NewEmptyTokenizedDataPage[T any]() *TokenizedDataPage[T]

NewEmptyTokenizedDataPage creates a new empty instance of data page.

Returns: *TokenizedDataPage[T]

func NewTokenizedDataPage added in v1.0.4

func NewTokenizedDataPage[T any](token string, data []T) *TokenizedDataPage[T]

NewTokenizedDataPage creates a new instance of data page and assigns its values.

Parameters:
	- token a token that defines a starting point for next search
	- data []T a list of items from the retrieved page.
Returns: *TokenizedDataPage[T]

func (*TokenizedDataPage[T]) HasData added in v1.0.4

func (d *TokenizedDataPage[T]) HasData() bool

HasData method check if data exists

func (*TokenizedDataPage[T]) HasToken added in v1.0.4

func (d *TokenizedDataPage[T]) HasToken() bool

HasToken method check if token exists

type TokenizedPagingParams added in v1.0.4

type TokenizedPagingParams struct {
	Token string `json:"token"`
	Take  int64  `json:"take"`
	Total bool   `json:"total"`
}

TokenizedPagingParams Data transfer object to pass paging parameters for queries.

The page is defined by two parameters:
	- the token parameter a starting point for a new page. The token shall be received from previous searches.
	- the take parameter sets how many items to return in a page.

additionally, the optional total parameter tells to return total number of items in the query. Remember: not all implementations support the total parameter because its generation may lead to severe performance implications.

Example:
	filter := NewFilterParamsFromTuples("type", "Type1");
	paging := NewTokenizedPagingParams("", 100);

	err, page = myDataClient.getDataByFilter(filter, paging);

func NewEmptyTokenizedPagingParams added in v1.0.4

func NewEmptyTokenizedPagingParams() *TokenizedPagingParams

NewEmptyTokenizedPagingParams creates a new instance.

Returns: *TokenizedPagingParams

func NewTokenizedPagingParams added in v1.0.4

func NewTokenizedPagingParams(token string, take int64, total bool) *TokenizedPagingParams

NewTokenizedPagingParams creates a new instance and sets its values.

Parameters:
	- token string a token received from previous searches to define a starting point for this search.
	- take int64 the number of items to return.
	- total bool true to return the total number of items.
Returns: *TokenizedPagingParams

func NewTokenizedPagingParamsFromMap added in v1.0.4

func NewTokenizedPagingParamsFromMap(value *AnyValueMap) *TokenizedPagingParams

NewTokenizedPagingParamsFromMap creates a new TokenizedPagingParams and sets it parameters from the specified map

Parameters:
	- value AnyValueMap a AnyValueMap or StringValueMap to initialize this TokenizedPagingParams
Returns: *TokenizedPagingParams a newly created TokenizedPagingParams.

func NewTokenizedPagingParamsFromTuples added in v1.0.4

func NewTokenizedPagingParamsFromTuples(tuples ...any) *TokenizedPagingParams

NewTokenizedPagingParamsFromTuples creates a new TokenizedPagingParams from a list of key-value pairs called tuples.

Parameters
	- tuples ...any a list of values where odd elements are keys and the following even elements are values
Returns: *TokenizedPagingParams a newly created TokenizedPagingParams.

func NewTokenizedPagingParamsFromValue added in v1.0.4

func NewTokenizedPagingParamsFromValue(value any) *TokenizedPagingParams

NewTokenizedPagingParamsFromValue converts specified value into TokenizedPagingParams.

Parameters:
	- value any value to be converted
Returns *TokenizedPagingParams a newly created TokenizedPagingParams.

func (*TokenizedPagingParams) GetTake added in v1.0.4

func (c *TokenizedPagingParams) GetTake(maxTake int64) int64

GetTake the number of items to return in a page.

Parameters:
	- maxTake int64 the maximum number of items to return.
Returns: int64 the number of items to return.

Jump to

Keyboard shortcuts

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