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; |
|
32 |
31 /** |
33 /** |
32 * Maps a resource key for the menu label to the path name for the underlying |
34 * Maps a resource key for the menu label to the path name for the underlying |
33 * site. |
35 * site. |
34 * <p> |
36 * <p> |
35 * Objects of this class are internally instantiated by the |
37 * Objects of this class are internally instantiated by the |
36 * {@link ModuleManager}. |
38 * {@link ModuleManager}. |
37 */ |
39 */ |
38 public class MenuEntry { |
40 public class MenuEntry implements Comparable<MenuEntry> { |
|
41 |
|
42 /** |
|
43 * Class name of the module for which this menu is built. |
|
44 */ |
|
45 private final String moduleClassName; |
39 |
46 |
40 /** |
47 /** |
41 * Resource key for the menu label. |
48 * Resource key for the menu label. |
42 */ |
49 */ |
43 private ResourceKey resourceKey; |
50 private final ResourceKey resourceKey; |
44 |
51 |
45 /** |
52 /** |
46 * Path name of the module, linked by this menu entry. |
53 * Path name of the module, linked by this menu entry. |
47 */ |
54 */ |
48 private String pathName; |
55 private final String pathName; |
49 |
56 |
50 public MenuEntry() { |
57 /** |
|
58 * Sequence number to determine the ordering of the menu. |
|
59 */ |
|
60 private final int sequence; |
|
61 |
|
62 public MenuEntry(String moduleClassName, ResourceKey resourceKey, String pathName, int sequence) { |
|
63 this.moduleClassName = moduleClassName; |
|
64 this.resourceKey = resourceKey; |
|
65 this.pathName = pathName; |
|
66 this.sequence = sequence; |
51 } |
67 } |
52 |
68 |
53 public MenuEntry(ResourceKey resourceKey, String pathName) { |
69 public String getModuleClassName() { |
54 this.resourceKey = resourceKey; |
70 return moduleClassName; |
55 this.pathName = pathName; |
|
56 } |
|
57 |
|
58 public void setResourceKey(ResourceKey resourceKey) { |
|
59 this.resourceKey = resourceKey; |
|
60 } |
71 } |
61 |
72 |
62 public ResourceKey getResourceKey() { |
73 public ResourceKey getResourceKey() { |
63 return resourceKey; |
74 return resourceKey; |
64 } |
75 } |
65 |
76 |
66 public void setPathName(String pathName) { |
|
67 this.pathName = pathName; |
|
68 } |
|
69 |
|
70 public String getPathName() { |
77 public String getPathName() { |
71 return pathName; |
78 return pathName; |
72 } |
79 } |
73 |
80 |
|
81 public int getSequence() { |
|
82 return sequence; |
|
83 } |
|
84 |
|
85 @Override |
|
86 public boolean equals(Object o) { |
|
87 if (this == o) return true; |
|
88 if (o == null || getClass() != o.getClass()) return false; |
|
89 MenuEntry menuEntry = (MenuEntry) o; |
|
90 return resourceKey.equals(menuEntry.resourceKey) && |
|
91 pathName.equals(menuEntry.pathName); |
|
92 } |
|
93 |
|
94 @Override |
|
95 public int hashCode() { |
|
96 return Objects.hash(resourceKey, pathName); |
|
97 } |
|
98 |
|
99 @Override |
|
100 public int compareTo(MenuEntry menuEntry) { |
|
101 return Integer.compare(this.sequence, menuEntry.sequence); |
|
102 } |
74 } |
103 } |