+/*
+ * Svjatoslav Commons - shared library of common functionality.
+ * Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 3 of the GNU Lesser General Public License
+ * or later as published by the Free Software Foundation.
+ */
+
package eu.svjatoslav.commons.network.navigation;
import java.util.ArrayList;
private NavigationItem parent;
private final String linkUrl;
+ /**
+ * CSS prefix is inherited to child menu items.
+ */
+ private String cssPrefix;
+
public NavigationItem(final Locale... localeOrder) {
if (localeOrder.length == 0)
this.localeOrder = new Locale[] { Locale.ENG };
return item;
}
+ protected String getCssPrefix() {
+ if (cssPrefix != null)
+ return cssPrefix;
+
+ if (parent == null)
+ return null;
+
+ return parent.getCssPrefix();
+ }
+
public String getLinkUrl() {
return linkUrl;
}
public String getTitle() {
if (localeToTitle.size() != 1)
- throw new RuntimeException("there shall be exactly one title");
+ throw new RuntimeException(
+ "NavigationItem.getTitle() was called without locale parameter, but there there are multiple titles in diffirent locales available.");
return localeToTitle.values().iterator().next();
}
return WildCardMatcher.match(url, matchingPattern);
}
+ public void setCssPrefix(final String cssPrefix) {
+ this.cssPrefix = cssPrefix;
+ }
+
public NavigationItem setPattern(final String pattern) {
matchingPattern = pattern;
return this;