further generics simplifications
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sat, 25 Oct 2014 21:02:48 +0000 (00:02 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sat, 25 Oct 2014 21:02:48 +0000 (00:02 +0300)
src/main/java/eu/svjatoslav/commons/network/navigation/NavigationItem.java

index d95ba4f..57a7649 100755 (executable)
@@ -17,30 +17,30 @@ import java.util.Map;
 import eu.svjatoslav.commons.network.Locale;
 import eu.svjatoslav.commons.string.WildCardMatcher;
 
-public class NavigationItem<NI extends NavigationItem> {
+public class NavigationItem {
 
        private String matchingPattern;
 
        private final Map<Locale, String> localeToTitle = new HashMap<Locale, String>();
-       private final ArrayList<NI> subElements = new ArrayList<NI>();
-       private final NI parent;
-       private final Navigation<NI> navigation;
+       private final ArrayList<NavigationItem> subElements = new ArrayList<NavigationItem>();
+       private final NavigationItem parent;
+       private final Navigation<NavigationItem> navigation;
        private final String linkUrl;
        /**
         * CSS prefix is inherited to child menu items.
         */
        private String cssPrefix;
 
-       public NavigationItem(final Navigation<NI> navigation) {
+       public NavigationItem(final Navigation<NavigationItem> navigation) {
                this.navigation = navigation;
                parent = null;
                matchingPattern = null;
                linkUrl = null;
        }
 
-       public NavigationItem(final NI parent, final String linkUrl,
+       public NavigationItem(final NavigationItem parent, final String linkUrl,
                        final String... titles) {
-               this.navigation = parent.getNavigation();
+               navigation = parent.getNavigation();
                this.parent = parent;
                this.linkUrl = linkUrl;
                matchingPattern = linkUrl;
@@ -50,7 +50,7 @@ public class NavigationItem<NI extends NavigationItem> {
                parent.addNavigationItem(this);
        }
 
-       public void addNavigationItem(final NI navigationItem) {
+       public void addNavigationItem(final NavigationItem navigationItem) {
                subElements.add(navigationItem);
        }
 
@@ -68,12 +68,12 @@ public class NavigationItem<NI extends NavigationItem> {
                return linkUrl;
        }
 
-       NI getMatchingNavigationItem(final String requestPath) {
+       NavigationItem getMatchingNavigationItem(final String requestPath) {
                if (matchesUrl(requestPath))
-                       return (NI) this;
+                       return this;
 
-               for (final NI childNavigationItem : subElements) {
-                       final NI match = (NI) childNavigationItem
+               for (final NavigationItem childNavigationItem : subElements) {
+                       final NavigationItem match = childNavigationItem
                                        .getMatchingNavigationItem(requestPath);
 
                        if (match != null)
@@ -82,11 +82,11 @@ public class NavigationItem<NI extends NavigationItem> {
                return null;
        }
 
-       public Navigation<NI> getNavigation() {
+       public Navigation<NavigationItem> getNavigation() {
                return navigation;
        }
 
-       public List<NI> getSubElements() {
+       public List<NavigationItem> getSubElements() {
                return subElements;
        }