func (o *ObjectsMap) GetObjectLink(baseHandle int) int {
	o.mutex.Lock()
	defer o.mutex.Unlock()
	var objectLink int
	if o.objectLink == nil {
		return objectLink
	}
	return o.objectLink[baseHandle]
}
GetObjectLink get linked object handle, defaults to 0 if not found
package enigmahandlers
import (
	"sort"
	"sync"
	"github.com/hashicorp/go-multierror"
	"github.com/pkg/errors"
	"github.com/qlik-oss/gopherciser/helpers"
)
type (
	ObjectsMap struct {
		objects    map[int]*Object
		objectLink map[int]int
		mutex      sync.Mutex
	}
)
func (o *ObjectsMap) GetObject(handle int) (*Object, error) {
	obj := o.Load(handle)
	if obj == nil {
		return nil, ObjectNotFound(handle)
	}
	return obj, nil
}
func (o *ObjectsMap) Load(handle int) *Object {
	o.mutex.Lock()
	defer o.mutex.Unlock()
	if o.objects == nil {
		return nil
	}
	return (o.objects)[handle]
}
func (o *ObjectsMap) Store(handle int, object *Object) {
	o.mutex.Lock()
	defer o.mutex.Unlock()
	if o.objects == nil {
		o.objects = make(map[int]*Object)
	}
	o.objects[handle] = object
}
func (o *ObjectsMap) GetObjectByID(id string) (*Object, error) {
	o.mutex.Lock()
	defer o.mutex.Unlock()
	for _, v := range o.objects {
		if v != nil && v.ID == id {
			return v, nil
		}
	}
	return nil, ObjectIDNotFound(id)
}
func (o *ObjectsMap) GetObjectsOfType(typ ObjectType) []*Object {
	o.mutex.Lock()
	defer o.mutex.Unlock()
	objectList := make([]*Object, 0, len(o.objects))
	for _, v := range o.objects {
		if v.Type == typ {
			local := v
			objectList = append(objectList, local)
		}
	}
	return objectList
}
func (o *ObjectsMap) AddObject(obj *Object) error {
	if o == nil {
		return errors.Errorf("Object map is nil")
	}
	if obj == nil {
		return errors.Errorf("Tried to store nil object in objectmap")
	}
	if obj.Handle < 0 {
		return errors.Errorf("Invalid object handle<%d>", obj.Handle)
	}
	o.Store(obj.Handle, obj)
	return nil
}
func (o *ObjectsMap) RemoveObject(handle int) error {
	if o == nil {
		return errors.Errorf("Object map is nil")
	}
	if handle < 0 {
		return errors.Errorf("Invalid object handle<%d>", handle)
	}
	obj := o.Load(handle)
	o.mutex.Lock()
	defer o.mutex.Unlock()
	delete(o.objects, handle)
	if obj == nil {
		return nil
	}
	if err := obj.Close(); err != nil {
		return errors.WithStack(err)
	}
	return nil
}
func (o *ObjectsMap) ClearObjectsOfType(t ObjectType) ([]int, error) {
	handles := make([]int, 0, len(o.objects))
	for _, v := range o.objects {
		if v != nil && v.Type == t {
			handles = append(handles, v.Handle)
		}
	}
	return handles, errors.WithStack(o.ClearObjects(handles))
}
func (o *ObjectsMap) ClearObjects(handles []int) error {
	var mErr *multierror.Error
	for _, handle := range handles {
		if err := o.ClearObject(handle); err != nil {
			mErr = multierror.Append(mErr, err)
		}
	}
	return errors.WithStack(helpers.FlattenMultiError(mErr))
}
func (o *ObjectsMap) ClearObject(handle int) error {
	err := o.RemoveObject(handle)
	o.RemoveObjectLink(handle)
	return errors.WithStack(err)
}
func (o *ObjectsMap) AddObjectLink(baseHandle, linkedHandle int) {
	o.mutex.Lock()
	defer o.mutex.Unlock()
	if o.objectLink == nil {
		o.objectLink = make(map[int]int)
	}
	o.objectLink[baseHandle] = linkedHandle
}