Class ReflectiveFieldResolver
The resolver is used for structural path traversal rather than direct
value access. Given a path such as profile.address.city, it resolves
each segment in order and returns the corresponding Field objects as
an immutable list.
Resolution is performed segment by segment starting from the configured root class. For each segment, the resolver:
- looks for a declared field on the current class
- if not found, continues searching up the superclass hierarchy
- uses the resolved field's type as the basis for the next segment
Container-like field types are unwrapped before the next segment is resolved:
- array types resolve to their component type
Collectiontypes resolve to their first generic type argument- all other types are used as declared
The resolver works with declared fields, including non-public ones, but it does not make them accessible. It also searches only the class/superclass hierarchy; interfaces are not inspected for fields.
No special path syntax is supported beyond dot-separated field names. Empty or unresolvable segments fail immediately.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionresolveFieldPath(@NonNull String path) Resolves a dotted field path from the configured root class.
-
Constructor Details
-
ReflectiveFieldResolver
public ReflectiveFieldResolver()
-
-
Method Details
-
resolveFieldPath
Resolves a dotted field path from the configured root class.The path is split on dots and processed left to right. Each resolved field becomes the structural context for the next segment after array and collection unwrapping has been applied. For example, when resolving
accounts.portfolios.code, ifaccountsis aList<Account>, the next segment is resolved againstAccountrather thanList.The returned list contains one
Fieldper path segment in the same order as the input path. The final element therefore represents the terminal field in the path.- Parameters:
path- dotted field path to resolve- Returns:
- immutable list of fields representing the resolved path
- Throws:
IllegalArgumentException- if the path is empty or any segment cannot be resolved in the current structural contextUnsupportedOperationException- if traversal reaches a collection whose element type cannot be resolved reflectively
-