implementation

package
v2.7.7+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2019 License: MIT Imports: 4 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DictionaryHelper collections.IDictionaryHelper = baseDictHelper

DictionaryHelper gives public access to the basic dictionary functions

View Source
var GenericListHelper collections.IListHelper = baseListHelper

GenericListHelper gives public access to the basic list functions

Functions

func NeedConversion

func NeedConversion(object interface{}, strict bool, typeName string) bool

NeedConversion determine if the object need deep conversion.

strict indicates that the type must be converted to the desired type
even if the object implements the Dictionary or List interface.

Types

type BaseHelper

type BaseHelper struct {
	ConvertList    func(list baseIList) baseIList
	ConvertDict    func(dict baseIDict) baseIDict
	NeedConversion func(object interface{}, strict bool) bool
}

BaseHelper implements basic functionalities required for both IGenericList & IDictionary

func (BaseHelper) AsDictionary

func (bh BaseHelper) AsDictionary(object interface{}) baseIDict

AsDictionary converts object to IDictionary object. It panics if conversion is impossible.

func (BaseHelper) AsList

func (bh BaseHelper) AsList(object interface{}) baseIList

AsList converts object to IGenericList object. It panics if conversion is impossible.

func (BaseHelper) Convert

func (bh BaseHelper) Convert(object interface{}) interface{}

Convert tries to convert the supplied object into IDictionary or IGenericList. Returns the supplied object if not conversion occurred.

func (BaseHelper) CreateDictionary

func (bh BaseHelper) CreateDictionary(args ...int) baseIDict

CreateDictionary creates a new IDictionary with optional capacity arguments.

func (BaseHelper) CreateList

func (bh BaseHelper) CreateList(args ...int) baseIList

CreateList creates a new IGenericList with optional size/capacity arguments.

func (BaseHelper) NewList

func (bh BaseHelper) NewList(items ...interface{}) baseIList

NewList creates a new IGenericList from supplied arguments.

func (BaseHelper) NewStringList

func (bh BaseHelper) NewStringList(items ...string) baseIList

NewStringList creates a new IGenericList from supplied arguments.

func (BaseHelper) TryAsDictionary

func (bh BaseHelper) TryAsDictionary(object interface{}) (baseIDict, error)

TryAsDictionary tries to convert any object to IDictionary object.

func (BaseHelper) TryAsDictionaryStrict

func (bh BaseHelper) TryAsDictionaryStrict(object interface{}) (baseIDict, error)

TryAsDictionaryStrict tries to convert any object to IDictionary object.

func (BaseHelper) TryAsList

func (bh BaseHelper) TryAsList(object interface{}) (baseIList, error)

TryAsList tries to convert any object to IGenericList object.

func (BaseHelper) TryAsListStrict

func (bh BaseHelper) TryAsListStrict(object interface{}) (baseIList, error)

TryAsListStrict tries to convert any object to IGenericList object.

func (BaseHelper) TryConvert

func (bh BaseHelper) TryConvert(object interface{}) (interface{}, bool)

TryConvert tries to convert any object to IGenericList or IDictionary object. Returns true if a conversion occurred.

type DictHelper

type DictHelper struct {
	BaseHelper
}

DictHelper implements basic functionalities required for IDictionary.

func (DictHelper) Add

func (dh DictHelper) Add(dict baseIDict, key interface{}, value interface{}) baseIDict

Add adds value to an existing key instead of replacing the value as done by set.

func (DictHelper) AsDictionary

func (dh DictHelper) AsDictionary(object interface{}) baseIDict

AsDictionary returns the object casted as IDictionary.

func (DictHelper) Clone

func (dh DictHelper) Clone(dict baseIDict, keys []interface{}) baseIDict

Clone returns a distinct copy of the object with only supplied keys. If no keys are supplied, all keys from d are copied.

func (DictHelper) Default

func (dh DictHelper) Default(dict baseIDict, key, defVal interface{}) interface{}

Default returns defVal if dictionary doesn't contain key, otherwise, simply returns entry corresponding to key.

func (DictHelper) Delete

func (dh DictHelper) Delete(dict baseIDict, keys []interface{}) (baseIDict, error)

Delete removes the entry value associated with key. The entry must exist.

func (DictHelper) Flush

