/**
 * Copyright 2019  The Hyve B.V.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */ import { TransmartConstraintVisitor } from './transmart-constraint-visitor' ; import { TransmartAndConstraint , TransmartCombinationConstraint , TransmartConceptConstraint , TransmartConstraint , TransmartFieldConstraint , TransmartNegationConstraint , TransmartNullConstraint , TransmartOrConstraint , TransmartPatientSetConstraint , TransmartRelationConstraint , TransmartStudyNameConstraint , TransmartSubSelectionConstraint , TransmartTemporalConstraint , TransmartTimeConstraint , TransmartTrueConstraint , TransmartValueConstraint } from '../../models/transmart-models/transmart-constraint' ; export abstract class AbstractTransmartConstraintVisitor < T > implements TransmartConstraintVisitor < T > { visit ( constraint ) { if ( constraint === null || constraint === undefined ) { return null ; } switch ( constraint . type ) { case 'true' : return this . visitTrueConstraint ( < TransmartTrueConstraint > constraint ) ; case 'field' : return this . visitFieldConstraint ( < TransmartFieldConstraint > constraint ) ; case 'concept' : return this . visitConceptConstraint ( < TransmartConceptConstraint > constraint ) ; case 'study_name' : return this . visitStudyNameConstraint ( < TransmartStudyNameConstraint > constraint ) ; case 'null' : return this . visitNullConstraint ( < TransmartNullConstraint > constraint ) ; case 'value' : return this . visitValueConstraint ( < TransmartValueConstraint > constraint ) ; case 'time' : return this . visitTimeConstraint ( < TransmartTimeConstraint > constraint ) ; case 'patient_set' : return this . visitPatientSetConstraint ( < TransmartPatientSetConstraint > constraint ) ; case 'negation' : return this . visitNegationConstraint ( < TransmartNegationConstraint > constraint ) ; case 'and' : return this . visitAndConstraint ( < TransmartAndConstraint > constraint ) ; case 'or' : return this . visitOrConstraint ( < TransmartOrConstraint > constraint ) ; case 'temporal' : return this . visitTemporalConstraint ( < TransmartTemporalConstraint > constraint ) ; case 'subselection' : return this . visitSubSelectionConstraint ( < TransmartSubSelectionConstraint > constraint ) ; case 'relation' : return this . visitRelationConstraint ( < TransmartRelationConstraint > constraint ) ; default : throw new Error ( `Unsupported constraint type: ${ constraint . type }` ) ; } } abstract visitTrueConstraint ( constraint ) ; abstract visitFieldConstraint ( constraint ) ; abstract visitConceptConstraint ( constraint ) ; abstract visitStudyNameConstraint ( constraint ) ; abstract visitNullConstraint ( constraint ) ; abstract visitValueConstraint ( constraint ) ; abstract visitTimeConstraint ( constraint ) ; abstract visitPatientSetConstraint ( constraint ) ; abstract visitNegationConstraint ( constraint ) ; abstract visitCombinationConstraint ( constraint ) ; visitAndConstraint ( constraint ) { return this . visitCombinationConstraint ( constraint ) ; } visitOrConstraint ( constraint ) { return this . visitCombinationConstraint ( constraint ) ; } abstract visitTemporalConstraint ( constraint ) ; abstract visitSubSelectionConstraint ( constraint ) ; abstract visitRelationConstraint ( constraint ) ; }