(Object bean)
| 1150 | |
| 1151 | |
| 1152 | private void populateMap(Object bean) { |
| 1153 | Class klass = bean.getClass(); |
| 1154 | |
| 1155 | // If klass is a System class then set includeSuperClass to false. |
| 1156 | |
| 1157 | boolean includeSuperClass = klass.getClassLoader() != null; |
| 1158 | |
| 1159 | Method[] methods = includeSuperClass |
| 1160 | ? klass.getMethods() |
| 1161 | : klass.getDeclaredMethods(); |
| 1162 | for (int i = 0; i < methods.length; i += 1) { |
| 1163 | try { |
| 1164 | Method method = methods[i]; |
| 1165 | if (Modifier.isPublic(method.getModifiers())) { |
| 1166 | String name = method.getName(); |
| 1167 | String key = ""; |
| 1168 | if (name.startsWith("get")) { |
| 1169 | if ("getClass".equals(name) || |
| 1170 | "getDeclaringClass".equals(name)) { |
| 1171 | key = ""; |
| 1172 | } else { |
| 1173 | key = name.substring(3); |
| 1174 | } |
| 1175 | } else if (name.startsWith("is")) { |
| 1176 | key = name.substring(2); |
| 1177 | } |
| 1178 | if (key.length() > 0 && |
| 1179 | Character.isUpperCase(key.charAt(0)) && |
| 1180 | method.getParameterTypes().length == 0) { |
| 1181 | if (key.length() == 1) { |
| 1182 | key = key.toLowerCase(); |
| 1183 | } else if (!Character.isUpperCase(key.charAt(1))) { |
| 1184 | key = key.substring(0, 1).toLowerCase() + |
| 1185 | key.substring(1); |
| 1186 | } |
| 1187 | |
| 1188 | Object result = method.invoke(bean, (Object[])null); |
| 1189 | if (result != null) { |
| 1190 | this.map.put(key, wrap(result)); |
| 1191 | } |
| 1192 | } |
| 1193 | } |
| 1194 | } catch (Exception ignore) { |
| 1195 | } |
| 1196 | } |
| 1197 | } |
| 1198 | |
| 1199 | |
| 1200 | /** |
no test coverage detected