View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.devacfr.maven.skins.reflow.model;
20  
21  import javax.annotation.Nonnull;
22  
23  import java.util.Collections;
24  import java.util.List;
25  
26  import org.apache.commons.lang3.builder.ToStringBuilder;
27  
28  /**
29   * @author Christophe Friederich
30   * @since 2.0
31   */
32  public class SideNavMenuItem {
33  
34      /** */
35      private String name;
36  
37      /** */
38      private String href;
39  
40      /** */
41      private String icon;
42  
43      /** */
44      private String slugName;
45  
46      /** */
47      private List<SideNavMenuItem> items;
48  
49      /** */
50      private String parent;
51  
52      /**
53       * Default constructor.
54       */
55      public SideNavMenuItem() {
56      }
57  
58      /**
59       * @return Returns the name of item menu.
60       */
61      public String getName() {
62          return name;
63      }
64  
65      /**
66       * @param name
67       *            the name of item menu
68       * @return Returns the fluent instance.
69       */
70      public SideNavMenuItem withName(final String name) {
71          this.name = name;
72          return this;
73      }
74  
75      /**
76       * @return Returns the name of parent page.
77       */
78      public String getParent() {
79          return parent;
80      }
81  
82      /***
83       * @param parent
84       *            the name of parent page
85       * @return Returns the fluent instance.
86       */
87      public SideNavMenuItem withParent(final String parent) {
88          this.parent = parent;
89          return this;
90      }
91  
92      /**
93       * @return Returns the link associated to this item menu.
94       */
95      public String getHref() {
96          return href;
97      }
98  
99      /**
100      * @param href
101      *            the link to use.
102      * @return Returns the fluent instance.
103      */
104     public SideNavMenuItem withHref(final String href) {
105         this.href = href;
106         return this;
107     }
108 
109     /**
110      * @return Returns the {@link String} representing the slugged link associate to this menu item.
111      */
112     public String getSlugName() {
113         return slugName;
114     }
115 
116     /**
117      * @param slugName
118      *            the slugged name.
119      * @return Returns the fluent instance.
120      */
121     public SideNavMenuItem withSlugName(final String slugName) {
122         this.slugName = slugName;
123         return this;
124     }
125 
126     /**
127      * @return Returns the icon to use.
128      */
129     public String getIcon() {
130         return icon;
131     }
132 
133     /**
134      * Sets the icon associate to.
135      *
136      * @param icon
137      *            the icon to use.
138      * @return Returns the fluent instance.
139      */
140     public SideNavMenuItem withIcon(final String icon) {
141         this.icon = icon;
142         return this;
143     }
144 
145     /**
146      * Gets the indicating whether has items.
147      *
148      * @return Returns {@code true} if has items, otherwise {@code false}.
149      */
150     public boolean isHasItems() {
151         return items != null && !items.isEmpty();
152     }
153 
154     /**
155      * Gets the list of items.
156      *
157      * @return Returns a {@link List} representing the items.
158      */
159     @Nonnull
160     public List<SideNavMenuItem> getItems() {
161         if (items == null) {
162             return Collections.emptyList();
163         }
164         return items;
165     }
166 
167     /**
168      * Sets the items associate.
169      *
170      * @param items
171      *            the list of items.
172      * @return Returns the fluent instance.
173      */
174     public SideNavMenuItem withItems(final List<SideNavMenuItem> items) {
175         this.items = items;
176         return this;
177     }
178 
179     /**
180      * {@inheritDoc}
181      */
182     @Override
183     public String toString() {
184         return ToStringBuilder.reflectionToString(this);
185     }
186 }