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 package org.apache.commons.beanutils2.bugs.other;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.apache.commons.beanutils2.bugs.Jira61Test;
23
24 /**
25 * Factory which creates beans for {@link Jira61Test}.
26 */
27 public class Jira61BeanFactory {
28
29 /**
30 * Test Bean
31 */
32 public static class TestBean {
33
34 private final String[] indexed = { "one", "two", "three" };
35 private String simple = "FOO";
36 private final Map<String, Object> mapped = new HashMap<>();
37
38 /** Default Constructor */
39 public TestBean() {
40 mapped.put("foo-key", "foo-value");
41 mapped.put("bar-key", "bar-value");
42 }
43
44 /**
45 * Gets indexed property.
46 *
47 * @param index The index
48 * @return The indexed value
49 */
50 public String getIndexedReadOnly(final int index) {
51 return indexed[index];
52 }
53
54 /**
55 * Gets mapped property.
56 *
57 * @param key The mapped key
58 * @return The mapped value
59 */
60 public String getMappedReadOnly(final String key) {
61 return (String) mapped.get(key);
62 }
63
64 /**
65 * Gets simpleReadOnly
66 *
67 * @return the simple value
68 */
69 public String getSimpleReadOnly() {
70 return simple;
71 }
72
73 /**
74 * Sets indexed property.
75 *
76 * @param index The index
77 * @param value The indexed value
78 */
79 public void setIndexedWriteOnly(final int index, final String value) {
80 this.indexed[index] = value;
81 }
82
83 /**
84 * Sets mapped property.
85 *
86 * @param key The mapped key
87 * @param value The mapped value
88 */
89 public void setMappedWriteOnly(final String key, final String value) {
90 mapped.put(key, value);
91 }
92
93 /**
94 * Sets simpleWriteOnly
95 *
96 * @param simple simple value
97 */
98 public void setSimpleWriteOnly(final String simple) {
99 this.simple = simple;
100 }
101
102 }
103
104 /**
105 * Factory method which creates a new {@link TestBean}.
106 *
107 * @return a new {@link TestBean}.
108 */
109 public static TestBean createBean() {
110 return new TestBean();
111 }
112
113 }