silegismg-interpretador-articulacao
Version:
Interpretador de Articulação
71 lines (70 loc) • 2.89 kB
JavaScript
;
/* Copyright 2017 Assembleia Legislativa de Minas Gerais
*
* This file is part of Interpretador-Articulacao.
*
* Interpretador-Articulacao is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* Interpretador-Articulacao is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Interpretador-Articulacao. If not, see <http://www.gnu.org/licenses/>.
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Dispositivo_1 = __importStar(require("./Dispositivo"));
const Item_1 = __importDefault(require("./Item"));
class Alinea extends Dispositivo_1.default {
constructor(numero, descricao) {
super(Dispositivo_1.TipoDispositivo.ALINEA, numero, descricao, ['itens']);
this.itens = [];
}
adicionar(item) {
if (!(item instanceof Item_1.default)) {
throw new Error('Tipo não suportado.');
}
Object.defineProperty(item, '$parent', { value: this });
this.itens.push(item);
}
remover(item) {
if (!(item instanceof Item_1.default)) {
throw new Error('Tipo não suportado.');
}
const idx = this.itens.indexOf(item);
if (idx === -1) {
throw new Error('Dispositivo não encontrado.');
}
this.itens.splice(idx, 1);
}
}
exports.default = Alinea;