View Javadoc

1   /*
2    * $Id: MenuItem.java 1198682 2011-11-07 09:50:53Z mcucchiara $
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   * http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  package org.apache.commons.ognl.test.objects;
21  
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  /**
26   *
27   */
28  public class MenuItem
29  {
30  
31      private String page;
32  
33      private String label;
34  
35      private List<MenuItem> children = new ArrayList<MenuItem>();
36  
37      public MenuItem( String page, String label )
38      {
39          this( page, label, new ArrayList<MenuItem>() );
40      }
41  
42      public MenuItem( String page, String label, List<MenuItem> children )
43      {
44          this.page = page;
45          this.label = label;
46          this.children = children;
47      }
48  
49      public List<MenuItem> getChildren()
50      {
51          return children;
52      }
53  
54      public String getLabel()
55      {
56          return label;
57      }
58  
59      public String getPage()
60      {
61          return page;
62      }
63  
64      public String toString()
65      {
66          return new StringBuilder( "MenuItem[" )
67              .append( "page=" )
68              .append( getPage() )
69              .append( ",label=" )
70              .append( getLabel() )
71              .append( ",children=" )
72              .append( getChildren().size() )
73              .append( "]" ).toString();
74      }
75  }