KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > reflect > Changes


1 package spoon.reflect;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 import spoon.reflect.declaration.CtElement;
7
8 /**
9  * This class is a container for a list changes that may have occured on a model
10  * because of a transformation.
11  */

12 public class Changes {
13
14     List JavaDoc<CtElement> added;
15
16     List JavaDoc<CtElement> modified;
17
18     List JavaDoc<CtElement> removed;
19
20     /**
21      * Gets the list of elements added in the model.
22      */

23     public List JavaDoc<CtElement> getAdded() {
24         if (added == null) {
25             added = new ArrayList JavaDoc<CtElement>();
26         }
27         return added;
28     }
29
30     /**
31      * Gets the list of elements removed from the model.
32      */

33     public List JavaDoc<CtElement> getRemoved() {
34         if (removed == null) {
35             removed = new ArrayList JavaDoc<CtElement>();
36         }
37         return removed;
38     }
39
40     /**
41      * Gets the list of updated elements.
42      */

43     public List JavaDoc<CtElement> getModified() {
44         if (modified == null) {
45             modified = new ArrayList JavaDoc<CtElement>();
46         }
47         return modified;
48     }
49
50     /**
51      * Returns true if elements are added.
52      */

53     public boolean hasAdded() {
54         return added != null && !added.isEmpty();
55     }
56
57     /**
58      * Returns true if elements are modified.
59      */

60     public boolean hasModified() {
61         return modified != null && !modified.isEmpty();
62     }
63
64     /**
65      * Returns true if elements are removed.
66      */

67     public boolean hasRemoved() {
68         return removed != null && !removed.isEmpty();
69     }
70
71 }
72
Popular Tags