func (dh DictHelper) Flush(dict baseIDict, keys []interface{}) baseIDict

Flush removes all specified keys from the dictionary. If no key is specified, all keys are removed.

func (DictHelper) Get

func (dh DictHelper) Get(dict baseIDict, keys []interface{}) interface{}

Get returns the value associated with key.

func (DictHelper) GetKeys

func (dh DictHelper) GetKeys(dict baseIDict) baseIList

GetKeys returns the keys in the dictionary in alphabetical order.

func (DictHelper) GetValues

func (dh DictHelper) GetValues(dict baseIDict) baseIList

GetValues returns the values in the dictionary in key alphabetical order.

func (DictHelper) Has

func (dh DictHelper) Has(dict baseIDict, keys []interface{}) bool

Has returns true if the dictionary object contains all the keys.

func (DictHelper) KeysAsString

func (dh DictHelper) KeysAsString(dict baseIDict) collections.StringArray

KeysAsString returns the keys in the dictionary in alphabetical order.

func (DictHelper) Merge

func (dh DictHelper) Merge(target baseIDict, sources []baseIDict) baseIDict

Merge merges the other dictionaries into the current dictionary.

func (DictHelper) Omit

func (dh DictHelper) Omit(dict baseIDict, keys []interface{}) baseIDict

Omit returns a distinct copy of the object including all keys except specified ones.

func (DictHelper) Pop

func (dh DictHelper) Pop(dict baseIDict, keys []interface{}) interface{}

Pop returns and remove the objects with the specified keys.

func (DictHelper) Set

func (dh DictHelper) Set(dict baseIDict, key interface{}, value interface{}) baseIDict

Set sets key to value in the dictionary.

func (DictHelper) Transpose

func (dh DictHelper) Transpose(dict baseIDict) baseIDict

Transpose returns a dictionary with values as keys and keys as values. The resulting dictionary is a dictionary where each key could contains single value or list of values if there are multiple matches.

type DictTypeName

type DictTypeName = baseDict

DictTypeName implementation of IDictionary for baseDict

type ListHelper

type ListHelper struct {
	BaseHelper
}

ListHelper implements basic functionalities required for IGenericList.

func (ListHelper) Add

func (lh ListHelper) Add(list baseIList, prepend bool, objects ...interface{}) baseIList

Add adds elements at the end of the supplied list.

func (ListHelper) Clone

func (lh ListHelper) Clone(list baseIList) baseIList

Clone returns a copy of the supplied list.

func (ListHelper) Contains

func (lh ListHelper) Contains(list baseIList, values ...interface{}) bool

Contains indicates if the list contains all specified elements

func (ListHelper) GetIndexes

func (lh ListHelper) GetIndexes(list baseIList, indexes ...int) interface{}

GetIndexes returns the element at position index in the list. If index is out of bound, nil is returned.

func (ListHelper) GetStringArray

func (lh ListHelper) GetStringArray(list baseIList) strArray

GetStringArray returns a StringArray representation of the list.

func (ListHelper) GetStrings

func (lh ListHelper) GetStrings(list baseIList) []string

GetStrings returns a string array representation of the list.

func (ListHelper) Intersect

func (lh ListHelper) Intersect(list baseIList, values ...interface{}) baseIList

Intersect returns a new list that is the result of the intersection of the list and the parameters.

func (ListHelper) Remove

func (lh ListHelper) Remove(list baseIList, indexes ...int) baseIList

Remove returns a new list without the element specified.

func (ListHelper) Reverse

func (lh ListHelper) Reverse(list baseIList) baseIList

Reverse returns a copy of the current list in reverse order.

func (ListHelper) SetIndex

func (lh ListHelper) SetIndex(list baseIList, index int, value interface{}) (baseIList, error)

SetIndex sets the value at position index into the list. If list is not large enough, it is enlarged to fit the index.

func (ListHelper) Unique

func (lh ListHelper) Unique(list baseIList) baseIList

Unique returns a copy of the list removing all duplicate elements.

func (ListHelper) Without

func (lh ListHelper) Without(list baseIList, values ...interface{}) baseIList

Without returns a copy of the list removing specified elements.

type ListTypeName

type ListTypeName = baseList

ListTypeName implementation of IGenericList for baseList

Jump to

Keyboard shortcuts

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