func (s *EntrySchema) SetChildren(children []*EntrySchema) *EntrySchema {
	s.children = children
	return s
}
SetChildren sets the entry's children. This should only be called by
the tests.
package apitypes
import (
	"encoding/json"
	"fmt"
	"sort"
	"github.com/emirpasic/gods/maps/linkedhashmap"
	"github.com/getlantern/deepcopy"
	"github.com/puppetlabs/wash/plugin"
)
type SignalSchema = plugin.SignalSchema
type EntrySchema struct {
	plugin.EntrySchema
	path     string
	typeID   string
	children []*EntrySchema
	graph *linkedhashmap.Map
}
func NewEntrySchema(s *plugin.EntrySchema) *EntrySchema {
	if s == nil {
		return nil
	}
	return &EntrySchema{
		EntrySchema: (*s),
	}
}
func (s EntrySchema) MarshalJSON() ([]byte, error) {
	if s.graph != nil {
		return s.graph.ToJSON()
	}
	return json.Marshal(s.EntrySchema)
}
func (s *EntrySchema) UnmarshalJSON(data []byte) error {
	rawGraph := linkedhashmap.New()
	if err := rawGraph.FromJSON(data); err != nil {
		return err
	}
	if rawGraph.Size() <= 0 {
		return fmt.Errorf("expected a non-empty JSON object but got %v instead", string(data))
	}
	graph := linkedhashmap.New()
	var err error
	rawGraph.Each(func(key interface{}, value interface{}) {
		if err != nil {
			return
		}
		var schema plugin.EntrySchema
		err = deepcopy.Copy(&schema, value.(map[string]interface{}))
		if err != nil {
			return
		}
		if len(schema.Label) <= 0 {
			err = fmt.Errorf("label for %v was not provided", key.(string))
			return
		}
		graph.Put(key, schema)
	})
	if err != nil {
		return err
	}
	var fillStree func(string, string, map[string]*EntrySchema) *EntrySchema
	fillStree = func(path string, typeID string, visited map[string]*EntrySchema) *EntrySchema {
		if node, ok := visited[typeID]; ok {
			return node
		}
		schema, _ := graph.Get(typeID)
		node := &EntrySchema{
			EntrySchema: schema.(plugin.EntrySchema),
			typeID:      typeID,
			path:        path,
		}
		if len(path) <= 0 {
			node.path = node.Label()
		} else {
			node.path = path + "/" + node.Label()
		}
		visited[typeID] = node
		for _, childTypeID := range node.EntrySchema.Children {
			node.children = append(node.children, fillStree(node.path, childTypeID, visited))
		}
		delete(visited, typeID)
		return node
	}
	it := graph.Iterator()
	it.First()
	root := fillStree("", it.Key().(string), make(map[string]*EntrySchema))
	(*s) = (*root)
	s.graph = graph
	return nil
}
func (s *EntrySchema) Path() string {
	return s.path
}
func (s *EntrySchema) SetPath(path string) *EntrySchema {
	s.path = path
	return s
}
func (s *EntrySchema) TypeID() string {
	return s.typeID
}
func (s *EntrySchema) SetTypeID(typeID string) *EntrySchema {
	s.typeID = typeID
	return s
}
func (s *EntrySchema) Label() string {
	return s.EntrySchema.Label
}
func (s *EntrySchema) Description() string {
	return s.EntrySchema.Description
}
func (s *EntrySchema) SetDescription(description string) *EntrySchema {
	s.EntrySchema.Description = description
	return s
}
func (s *EntrySchema) Signals() []SignalSchema {
	return s.EntrySchema.Signals
}
func (s *EntrySchema) SetSignals(signals []SignalSchema) *EntrySchema {
	s.EntrySchema.Signals = signals
	return s
}
func (s *EntrySchema) Singleton() bool {
	return s.EntrySchema.Singleton
}
func (s *EntrySchema) Actions() []string {
	return s.EntrySchema.Actions
}
func (s *EntrySchema) SetActions(actions []string) *EntrySchema {
	s.EntrySchema.Actions = actions
	return s
}
func (s *EntrySchema) PartialMetadataSchema() *plugin.JSONSchema {
	return s.EntrySchema.PartialMetadataSchema
}
func (s *EntrySchema) SetPartialMetadataSchema(schema *plugin.JSONSchema) {
	s.EntrySchema.PartialMetadataSchema = schema
}
func (s *EntrySchema) MetadataSchema() *plugin.JSONSchema {
	return s.EntrySchema.MetadataSchema
}
func (s *EntrySchema) SetMetadataSchema(schema *plugin.JSONSchema) {
	s.EntrySchema.MetadataSchema = schema
}
func (s *EntrySchema) Children() []*EntrySchema {
	return s.children
}
func (s *EntrySchema) GetChild(typeID string) *EntrySchema {
	for _, child := range s.Children() {
		if child.TypeID() == typeID {
			return child
		}
	}
	return nil
}