Get a Map containing field names and wrapped values for the fields' values. If the wrapped object is a Class, then this will return static fields. If the wrapped object is any other Object, then this will return instance fields. These two calls are equivalent on(o
()
| 406 | * @return A map containing field names and wrapped values. |
| 407 | */ |
| 408 | public Map<String, Reflect> fields() { |
| 409 | Map<String, Reflect> result = new LinkedHashMap<String, Reflect>(); |
| 410 | Class<?> t = type(); |
| 411 | |
| 412 | do { |
| 413 | for (Field field : t.getDeclaredFields()) { |
| 414 | if (type != object ^ Modifier.isStatic(field.getModifiers())) { |
| 415 | String name = field.getName(); |
| 416 | |
| 417 | if (!result.containsKey(name)) |
| 418 | result.put(name, field(name)); |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | t = t.getSuperclass(); |
| 423 | } |
| 424 | while (t != null); |
| 425 | |
| 426 | return result; |
| 427 | } |
| 428 | |
| 429 | /** |
| 430 | * Call a method by its name. |