@@ -62,6 +62,26 @@ public LinkedHashMap<String, ListField> getListFields() {
6262 return listFields ;
6363 }
6464
65+ /**
66+ * Retrieves all subfields from the {@code fields} map as a {@link LinkedHashMap} of
67+ * {@code ObjectField} objects, keyed by their field names.
68+ *
69+ * @return a {@link LinkedHashMap} containing the field names as keys and their corresponding
70+ * {@code ObjectField} objects as values
71+ */
72+ public LinkedHashMap <String , ObjectField > getObjectFields () {
73+ LinkedHashMap <String , ObjectField > objectFields = new LinkedHashMap <>();
74+ if (fields != null ) {
75+ for (String fieldName : fields .keySet ()) {
76+ DynamicField field = fields .get (fieldName );
77+ if (field != null && field .getType () == DynamicField .FieldType .OBJECT_FIELD ) {
78+ objectFields .put (fieldName , field .getObjectField ());
79+ }
80+ }
81+ }
82+ return objectFields ;
83+ }
84+
6585 /**
6686 * Retrieves a single sub-field from the {@code fields} map as a {@link SimpleField}.
6787 *
@@ -80,14 +100,14 @@ public SimpleField getSimpleField(String fieldKey) throws IllegalStateException
80100 }
81101
82102 /**
83- * Retrieves a list sub-field from the {@code fields} map as a {@link SimpleField }.
103+ * Retrieves a list sub-field from the {@code fields} map as a {@link ListField }.
84104 *
85105 * @param fieldKey the name/key of the field to retrieve
86- * @return the corresponding {@link SimpleField }, or {@code null} if {@code fields} is
106+ * @return the corresponding {@link ListField }, or {@code null} if {@code fields} is
87107 * {@code null}
88108 * or if no field exists for {@code fieldKey} (depending on {@code fields}' behavior)
89109 * @throws IllegalStateException if the referenced field exists but is not of type
90- * {@code SIMPLE_FIELD }
110+ * {@code LIST_FIELD }
91111 */
92112 public ListField getListField (String fieldKey ) {
93113 if (fields == null ) {
@@ -96,6 +116,23 @@ public ListField getListField(String fieldKey) {
96116 return fields .getListField (fieldKey );
97117 }
98118
119+ /**
120+ * Retrieves an object sub-field from the {@code fields} map as a {@link ObjectField}.
121+ *
122+ * @param fieldKey the name/key of the field to retrieve
123+ * @return the corresponding {@link ObjectField}, or {@code null} if {@code fields} is
124+ * {@code null}
125+ * or if no field exists for {@code fieldKey} (depending on {@code fields}' behavior)
126+ * @throws IllegalStateException if the referenced field exists but is not of type
127+ * {@code OBJECT_FIELD}
128+ */
129+ public ObjectField getObjectField (String fieldKey ) {
130+ if (fields == null ) {
131+ return null ;
132+ }
133+ return fields .getObjectField (fieldKey );
134+ }
135+
99136 @ Override
100137 public String toString () {
101138 return "\n " + (fields != null ? fields .toString (1 ) : "" );
0 commit comments