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