coredynamic

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: MIT Imports: 15 Imported by: 72

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyToReflectVal added in v0.6.9

func AnyToReflectVal(any interface{}) reflect.Value

func LengthOfReflect

func LengthOfReflect(reflectVal reflect.Value) int

func MapKeysStringSlice added in v0.6.9

func MapKeysStringSlice(reflectVal reflect.Value) ([]string, error)

func MapKeysStringSliceAny added in v0.6.9

func MapKeysStringSliceAny(any interface{}) ([]string, error)

func MapKeysStringSliceAnyMust added in v0.6.9

func MapKeysStringSliceAnyMust(any interface{}) []string

func MapKeysStringSliceAnySorted added in v0.6.9

func MapKeysStringSliceAnySorted(any interface{}) ([]string, error)

func MapKeysStringSliceAnySortedMust added in v0.6.9

func MapKeysStringSliceAnySortedMust(any interface{}) []string

func SliceItemsAsStrings added in v0.6.9

func SliceItemsAsStrings(reflectVal reflect.Value) ([]string, error)

func SliceItemsAsStringsAny added in v0.6.9

func SliceItemsAsStringsAny(any interface{}) ([]string, error)

func SliceItemsAsStringsAnyMust added in v0.6.9

func SliceItemsAsStringsAnyMust(any interface{}) []string

func SliceItemsProcessorAsStrings added in v0.6.9

func SliceItemsProcessorAsStrings(
	reflectVal reflect.Value,
	processor func(index int, item interface{}) (result string, isTake, isBreak bool),
) ([]string, error)

func SliceItemsSimpleProcessorAsStrings added in v0.6.9

func SliceItemsSimpleProcessorAsStrings(
	reflectVal reflect.Value,
	isSkipEmpty bool,
	processor func(index int, item interface{}) (result string),
) ([]string, error)

Types

type Collection

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

func EmptyDynamicCollection

func EmptyDynamicCollection() *Collection

func NewDynamicCollection

func NewDynamicCollection(capacity int) *Collection

func (*Collection) Add

func (receiver *Collection) Add(dynamic Dynamic) *Collection

func (*Collection) AddAny

func (receiver *Collection) AddAny(anyItem interface{}, isValid bool) *Collection

func (*Collection) AddAnyMany

func (receiver *Collection) AddAnyMany(anyItems ...interface{}) *Collection

func (*Collection) AddAnyNonNull

func (receiver *Collection) AddAnyNonNull(anyItem interface{}, isValid bool) *Collection

func (*Collection) AddManyPtr

func (receiver *Collection) AddManyPtr(dynamicItems ...*Dynamic) *Collection

func (*Collection) AddNonEmpty

func (receiver *Collection) AddNonEmpty(dynamic *Dynamic) *Collection

func (*Collection) AddPtr

func (receiver *Collection) AddPtr(dynamic *Dynamic) *Collection

func (*Collection) At

func (receiver *Collection) At(index int) *Dynamic

func (*Collection) Count

func (receiver *Collection) Count() int

func (*Collection) HasAnyItem

func (receiver *Collection) HasAnyItem() bool

func (*Collection) HasIndex

func (receiver *Collection) HasIndex(index int) bool

func (*Collection) IsEmpty

func (receiver *Collection) IsEmpty() bool

func (*Collection) Items

func (receiver *Collection) Items() *[]*Dynamic

func (*Collection) LastIndex

func (receiver *Collection) LastIndex() int

func (*Collection) Length

func (receiver *Collection) Length() int

func (*Collection) ListStrings

func (receiver *Collection) ListStrings() []string

func (*Collection) ListStringsPtr

func (receiver *Collection) ListStringsPtr() *[]string

func (*Collection) MarshalJSON

func (receiver *Collection) MarshalJSON() ([]byte, error)

func (*Collection) RemoveAt

func (receiver *Collection) RemoveAt(index int) (isSuccess bool)

func (*Collection) String

func (receiver *Collection) String() string

func (*Collection) StringJson

func (receiver *Collection) StringJson() (jsonString string, err error)

func (*Collection) StringJsonMust

func (receiver *Collection) StringJsonMust() string

func (*Collection) UnmarshalJSON

func (receiver *Collection) UnmarshalJSON(data []byte) error

type Dynamic

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

func InvalidDynamic added in v0.5.1

func InvalidDynamic() Dynamic

func InvalidDynamicPtr added in v0.5.1

func InvalidDynamicPtr() *Dynamic

func NewDynamic

func NewDynamic(
	data interface{},
	isValid bool,
) Dynamic

func NewDynamicPtr

func NewDynamicPtr(
	data interface{},
	isValid bool,
) *Dynamic

func NewDynamicValid added in v0.6.5

func NewDynamicValid(
	data interface{},
) Dynamic

func (*Dynamic) Clone added in v0.5.1

func (receiver *Dynamic) Clone() *Dynamic

func (*Dynamic) ConvertUsingFunc

