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  import java.util.HashMap;
21  import java.util.Map;
22  
23  /**
24   * Just a Java bean (JAJB) to try to replicate a reported bug
25   */
26  
27  public class MappedPropertyTestBean {
28  
29      private final Map<Object, Object> map = new HashMap<>();
30      private final Map<Object, Object> myMap = new HashMap<>();
31  
32      public Long getDifferentTypes(final String key) {
33          return Long.valueOf(((Number) map.get(key)).longValue());
34      }
35  
36      public String getInvalidGetter(final String key, final String other) {
37          return (String) map.get(key);
38      }
39  
40      public String getInvalidSetter(final String key) {
41          return (String) map.get(key);
42      }
43  
44      public String getMappedGetterOnly(final String key) {
45          return (String) map.get(key);
46      }
47  
48      public String getMapproperty(final String key) {
49          return (String) map.get(key);
50      }
51  
52      public Map<Object, Object> getMyMap() {
53          return myMap;
54      }
55  
56      protected String getProtectedMapped(final String key) {
57          return (String) map.get(key);
58      }
59  
60      public boolean isMappedBoolean(final String key) {
61          return ((Boolean) map.get(key)).booleanValue();
62      }
63  
64      public void setAnyMapped(final MappedPropertyTestBean key, final MappedPropertyTestBean value) {
65          map.put(key, value);
66      }
67  
68      public void setDifferentTypes(final String key, final Integer value) {
69          map.put(key, value);
70      }
71  
72      public void setInvalidGetter(final String key, final String value) {
73          map.put(key, value);
74      }
75  
76      public void setInvalidSetter(final String key, final String value, final String other) {
77      }
78  
79      public void setMappedBoolean(final String key, final boolean value) {
80          map.put(key, value ? Boolean.TRUE : Boolean.FALSE);
81      }
82  
83      public void setMappedPrimitive(final int key, final int value) {
84          map.put(Integer.valueOf(key), Integer.valueOf(value));
85      }
86  
87      public void setMappedSetterOnly(final String key, final String value) {
88          map.put(key, value);
89      }
90  
91      public void setMapproperty(final String key, final String value) {
92          map.put(key, value);
93      }
94  
95      protected void setProtectedMapped(final String key, final String value) {
96          map.put(key, value);
97      }
98  
99  }