Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // StringHandler global instance. StringHandler = PutHandler("string", ContentHandler{handleString, remapString}) // IntHandler global instance. IntHandler = PutHandler("int", ContentHandler{handleInt, remapInt}) // UintHandler global instance. UintHandler = PutHandler("uint", ContentHandler{handleUint, remapUint}) // FloatHandler global instance. FloatHandler = PutHandler("float", ContentHandler{handleFloat, remapFloat}) // ComplexHandler global instance. ComplexHandler = PutHandler("complex", ContentHandler{handleComplex, remapComplex}) // UintptrHandler global instance. UintptrHandler = PutHandler("uintptr", ContentHandler{handleUintptr, remapUintptr}) )
Functions ¶
This section is empty.
Types ¶
type Callable ¶
type Callable struct { Passed bool Result interface{} }
The Callable structure allows chaining of function calls (promise like)
func (Callable) Cleanup ¶
func (callable Callable) Cleanup(function func())
Cleanup is the call to end the callable's chain.
func (Callable) OnFail ¶
OnFail calls a function on the failure of a callable
type ContentHandler ¶
type ContentHandler struct { // Handler is the handler. Handler Handler // Mapper is the remapper to `interface{}`. Mapper RemapHandler }
The ContentHandler structure is a registration structure to hold a handler and a remapper.
func PutHandler ¶
func PutHandler(name string, handler ContentHandler) ContentHandler
PutHandler puts a handler into the registered handlers map, registered by name.
type Handler ¶
The Handler is a type for a slice handler function.
type Iterator ¶
type Iterator struct { // The current value. Value interface{} // contains filtered or unexported fields }
The Iterator is a small struct used for handling iterator-like usage. Go itself does not support the while loop, however, we can achieve similar usage recursively.
type List ¶
type List struct {
// contains filtered or unexported fields
}
The List struct is the actual list.
func Map ¶
func Map(list *List, transformer Transformer) *List
The Map function handles mapping for a raw List.
func NewFromPrimitiveSlice ¶
func NewFromPrimitiveSlice(slice interface{}, element interface{}) *List
NewFromPrimitiveSlice handles slice support, however, to avoid the reflect solution to this, we try to handle type assertion ourself.
The parameter element takes the first element.
Note that if the slice is of []interface{}, the New function may be used instead.
func (*List) Iterator ¶
Iterator returns the list's iterator. If it does not exist, it will create a new one.
func (*List) Mappable ¶
func (list *List) Mappable() MappableList
Mappable returns a mappable list from an existing List.
type MappableList ¶
type MappableList struct { // The embedded list. *List }
A MappableList is able to apply a Transformer to it's elements.
func (*MappableList) Filter ¶
func (l *MappableList) Filter(predicate Predicate) MappableList
func (*MappableList) Map ¶
func (l *MappableList) Map(transformer Transformer) *List
The Map function is called on a MappableList to apply the requested Transformer.
type Predicate ¶
type Predicate func(interface{}) bool
The Predicate is a type alias for a function that takes in a parameter and returns a boolean. The predicate is similar to Java's `Predicate<T>`, without the generic usage. This makes the usage of a predicate not necessarily type safe. This also means that the writer of the predicate has to write code that they trust when passing the predicate into the filter.
type RemapHandler ¶
type RemapHandler func(slice interface{}, args ...interface{}) []interface{}
The RemapHandler is the function type for any handler for remapping.
type Transformer ¶
type Transformer func(v interface{}) interface{}
The Transformer is a type alias for a mapping function.