func (receiver *Dynamic) ConvertUsingFunc(
	converter SimpleInOutConverter,
	expectedType reflect.Type,
) *SimpleResult

func (*Dynamic) Data

func (receiver *Dynamic) Data() interface{}

func (*Dynamic) Float64

func (receiver *Dynamic) Float64() (val float64, err error)

func (*Dynamic) IntDefault

func (receiver *Dynamic) IntDefault(defaultInt int) (val int, isSuccess bool)

func (*Dynamic) IsFunc added in v0.4.6

func (receiver *Dynamic) IsFunc() bool

func (*Dynamic) IsInvalid

func (receiver *Dynamic) IsInvalid() bool

func (*Dynamic) IsMap

func (receiver *Dynamic) IsMap() bool

func (*Dynamic) IsNull

func (receiver *Dynamic) IsNull() bool

func (*Dynamic) IsNumber

func (receiver *Dynamic) IsNumber() bool

IsNumber true if float (any), byte, int (any), uint(any)

func (*Dynamic) IsPointer

func (receiver *Dynamic) IsPointer() bool

func (*Dynamic) IsPrimitive

func (receiver *Dynamic) IsPrimitive() bool

func (*Dynamic) IsReflectKind

func (receiver *Dynamic) IsReflectKind(checkingKind reflect.Kind) bool

func (*Dynamic) IsReflectTypeOf

func (receiver *Dynamic) IsReflectTypeOf(
	typeRequest reflect.Type,
) bool

func (*Dynamic) IsSliceOrArray

func (receiver *Dynamic) IsSliceOrArray() bool

func (*Dynamic) IsSliceOrArrayOrMap added in v0.4.6

func (receiver *Dynamic) IsSliceOrArrayOrMap() bool

func (*Dynamic) IsStruct

func (receiver *Dynamic) IsStruct() bool

func (*Dynamic) IsStructStringNullOrEmpty

func (receiver *Dynamic) IsStructStringNullOrEmpty() bool

func (*Dynamic) IsStructStringNullOrEmptyOrWhitespace

func (receiver *Dynamic) IsStructStringNullOrEmptyOrWhitespace() bool

func (*Dynamic) IsValid

func (receiver *Dynamic) IsValid() bool

func (*Dynamic) IsValueType

func (receiver *Dynamic) IsValueType() bool

func (*Dynamic) JsonBytes

func (receiver *Dynamic) JsonBytes() (jsonBytesPtr []byte, err error)

func (*Dynamic) JsonBytesPtr

func (receiver *Dynamic) JsonBytesPtr() (jsonBytesPtr *[]byte, err error)

JsonBytesPtr returns empty string on nil. no error on nil.

func (*Dynamic) Length

func (receiver *Dynamic) Length() int

Length Returns length of a slice, map, array

It will also reduce from pointer

Reference : https://cutt.ly/PnaWAFn | https://cutt.ly/jnaEig8 | https://play.golang.org/p/UCORoShXlv1

func (*Dynamic) MapToKeyVal

func (receiver *Dynamic) MapToKeyVal() (*KeyValCollection, error)

func (*Dynamic) MarshalJSON

func (receiver *Dynamic) MarshalJSON() ([]byte, error)

func (*Dynamic) ReflectKind

func (receiver *Dynamic) ReflectKind() reflect.Kind

func (*Dynamic) ReflectType

func (receiver *Dynamic) ReflectType() reflect.Type

func (*Dynamic) ReflectTypeName

func (receiver *Dynamic) ReflectTypeName() string

func (*Dynamic) ReflectValue

func (receiver *Dynamic) ReflectValue() *reflect.Value

func (*Dynamic) String

func (receiver *Dynamic) String() string

func (*Dynamic) StringJson

func (receiver *Dynamic) StringJson() (jsonString string, err error)

func (*Dynamic) StringJsonMust

func (receiver *Dynamic) StringJsonMust() string

func (*Dynamic) StructString

func (receiver *Dynamic) StructString() string

func (*Dynamic) StructStringPtr

func (receiver *Dynamic) StructStringPtr() *string

func (*Dynamic) UnmarshalJSON

func (receiver *Dynamic) UnmarshalJSON(data []byte) error

func (*Dynamic) Value

func (receiver *Dynamic) Value() interface{}

type DynamicStatus added in v0.4.7

type DynamicStatus struct {
	Dynamic
	Index   int
	Message string
}

func InvalidDynamicStatus added in v0.5.1

func InvalidDynamicStatus(message string) *DynamicStatus

func InvalidDynamicStatusNoMessage added in v0.5.1

func InvalidDynamicStatusNoMessage() *DynamicStatus

func (*DynamicStatus) Clone added in v0.5.1

func (receiver *DynamicStatus) Clone() *DynamicStatus

Clone Warning: Cannot clone dynamic data or interface properly but set it again

If it is a pointer one needs to copy it manually.

type KeyVal

