object

package
v1.2.35 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

object consists of {@code static} utility methods for operating on objects, or checking certain conditions before operation. These utilities include {@code null}-safe or {@code null}-tolerant methods for computing the hashmap code of an object, returning a string for an object, comparing two objects, and checking if indexes or sub-range values are out-of-bounds.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFromIndexSize

func CheckFromIndexSize(fromIndex, size, length int) int

Checks if the sub-range from {@code fromIndex} (inclusive) to {@code fromIndex + size} (exclusive) is within the bounds of range from {@code 0} (inclusive) to {@code length} (exclusive).

func CheckFromToIndex

func CheckFromToIndex(fromIndex, toIndex, length int) int

Checks if the sub-range from {@code fromIndex} (inclusive) to {@code toIndex} (exclusive) is within the bounds of range from {@code 0} (inclusive) to {@code length} (exclusive).

func CheckIndex

func CheckIndex(index, length int) int

Checks if the {@code index} is within the bounds of the range from {@code 0} (inclusive) to {@code length} (exclusive).

func Compare

func Compare(a, b interface{}, compare Comparator) int

Returns 0 if the arguments are identical and {@code c.compare(a, b)} otherwise. Consequently, if both arguments are {@code null} 0 is returned.

func DeepClone

func DeepClone(obj interface{}) (copy interface{})

DeepCopys returns a interface consisting of the deeply copying elements. just clone public&clonable elems - upper case - name & IsCloneable()==true

func DeepEquals

func DeepEquals(a, b interface{}) bool

DeepEquals Returns {@code true} if the arguments are deeply equal to each other and {@code false} otherwise.

func DumpFuncInfo

func DumpFuncInfo(m interface{}) []byte

DumpFuncInfo returns m's function info

func DumpMethodInfo

func DumpMethodInfo(i interface{}) []byte

获取一个对象的字段和方法

func Equals

func Equals(a, b interface{}) bool

Equals Returns {@code true} if the arguments are equal to each other and {@code false} otherwise.

func GetFunc

func GetFunc() *runtime.Func

func IsCloneable

func IsCloneable(obj interface{}) bool

IsCloneable Returns {@code true} if the arguments are a chan or func field or pointer to chan or func and {@code false} otherwise.

func IsNil

func IsNil(obj interface{}) bool

IsNil returns {@code true} if the provided reference is {@code nil} otherwise returns {@code false}.

func IsNilable

func IsNilable(obj interface{}) (canBeNil bool)

IsNil returns {@code true} if the provided reference can be assigned {@code nil} otherwise returns {@code false}.

func IsZero

func IsZero(obj interface{}) bool

IsZero reports whether a value is a zero value of its kind. If value.Kind() is Struct, it traverses each field of the struct recursively calling IsZero, returning true only if each field's IsZero result is also true.

func NoneNil

func NoneNil(obj interface{}) bool

IsNil returns {@code true} if the provided reference is non-{@code nil} otherwise returns {@code false}.

func RequireEqual

func RequireEqual(actual, expected interface{}, msg ...string) interface{}

RequireNonNil checks that the specified object reference is not {@code nil}. This method is designed primarily for doing parameter validation in methods and constructors

func RequireNonNil

func RequireNonNil(obj interface{}, msg ...string) interface{}

RequireNonNil checks that the specified object reference is not {@code nil}. This method is designed primarily for doing parameter validation in methods and constructors

func RequireNonNull

func RequireNonNull(obj interface{}, msg ...string) interface{}

grammer surgar for RequireNonNil

func RequireNonNullElse

func RequireNonNullElse(obj, defaultObj interface{}) interface{}

RequireNonNullElse returns the first argument if it is non-{@code nil} and otherwise returns the non-{@code nil} second argument.

func RequireNonNullElseGet

func RequireNonNullElseGet(obj interface{}, sup interface{ Get() interface{} }) interface{}

RequireNonNullElseGet returns the first argument if it is non-{@code nil} and returns the non-{@code nil} value of {@code supplier.Get()}.

func ToString

func ToString(o interface{}, nullDefault ...string) string

Returns the result of calling {@code toString} on the first argument if the first argument is not {@code null} and returns the second argument otherwise.

Types

type Comparator

type Comparator interface {
	Compare(a, b interface{}) int
}

type ErrorMissMatch

type ErrorMissMatch error

type ErrorNilPointer

type ErrorNilPointer error

Directories

Path Synopsis
internal
preconditions
Utility methods to check if state or arguments are correct.
Utility methods to check if state or arguments are correct.

Jump to

Keyboard shortcuts

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