// Code generated by node-gen. DO NOT EDIT.
// SPDX-License-Identifier: AGPL-3.0-only

package splitandcache

import (
	"fmt"

	"github.com/grafana/mimir/pkg/streamingpromql/planning"
)

func (c *Cache) Child(idx int) planning.Node {
	if idx != 0 {
		panic(fmt.Sprintf("node of type Cache supports 1 child, but attempted to get child at index %d", idx))
	}
	return c.Inner
}

func (c *Cache) ChildCount() int {
	return 1
}

func (c *Cache) SetChildren(children []planning.Node) error {
	if len(children) != 1 {
		return fmt.Errorf("node of type Cache expects one child, but got %d", len(children))
	}
	c.Inner = children[0]
	return nil
}

func (c *Cache) ReplaceChild(idx int, node planning.Node) error {
	if idx != 0 {
		return fmt.Errorf("node of type Cache supports 1 child, but attempted to replace child at index %d", idx)
	}
	c.Inner = node
	return nil
}

func (c *Cache) ChildrenLabels() []string {
	return []string{""}
}

func (c *Cache) EquivalentToIgnoringHintsAndChildren(other planning.Node) bool {
	oi, ok := other.(*Cache)
	return ok &&
		c.SplitInterval == oi.SplitInterval
}

func (t *TimeRangeSplit) Child(idx int) planning.Node {
	if idx != 0 {
		panic(fmt.Sprintf("node of type TimeRangeSplit supports 1 child, but attempted to get child at index %d", idx))
	}
	return t.Inner
}

func (t *TimeRangeSplit) ChildCount() int {
	return 1
}

func (t *TimeRangeSplit) SetChildren(children []planning.Node) error {
	if len(children) != 1 {
		return fmt.Errorf("node of type TimeRangeSplit expects one child, but got %d", len(children))
	}
	t.Inner = children[0]
	return nil
}

func (t *TimeRangeSplit) ReplaceChild(idx int, node planning.Node) error {
	if idx != 0 {
		return fmt.Errorf("node of type TimeRangeSplit supports 1 child, but attempted to replace child at index %d", idx)
	}
	t.Inner = node
	return nil
}

func (t *TimeRangeSplit) ChildrenLabels() []string {
	return []string{""}
}

func (t *TimeRangeSplit) EquivalentToIgnoringHintsAndChildren(other planning.Node) bool {
	oi, ok := other.(*TimeRangeSplit)
	return ok &&
		t.SplitInterval == oi.SplitInterval
}
