package gw.rules uses java.util.NoSuchElementException uses gw.lang.reflect.gs.IGosuClass uses java.util.List class RuleIterator { var _ruleTreeExpander : IRuleTreeExpander var _childTypes : List var _currNode = -1 var _nodeType : Type as readonly RuleTree var _isRoot : boolean as readonly Root construct(nodeType : Type) { this(nodeType, RuleSetCache.Instance) } construct(nodeType : Type, ruleTreeExpander : IRuleTreeExpander) { this(nodeType, ruleTreeExpander, true) } private construct(nodeType : Type, ruleTreeExpander : IRuleTreeExpander, isRoot : boolean) { _isRoot = isRoot _nodeType = nodeType _ruleTreeExpander = ruleTreeExpander _childTypes = _ruleTreeExpander.getRulesForType(nodeType) } public function hasNextSibling() : boolean { return _currNode +1 < _childTypes.Count } public function nextSibling() : IGosuClass { if (!hasNextSibling()) { throw new NoSuchElementException() } _currNode = _currNode +1 return _childTypes[_currNode] } public function hasChildren() : boolean { return _currNode >= 0 and not _ruleTreeExpander.getRulesForType(_childTypes[_currNode]).Empty } public function children() : RuleIterator { return _currNode < 0 ? null : new RuleIterator(_childTypes[_currNode], _ruleTreeExpander, false) } }