// NOTE: This file is generated by the templates/template.rb script and should not
// be modified manually. See /home/runner/work/herb/herb/templates/rust/src/union_types.rs.erb

use crate::nodes::*;
use crate::errors::ErrorNode;
use crate::Location;

/// Union type for ERBContentNode | LiteralNode
#[derive(Debug, Clone)]
pub enum ERBContentNodeOrLiteralNode {
  ERBContentNode(Box<ERBContentNode>),
  LiteralNode(Box<LiteralNode>),
}

impl ERBContentNodeOrLiteralNode {
  pub fn node_type(&self) -> &str {
    match self {
      ERBContentNodeOrLiteralNode::ERBContentNode(n) => &n.node_type,
      ERBContentNodeOrLiteralNode::LiteralNode(n) => &n.node_type,
    }
  }

  pub fn location(&self) -> &Location {
    match self {
      ERBContentNodeOrLiteralNode::ERBContentNode(n) => &n.location,
      ERBContentNodeOrLiteralNode::LiteralNode(n) => &n.location,
    }
  }

  pub fn as_node(&self) -> &dyn Node {
    match self {
      ERBContentNodeOrLiteralNode::ERBContentNode(n) => n.as_ref(),
      ERBContentNodeOrLiteralNode::LiteralNode(n) => n.as_ref(),
    }
  }

  pub fn tree_inspect(&self) -> String {
    match self {
      ERBContentNodeOrLiteralNode::ERBContentNode(n) => n.tree_inspect(),
      ERBContentNodeOrLiteralNode::LiteralNode(n) => n.tree_inspect(),
    }
  }

  pub fn recursive_errors(&self) -> Vec<&dyn ErrorNode> {
    match self {
      ERBContentNodeOrLiteralNode::ERBContentNode(n) => n.recursive_errors(),
      ERBContentNodeOrLiteralNode::LiteralNode(n) => n.recursive_errors(),
    }
  }
}

/// Union type for ERBElseNode | ERBIfNode
#[derive(Debug, Clone)]
pub enum ERBElseNodeOrERBIfNode {
  ERBElseNode(Box<ERBElseNode>),
  ERBIfNode(Box<ERBIfNode>),
}

impl ERBElseNodeOrERBIfNode {
  pub fn node_type(&self) -> &str {
    match self {
      ERBElseNodeOrERBIfNode::ERBElseNode(n) => &n.node_type,
      ERBElseNodeOrERBIfNode::ERBIfNode(n) => &n.node_type,
    }
  }

  pub fn location(&self) -> &Location {
    match self {
      ERBElseNodeOrERBIfNode::ERBElseNode(n) => &n.location,
      ERBElseNodeOrERBIfNode::ERBIfNode(n) => &n.location,
    }
  }

  pub fn as_node(&self) -> &dyn Node {
    match self {
      ERBElseNodeOrERBIfNode::ERBElseNode(n) => n.as_ref(),
      ERBElseNodeOrERBIfNode::ERBIfNode(n) => n.as_ref(),
    }
  }

  pub fn tree_inspect(&self) -> String {
    match self {
      ERBElseNodeOrERBIfNode::ERBElseNode(n) => n.tree_inspect(),
      ERBElseNodeOrERBIfNode::ERBIfNode(n) => n.tree_inspect(),
    }
  }

  pub fn recursive_errors(&self) -> Vec<&dyn ErrorNode> {
    match self {
      ERBElseNodeOrERBIfNode::ERBElseNode(n) => n.recursive_errors(),
      ERBElseNodeOrERBIfNode::ERBIfNode(n) => n.recursive_errors(),
    }
  }
}

/// Union type for ERBEndNode | HTMLCloseTagNode | HTMLOmittedCloseTagNode | HTMLVirtualCloseTagNode
#[derive(Debug, Clone)]
pub enum ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode {
  ERBEndNode(Box<ERBEndNode>),
  HTMLCloseTagNode(Box<HTMLCloseTagNode>),
  HTMLOmittedCloseTagNode(Box<HTMLOmittedCloseTagNode>),
  HTMLVirtualCloseTagNode(Box<HTMLVirtualCloseTagNode>),
}

