| 191 | } |
| 192 | |
| 193 | public Object get(Object object) { |
| 194 | try { |
| 195 | if (method != null) { |
| 196 | if (getter == null) { |
| 197 | setGetter(object); |
| 198 | } |
| 199 | return getter.invoke(object); |
| 200 | } else { |
| 201 | return field.get(object); |
| 202 | } |
| 203 | } catch (SecurityException | IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { |
| 204 | throw new ParameterException(e); |
| 205 | } catch (NoSuchMethodException e) { |
| 206 | // Try to find a field |
| 207 | String name = method.getName(); |
| 208 | String fieldName = Character.toLowerCase(name.charAt(3)) + name.substring(4); |
| 209 | Object result = null; |
| 210 | try { |
| 211 | Field field = method.getDeclaringClass().getDeclaredField(fieldName); |
| 212 | if (field != null) { |
| 213 | setFieldAccessible(field); |
| 214 | result = field.get(object); |
| 215 | } |
| 216 | } catch(NoSuchFieldException | IllegalAccessException ex) { |
| 217 | // ignore |
| 218 | } |
| 219 | return result; |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | private void setGetter(Object object) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { |
| 224 | if(Boolean.class.getSimpleName().toLowerCase().equals(getType().getName())){ |