IndexMapping { public <T> Map<String, T> getAllFieldTypes(Function<String, T> transform) { return fieldMappings.entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> transform.apply(e.getValue()))); } IndexMapping(Map<String, String> fieldMappings);  IndexMapping(MappingMetadata metaData); int size(); String getFieldType(String fieldName); Map<String, T> getAllFieldTypes(Function<String, T> transform);  }
@Test public void getAllFieldTypes() { IndexMapping indexMapping = new IndexMapping(ImmutableMap.of("name", "text", "age", "int")); Map<String, String> fieldTypes = indexMapping.getAllFieldTypes(type -> "our_type"); assertThat( fieldTypes, allOf(aMapWithSize(2), hasEntry("name", "our_type"), hasEntry("age", "our_type"))); }