@Test public void testGetOrDefault() { Map<String, String> attributes = ImmutableMap.of("submission_timestamp", "2018-03-12T21:02:18.123456Z"); Map<String, String> derived = DerivedAttributesMap.of(attributes); assertEquals("2018-03-12", derived.getOrDefault("submission_date", "default")); assertEquals("21", derived.getOrDefault("submission_hour", "default")); assertEquals("default", derived.getOrDefault("nonexistent_attribute", "default")); }
@Override public String getOrDefault(Object key, String defaultValue) { String value = get(key); return value == null ? defaultValue : value; }
DerivedAttributesMap extends ForwardingMap<String, String> { @Override public String getOrDefault(Object key, String defaultValue) { String value = get(key); return value == null ? defaultValue : value; } }
DerivedAttributesMap extends ForwardingMap<String, String> { @Override public String getOrDefault(Object key, String defaultValue) { String value = get(key); return value == null ? defaultValue : value; } private  DerivedAttributesMap(Map<String, String> attributes); }
DerivedAttributesMap extends ForwardingMap<String, String> { @Override public String getOrDefault(Object key, String defaultValue) { String value = get(key); return value == null ? defaultValue : value; } private  DerivedAttributesMap(Map<String, String> attributes); static Map<String, String> of(Map<String, String> m); @Override String get(Object key); @Override String getOrDefault(Object key, String defaultValue); @Override boolean containsKey(@Nullable Object key); }
DerivedAttributesMap extends ForwardingMap<String, String> { @Override public String getOrDefault(Object key, String defaultValue) { String value = get(key); return value == null ? defaultValue : value; } private  DerivedAttributesMap(Map<String, String> attributes); static Map<String, String> of(Map<String, String> m); @Override String get(Object key); @Override String getOrDefault(Object key, String defaultValue); @Override boolean containsKey(@Nullable Object key);  }