Gets the menu entry or sub-menu for a specified index (zero-index), ignoring status and separators @param menuIndex the menu entry index to use to retrieve the menu entry.
(final int menuIndex)
| 281 | * @param menuIndex the menu entry index to use to retrieve the menu entry. |
| 282 | */ |
| 283 | public |
| 284 | Entry get(final int menuIndex) { |
| 285 | if (menuIndex < 0) { |
| 286 | return null; |
| 287 | } |
| 288 | |
| 289 | synchronized (menuEntries) { |
| 290 | // access on this object must be synchronized for object visibility |
| 291 | if (!menuEntries.isEmpty()) { |
| 292 | int count = 0; |
| 293 | for (Entry entry : menuEntries) { |
| 294 | if (entry instanceof Separator || entry instanceof Status) { |
| 295 | continue; |
| 296 | } |
| 297 | |
| 298 | if (count == menuIndex) { |
| 299 | return entry; |
| 300 | } |
| 301 | |
| 302 | count++; |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | return null; |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * @return a copy of all of the current menu entries. It is safe to modify any of the entries in this list without concerning yourself with synchronize. |