26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
27 * |
27 * |
28 */ |
28 */ |
29 package de.uapcore.lightpit; |
29 package de.uapcore.lightpit; |
30 |
30 |
31 import java.util.Objects; |
31 public class MenuEntry { |
32 |
|
33 /** |
|
34 * Maps a resource key for the menu label to the path name for the underlying |
|
35 * site. |
|
36 * <p> |
|
37 * Objects of this class are internally instantiated by the |
|
38 * {@link ModuleManager}. |
|
39 */ |
|
40 public class MenuEntry implements Comparable<MenuEntry> { |
|
41 |
32 |
42 /** |
33 /** |
43 * Resource key for the menu label. |
34 * Resource key for the menu label. |
44 */ |
35 */ |
45 private final ResourceKey resourceKey; |
36 private final ResourceKey resourceKey; |
53 * Path name of the module, linked by this menu entry. |
44 * Path name of the module, linked by this menu entry. |
54 */ |
45 */ |
55 private final String pathName; |
46 private final String pathName; |
56 |
47 |
57 /** |
48 /** |
58 * Sequence number to determine the ordering of the menu. |
|
59 */ |
|
60 private final int sequence; |
|
61 |
|
62 /** |
|
63 * True if this menu entry is active. |
49 * True if this menu entry is active. |
64 */ |
50 */ |
65 private boolean active = false; |
51 private boolean active = false; |
66 |
52 |
67 public MenuEntry(ResourceKey resourceKey, String pathName, int sequence) { |
53 public MenuEntry(ResourceKey resourceKey, String pathName) { |
68 this.text = null; |
54 this.text = null; |
69 this.resourceKey = resourceKey; |
55 this.resourceKey = resourceKey; |
70 this.pathName = pathName; |
56 this.pathName = pathName; |
71 this.sequence = sequence; |
|
72 } |
57 } |
73 |
58 |
74 public MenuEntry(String text, String pathName, int sequence) { |
59 public MenuEntry(String text, String pathName) { |
75 this.text = text; |
60 this.text = text; |
76 this.resourceKey = null; |
61 this.resourceKey = null; |
77 this.pathName = pathName; |
62 this.pathName = pathName; |
78 this.sequence = sequence; |
|
79 } |
63 } |
80 |
64 |
81 public ResourceKey getResourceKey() { |
65 public ResourceKey getResourceKey() { |
82 return resourceKey; |
66 return resourceKey; |
83 } |
67 } |
88 |
72 |
89 public String getPathName() { |
73 public String getPathName() { |
90 return pathName; |
74 return pathName; |
91 } |
75 } |
92 |
76 |
93 public int getSequence() { |
|
94 return sequence; |
|
95 } |
|
96 |
|
97 public boolean isActive() { |
77 public boolean isActive() { |
98 return this.active; |
78 return this.active; |
99 } |
79 } |
100 |
80 |
101 public void setActive(boolean active) { |
81 public void setActive(boolean active) { |
102 this.active = true; |
82 this.active = true; |
103 } |
83 } |
104 |
84 |
105 @Override |
|
106 public boolean equals(Object o) { |
|
107 if (this == o) return true; |
|
108 if (o == null || getClass() != o.getClass()) return false; |
|
109 MenuEntry menuEntry = (MenuEntry) o; |
|
110 return resourceKey.equals(menuEntry.resourceKey) && |
|
111 pathName.equals(menuEntry.pathName); |
|
112 } |
|
113 |
|
114 @Override |
|
115 public int hashCode() { |
|
116 return Objects.hash(resourceKey, pathName); |
|
117 } |
|
118 |
|
119 @Override |
|
120 public int compareTo(MenuEntry menuEntry) { |
|
121 return Integer.compare(this.sequence, menuEntry.sequence); |
|
122 } |
|
123 } |
85 } |