Skip to contentPackage: CompositeNode
CompositeNode
Coverage
1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jsonld.serialization.model;
16:
17: import java.util.Collection;
18: import java.util.Collections;
19: import java.util.Objects;
20:
21: public abstract class CompositeNode extends JsonNode {
22:
23: final Collection<JsonNode> items;
24: private boolean open;
25:
26: public CompositeNode() {
27: this.items = initItems();
28: this.open = true;
29: }
30:
31: public CompositeNode(String name) {
32: super(name);
33: this.items = initItems();
34: this.open = true;
35: }
36:
37: abstract Collection<JsonNode> initItems();
38:
39: public void addItem(JsonNode item) {
40: Objects.requireNonNull(item);
41: items.add(item);
42: }
43:
44: public Collection<JsonNode> getItems() {
45: return Collections.unmodifiableCollection(items);
46: }
47:
48: public void close() {
49: this.open = false;
50: }
51:
52: public boolean isOpen() {
53: return open;
54: }
55: }