View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      https://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.beanutils2;
19  
20  /**
21   * Specialist test bean for complex nested properties.
22   */
23  
24  public class NestedTestBean {
25  
26      private String name;
27  
28      private String testString = "NOT SET";
29  
30      private boolean testBoolean;
31  
32      private NestedTestBean[] indexedBeans;
33  
34      private NestedTestBean simpleBean;
35  
36      public NestedTestBean(final String name) {
37          setName(name);
38      }
39  
40      public NestedTestBean getIndexedProperty(final int index) {
41          return this.indexedBeans[index];
42      }
43  
44      public String getName() {
45          return name;
46      }
47  
48      public NestedTestBean getSimpleBeanProperty() {
49          return simpleBean;
50      }
51  
52      public boolean getTestBoolean() {
53          return testBoolean;
54      }
55  
56      public String getTestString() {
57          return testString;
58      }
59  
60      public void init() {
61          indexedBeans = new NestedTestBean[5];
62          indexedBeans[0] = new NestedTestBean("Bean@0");
63          indexedBeans[1] = new NestedTestBean("Bean@1");
64          indexedBeans[2] = new NestedTestBean("Bean@2");
65          indexedBeans[3] = new NestedTestBean("Bean@3");
66          indexedBeans[4] = new NestedTestBean("Bean@4");
67  
68          simpleBean = new NestedTestBean("Simple Property Bean");
69      }
70  
71      public void setIndexedProperty(final int index, final NestedTestBean value) {
72          this.indexedBeans[index] = value;
73      }
74  
75      public void setName(final String name) {
76          this.name = name;
77      }
78  
79      public void setTestBoolean(final boolean testBoolean) {
80          this.testBoolean = testBoolean;
81      }
82  
83      public void setTestString(final String testString) {
84          this.testString = testString;
85      }
86  
87  }