import { Step , Join , Direction , ExistentialCondition } from './steps' ; function hasSuccessor ( steps ) { return steps . some ( step => ( step instanceof Join && step . direction === Direction . Successor ) || ( step instanceof ExistentialCondition && hasSuccessor ( step . steps ) ) ) ; } export class Query { private pathLength : number ; constructor ( public steps ) { this . pathLength = this . steps . filter ( step => step instanceof Join ) . length ; } public concat ( other ) { return new Query ( this . steps . concat ( other . steps ) ) ; } public toDescriptiveString ( ) { return this . steps . map ( s => s . toDeclarativeString ( ) ) . join ( " " ) ; } public isDeterministic ( ) { return ! hasSuccessor ( this . steps ) ; } public getPathLength ( ) { return this . pathLength ; } }