key

package
v0.0.0-...-d002785 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortedKeys

func SortedKeys(m map[string]interface{}) []string

SortedKeys returns the keys of the given map, in a sorted order.

func StringifyInterface

func StringifyInterface(key interface{}) (string, error)

StringifyInterface transforms an arbitrary interface into its string representation. We need to do this because some entities use the string representation of their keys as their names. Note: this API is deprecated and will be removed.

Types

type Comparable

type Comparable interface {
	// Equal returns true if this object is equal to the other one.
	Equal(other interface{}) bool
}

Comparable types have an equality-testing method.

type Key

type Key interface {
	Key() interface{}
	String() string
	Equal(other interface{}) bool

	// GetFromMap returns the value for the entry of this Key.
	GetFromMap(map[Key]interface{}) (interface{}, bool)
	// DeleteFromMap deletes the entry in the map for this Key.
	// This is a no-op if the key does not exist in the map.
	DeleteFromMap(map[Key]interface{})
	// SetToMap updates or inserts an entry in the map for this Key.
	SetToMap(m map[Key]interface{}, value interface{})
}

Key represents the Key in the updates and deletes of the Notification objects. The only reason this exists is that Go won't let us define our own hash function for non-hashable types, and unfortunately we need to be able to index maps by map[string]interface{} objects.

func New

func New(intf interface{}) Key

New wraps the given value in a Key. This function panics if the value passed in isn't allowed in a Key or doesn't implement value.Value.

Jump to

Keyboard shortcuts

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