/**
 * Copyright 2017 - 2018  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 { Constraint } from '../constraint-models/constraint' ; import { Row } from './row' ; import { Col } from './col' ; import { TrueConstraint } from '../constraint-models/true-constraint' ; export class CrossTable { private _constraint : Constraint ; private _rowConstraints : Constraint [ ] = [ ] ; private _columnConstraints : Constraint [ ] = [ ] ; private _valueConstraints : Map < Constraint , Constraint [ ] > ; private _rowHeaderConstraints : Constraint [ ] [ ] ; private _columnHeaderConstraints : Constraint [ ] [ ] ; private _rows : Row [ ] = [ ] ; private _cols : Col [ ] = [ ] ; private _isUpdating : boolean ; constructor ( ) { this . constraint = new TrueConstraint ( ) ; this . valueConstraints = new Map < Constraint , Constraint [ ] > ( ) ; this . isUpdating = false ; } public setValueConstraints ( keyConstraint , valueConstraints ) { if ( ! ( this . rowConstraints . includes ( keyConstraint ) || this . columnConstraints . includes ( keyConstraint ) ) ) { throw new Error ( 'Constraint not present in the cross table' ) ; } this . valueConstraints . set ( keyConstraint , valueConstraints ) ; } get rowConstraints ( ) : Constraint [ ] { return this . _rowConstraints ; } set rowConstraints ( value ) { this . _rowConstraints = value ; } get columnConstraints ( ) : Constraint [ ] { return this . _columnConstraints ; } set columnConstraints ( value ) { this . _columnConstraints = value ; } get rows ( ) : Row [ ] { return this . _rows ; } set rows ( value ) { this . _rows = value ; } get cols ( ) : Col [ ] { return this . _cols ; } set cols ( value ) { this . _cols = value ; } get valueConstraints ( ) : Map < Constraint , Constraint [ ] > { return this . _valueConstraints ; } set valueConstraints ( value ) { this . _valueConstraints = value ; } get rowHeaderConstraints ( ) : Constraint [ ] [ ] { return this . _rowHeaderConstraints ; } set rowHeaderConstraints ( value ) { this . _rowHeaderConstraints = value ; } get columnHeaderConstraints ( ) : Constraint [ ] [ ] { return this . _columnHeaderConstraints ; } set columnHeaderConstraints ( value ) { this . _columnHeaderConstraints = value ; } get constraint ( ) : Constraint { return this . _constraint ; } set constraint ( value ) { this . _constraint = value ; } get isUpdating ( ) : boolean { return this . _isUpdating ; } set isUpdating ( value ) { this . _isUpdating = value ; } }