type KeyVal struct {
	Key   interface{}
	Value interface{}
}

func (*KeyVal) KeyDynamic

func (receiver *KeyVal) KeyDynamic() *Dynamic

func (*KeyVal) String

func (receiver *KeyVal) String() string

func (*KeyVal) ValueDynamic

func (receiver *KeyVal) ValueDynamic() *Dynamic

type KeyValCollection

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

func EmptyKeyValCollection

func EmptyKeyValCollection() *KeyValCollection

func MapAsKeyValSlice

func MapAsKeyValSlice(reflectVal reflect.Value) (*KeyValCollection, error)

func NewKeyValCollection

func NewKeyValCollection(capacity int) *KeyValCollection

func (*KeyValCollection) AddMany

func (receiver *KeyValCollection) AddMany(
	keyValues ...*KeyVal,
) *KeyValCollection

func (*KeyValCollection) AddPtr

func (receiver *KeyValCollection) AddPtr(
	keyVal *KeyVal,
) *KeyValCollection

func (*KeyValCollection) HasAnyItem

func (receiver *KeyValCollection) HasAnyItem() bool

func (*KeyValCollection) IsEmpty

func (receiver *KeyValCollection) IsEmpty() bool

func (*KeyValCollection) Items

func (receiver *KeyValCollection) Items() *[]*KeyVal

func (*KeyValCollection) Length

func (receiver *KeyValCollection) Length() int

func (*KeyValCollection) String

func (receiver *KeyValCollection) String() string

func (*KeyValCollection) StringJson

func (receiver *KeyValCollection) StringJson() (jsonString string, err error)

func (*KeyValCollection) StringJsonMust

func (receiver *KeyValCollection) StringJsonMust() string

type SimpleInOutConverter

type SimpleInOutConverter func(in interface{}, typeMust reflect.Type) *SimpleResult

type SimpleRequest

type SimpleRequest struct {
	Dynamic
	// contains filtered or unexported fields
}

func InvalidSimpleRequest added in v0.5.1

func InvalidSimpleRequest(
	message string,
) *SimpleRequest

func InvalidSimpleRequestNoMessage added in v0.5.1

func InvalidSimpleRequestNoMessage() *SimpleRequest

func NewSimpleRequest

func NewSimpleRequest(
	request interface{},
	isValid bool,
	message string,
) *SimpleRequest

func NewSimpleRequestValid added in v0.6.5

func NewSimpleRequestValid(
	request interface{},
) *SimpleRequest

func (*SimpleRequest) GetErrorOnTypeMismatch

func (receiver *SimpleRequest) GetErrorOnTypeMismatch(
	typeMatch reflect.Type,
	isIncludeInvalidMessage bool,
) error

func (*SimpleRequest) InvalidError

func (receiver *SimpleRequest) InvalidError() error

func (*SimpleRequest) IsPointer

func (receiver *SimpleRequest) IsPointer() bool

func (*SimpleRequest) IsReflectKind

func (receiver *SimpleRequest) IsReflectKind(checkingKind reflect.Kind) bool

func (*SimpleRequest) Message added in v0.5.1

func (receiver *SimpleRequest) Message() string

func (*SimpleRequest) Request

func (receiver *SimpleRequest) Request() interface{}

func (*SimpleRequest) Value

func (receiver *SimpleRequest) Value() interface{}

type SimpleRequestConverter

type SimpleRequestConverter func(request SimpleRequest) *SimpleResult

type SimpleResult

type SimpleResult struct {
	Dynamic
	Result  interface{}
	Message string
	// contains filtered or unexported fields
}

func InvalidSimpleResult added in v0.5.1

func InvalidSimpleResult(
	invalidMessage string,
) *SimpleResult

func InvalidSimpleResultNoMessage added in v0.5.1

func InvalidSimpleResultNoMessage() *SimpleResult

func NewSimpleResult

func NewSimpleResult(
	result interface{},
	isValid bool,
	invalidMessage string,
) *SimpleResult

func NewSimpleResultValid added in v0.6.5

func NewSimpleResultValid(
	result interface{},
) *SimpleResult

func (*SimpleResult) Clone added in v0.5.1

func (receiver *SimpleResult) Clone() *SimpleResult

func (*SimpleResult) GetErrorOnTypeMismatch

func (receiver *SimpleResult) GetErrorOnTypeMismatch(
	typeMatch reflect.Type,
	isIncludeInvalidMessage bool,
) error

func (*SimpleResult) InvalidError

func (receiver *SimpleResult) InvalidError() error

type ValueStatus added in v0.4.7

type ValueStatus struct {
	IsValid bool
	Message string
	Index   int
	Value   interface{}
}

func InvalidValueStatus added in v0.5.1

func InvalidValueStatus(message string) *ValueStatus

func InvalidValueStatusNoMessage added in v0.5.1

func InvalidValueStatusNoMessage() *ValueStatus

Jump to

Keyboard shortcuts

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