impl ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode {
  pub fn node_type(&self) -> &str {
    match self {
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::ERBEndNode(n) => &n.node_type,
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLCloseTagNode(n) => &n.node_type,
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLOmittedCloseTagNode(n) => &n.node_type,
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLVirtualCloseTagNode(n) => &n.node_type,
    }
  }

  pub fn location(&self) -> &Location {
    match self {
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::ERBEndNode(n) => &n.location,
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLCloseTagNode(n) => &n.location,
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLOmittedCloseTagNode(n) => &n.location,
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLVirtualCloseTagNode(n) => &n.location,
    }
  }

  pub fn as_node(&self) -> &dyn Node {
    match self {
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::ERBEndNode(n) => n.as_ref(),
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLCloseTagNode(n) => n.as_ref(),
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLOmittedCloseTagNode(n) => n.as_ref(),
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLVirtualCloseTagNode(n) => n.as_ref(),
    }
  }

  pub fn tree_inspect(&self) -> String {
    match self {
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::ERBEndNode(n) => n.tree_inspect(),
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLCloseTagNode(n) => n.tree_inspect(),
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLOmittedCloseTagNode(n) => n.tree_inspect(),
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLVirtualCloseTagNode(n) => n.tree_inspect(),
    }
  }

  pub fn recursive_errors(&self) -> Vec<&dyn ErrorNode> {
    match self {
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::ERBEndNode(n) => n.recursive_errors(),
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLCloseTagNode(n) => n.recursive_errors(),
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLOmittedCloseTagNode(n) => n.recursive_errors(),
      ERBEndNodeOrHTMLCloseTagNodeOrHTMLOmittedCloseTagNodeOrHTMLVirtualCloseTagNode::HTMLVirtualCloseTagNode(n) => n.recursive_errors(),
    }
  }
}

/// Union type for ERBIfNode | ERBUnlessNode
#[derive(Debug, Clone)]
pub enum ERBIfNodeOrERBUnlessNode {
  ERBIfNode(Box<ERBIfNode>),
  ERBUnlessNode(Box<ERBUnlessNode>),
}

impl ERBIfNodeOrERBUnlessNode {
  pub fn node_type(&self) -> &str {
    match self {
      ERBIfNodeOrERBUnlessNode::ERBIfNode(n) => &n.node_type,
      ERBIfNodeOrERBUnlessNode::ERBUnlessNode(n) => &n.node_type,
    }
  }

  pub fn location(&self) -> &Location {
    match self {
      ERBIfNodeOrERBUnlessNode::ERBIfNode(n) => &n.location,
      ERBIfNodeOrERBUnlessNode::ERBUnlessNode(n) => &n.location,
    }
  }

  pub fn as_node(&self) -> &dyn Node {
    match self {
      ERBIfNodeOrERBUnlessNode::ERBIfNode(n) => n.as_ref(),
      ERBIfNodeOrERBUnlessNode::ERBUnlessNode(n) => n.as_ref(),
    }
  }

  pub fn tree_inspect(&self) -> String {
    match self {
      ERBIfNodeOrERBUnlessNode::ERBIfNode(n) => n.tree_inspect(),
      ERBIfNodeOrERBUnlessNode::ERBUnlessNode(n) => n.tree_inspect(),
    }
  }

  pub fn recursive_errors(&self) -> Vec<&dyn ErrorNode> {
    match self {
      ERBIfNodeOrERBUnlessNode::ERBIfNode(n) => n.recursive_errors(),
      ERBIfNodeOrERBUnlessNode::ERBUnlessNode(n) => n.recursive_errors(),
    }
  }
}

/// Union type for ERBOpenTagNode | HTMLConditionalOpenTagNode | HTMLOpenTagNode
#[derive(Debug, Clone)]
pub enum ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode {
  ERBOpenTagNode(Box<ERBOpenTagNode>),
  HTMLConditionalOpenTagNode(Box<HTMLConditionalOpenTagNode>),
  HTMLOpenTagNode(Box<HTMLOpenTagNode>),
}

