@Test public void testGetFieldMap() { Map<String, Object> map = createMapWithTimestampField(TIMESTAMP); Object timeField = DataUtils.getNestedFieldValue(map, "timestamp"); assertLong(timeField, TIMESTAMP); }
public static Object getNestedFieldValue(Object structOrMap, String fieldName) { validate(structOrMap, fieldName); try { Object innermost = structOrMap; for (String name : fieldName.split("\\.")) { innermost = getField(innermost, name); } return innermost; } catch (DataException e) { throw new DataException( String.format("The field '%s' does not exist in %s.", fieldName, structOrMap), e ); } }
DataUtils { public static Object getNestedFieldValue(Object structOrMap, String fieldName) { validate(structOrMap, fieldName); try { Object innermost = structOrMap; for (String name : fieldName.split("\\.")) { innermost = getField(innermost, name); } return innermost; } catch (DataException e) { throw new DataException( String.format("The field '%s' does not exist in %s.", fieldName, structOrMap), e ); } } }
DataUtils { public static Object getNestedFieldValue(Object structOrMap, String fieldName) { validate(structOrMap, fieldName); try { Object innermost = structOrMap; for (String name : fieldName.split("\\.")) { innermost = getField(innermost, name); } return innermost; } catch (DataException e) { throw new DataException( String.format("The field '%s' does not exist in %s.", fieldName, structOrMap), e ); } }  }
DataUtils { public static Object getNestedFieldValue(Object structOrMap, String fieldName) { validate(structOrMap, fieldName); try { Object innermost = structOrMap; for (String name : fieldName.split("\\.")) { innermost = getField(innermost, name); } return innermost; } catch (DataException e) { throw new DataException( String.format("The field '%s' does not exist in %s.", fieldName, structOrMap), e ); } }  static Object getField(Object structOrMap, String fieldName); static Object getNestedFieldValue(Object structOrMap, String fieldName); static Field getNestedField(Schema schema, String fieldName); }
DataUtils { public static Object getNestedFieldValue(Object structOrMap, String fieldName) { validate(structOrMap, fieldName); try { Object innermost = structOrMap; for (String name : fieldName.split("\\.")) { innermost = getField(innermost, name); } return innermost; } catch (DataException e) { throw new DataException( String.format("The field '%s' does not exist in %s.", fieldName, structOrMap), e ); } }  static Object getField(Object structOrMap, String fieldName); static Object getNestedFieldValue(Object structOrMap, String fieldName); static Field getNestedField(Schema schema, String fieldName);  }