01: /*
02: * Spoon - http://spoon.gforge.inria.fr/
03: * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
04: *
05: * This software is governed by the CeCILL-C License under French law and
06: * abiding by the rules of distribution of free software. You can use, modify
07: * and/or redistribute the software under the terms of the CeCILL-C license as
08: * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
09: *
10: * This program is distributed in the hope that it will be useful, but WITHOUT
11: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12: * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
13: *
14: * The fact that you are presently reading this means that you have had
15: * knowledge of the CeCILL-C license and that you accept its terms.
16: */
17:
18: package spoon.reflect;
19:
20: import java.util.ArrayList;
21: import java.util.List;
22:
23: import spoon.reflect.declaration.CtElement;
24:
25: /**
26: * This class is a container for a list changes that may have occured on a model
27: * because of a transformation.
28: */
29: public class Changes {
30:
31: List<CtElement> added;
32:
33: List<CtElement> modified;
34:
35: List<CtElement> removed;
36:
37: /**
38: * Creates an instance to be further initialized.
39: */
40: public Changes() {
41: }
42:
43: /**
44: * Gets the list of elements added in the model.
45: */
46: public List<CtElement> getAdded() {
47: if (added == null) {
48: added = new ArrayList<CtElement>();
49: }
50: return added;
51: }
52:
53: /**
54: * Gets the list of elements removed from the model.
55: */
56: public List<CtElement> getRemoved() {
57: if (removed == null) {
58: removed = new ArrayList<CtElement>();
59: }
60: return removed;
61: }
62:
63: /**
64: * Gets the list of updated elements.
65: */
66: public List<CtElement> getModified() {
67: if (modified == null) {
68: modified = new ArrayList<CtElement>();
69: }
70: return modified;
71: }
72:
73: /**
74: * Returns true if elements are added.
75: */
76: public boolean hasAdded() {
77: return added != null && !added.isEmpty();
78: }
79:
80: /**
81: * Returns true if elements are modified.
82: */
83: public boolean hasModified() {
84: return modified != null && !modified.isEmpty();
85: }
86:
87: /**
88: * Returns true if elements are removed.
89: */
90: public boolean hasRemoved() {
91: return removed != null && !removed.isEmpty();
92: }
93:
94: }
|