impl ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode {
  pub fn node_type(&self) -> &str {
    match self {
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::ERBOpenTagNode(n) => &n.node_type,
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::HTMLConditionalOpenTagNode(n) => &n.node_type,
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::HTMLOpenTagNode(n) => &n.node_type,
    }
  }

  pub fn location(&self) -> &Location {
    match self {
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::ERBOpenTagNode(n) => &n.location,
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::HTMLConditionalOpenTagNode(n) => &n.location,
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::HTMLOpenTagNode(n) => &n.location,
    }
  }

  pub fn as_node(&self) -> &dyn Node {
    match self {
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::ERBOpenTagNode(n) => n.as_ref(),
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::HTMLConditionalOpenTagNode(n) => n.as_ref(),
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::HTMLOpenTagNode(n) => n.as_ref(),
    }
  }

  pub fn tree_inspect(&self) -> String {
    match self {
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::ERBOpenTagNode(n) => n.tree_inspect(),
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::HTMLConditionalOpenTagNode(n) => n.tree_inspect(),
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::HTMLOpenTagNode(n) => n.tree_inspect(),
    }
  }

  pub fn recursive_errors(&self) -> Vec<&dyn ErrorNode> {
    match self {
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::ERBOpenTagNode(n) => n.recursive_errors(),
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::HTMLConditionalOpenTagNode(n) => n.recursive_errors(),
      ERBOpenTagNodeOrHTMLConditionalOpenTagNodeOrHTMLOpenTagNode::HTMLOpenTagNode(n) => n.recursive_errors(),
    }
  }
}

/// Union type for HTMLCloseTagNode | HTMLOmittedCloseTagNode
#[derive(Debug, Clone)]
pub enum HTMLCloseTagNodeOrHTMLOmittedCloseTagNode {
  HTMLCloseTagNode(Box<HTMLCloseTagNode>),
  HTMLOmittedCloseTagNode(Box<HTMLOmittedCloseTagNode>),
}

impl HTMLCloseTagNodeOrHTMLOmittedCloseTagNode {
  pub fn node_type(&self) -> &str {
    match self {
      HTMLCloseTagNodeOrHTMLOmittedCloseTagNode::HTMLCloseTagNode(n) => &n.node_type,
      HTMLCloseTagNodeOrHTMLOmittedCloseTagNode::HTMLOmittedCloseTagNode(n) => &n.node_type,
    }
  }

  pub fn location(&self) -> &Location {
    match self {
      HTMLCloseTagNodeOrHTMLOmittedCloseTagNode::HTMLCloseTagNode(n) => &n.location,
      HTMLCloseTagNodeOrHTMLOmittedCloseTagNode::HTMLOmittedCloseTagNode(n) => &n.location,
    }
  }

  pub fn as_node(&self) -> &dyn Node {
    match self {
      HTMLCloseTagNodeOrHTMLOmittedCloseTagNode::HTMLCloseTagNode(n) => n.as_ref(),
      HTMLCloseTagNodeOrHTMLOmittedCloseTagNode::HTMLOmittedCloseTagNode(n) => n.as_ref(),
    }
  }

  pub fn tree_inspect(&self) -> String {
    match self {
      HTMLCloseTagNodeOrHTMLOmittedCloseTagNode::HTMLCloseTagNode(n) => n.tree_inspect(),
      HTMLCloseTagNodeOrHTMLOmittedCloseTagNode::HTMLOmittedCloseTagNode(n) => n.tree_inspect(),
    }
  }

  pub fn recursive_errors(&self) -> Vec<&dyn ErrorNode> {
    match self {
      HTMLCloseTagNodeOrHTMLOmittedCloseTagNode::HTMLCloseTagNode(n) => n.recursive_errors(),
      HTMLCloseTagNodeOrHTMLOmittedCloseTagNode::HTMLOmittedCloseTagNode(n) => n.recursive_errors(),
    }
  }
}

