import { IteratorExpression } from '../Expression' ; import { OclExecutionContext } from '../../OclExecutionContext' ; import { Utils } from '../../Utils' ; oclExpression oclExample export class ExistsExpression extends IteratorExpression { evaluate ( visitor , localVariables ? ) { const collection = this . getSource ( ) . evaluate ( visitor ) ; if ( collection instanceof Array ) { return collection . some ( c => { const variables = { } ; if ( this . getIterators ( ) ) { variables [ this . getIterators ( ) [ 0 ] ] = c ; } else { const variableName = Utils . getVariableName ( this ) ; variables [ variableName . getVariable ( ) ] = c [ variableName . getVariable ( ) ] ; } const visitResult = this . getBody ( ) . evaluate ( visitor , { ... localVariables , ... variables } ) ; return visitResult === true ; } ) ; } else { return false ; } } }