@Test public void testGetOrDefault() { final Key<String> key = Key.of(randomUUID().toString(), String.class); final Context context = new ContextConc(root, key, randomUUID().toString()); final Key<String> nokey = Key.of(randomUUID().toString(), String.class); final String expected = randomUUID().toString(); final String actual = context.getOrDefault(nokey, expected); assertEquals(expected, actual); }
@SuppressWarnings("unchecked") @Override public <T> T getOrDefault(final Key<T> key, final T defaultValue) { assertNotNull(key, "Key must not null"); final T value = (T) this.key2Value.get(key); return null != value ? value : defaultValue; }
ContextConc implements Context { @SuppressWarnings("unchecked") @Override public <T> T getOrDefault(final Key<T> key, final T defaultValue) { assertNotNull(key, "Key must not null"); final T value = (T) this.key2Value.get(key); return null != value ? value : defaultValue; } }
ContextConc implements Context { @SuppressWarnings("unchecked") @Override public <T> T getOrDefault(final Key<T> key, final T defaultValue) { assertNotNull(key, "Key must not null"); final T value = (T) this.key2Value.get(key); return null != value ? value : defaultValue; } <T> ContextConc(final Context parent, final String scope);  <T> ContextConc(final Context parent, final Key<T> key, final T value); }
ContextConc implements Context { @SuppressWarnings("unchecked") @Override public <T> T getOrDefault(final Key<T> key, final T defaultValue) { assertNotNull(key, "Key must not null"); final T value = (T) this.key2Value.get(key); return null != value ? value : defaultValue; } <T> ContextConc(final Context parent, final String scope);  <T> ContextConc(final Context parent, final Key<T> key, final T value); @Override Context withValue(final Key<T> key, final T value); @SuppressWarnings("unchecked") @Override T get(final Key<T> key); @SuppressWarnings("unchecked") @Override T getOrDefault(final Key<T> key, final T defaultValue); @Override Context withScope(final String scope); @Override String getScope(); }
ContextConc implements Context { @SuppressWarnings("unchecked") @Override public <T> T getOrDefault(final Key<T> key, final T defaultValue) { assertNotNull(key, "Key must not null"); final T value = (T) this.key2Value.get(key); return null != value ? value : defaultValue; } <T> ContextConc(final Context parent, final String scope);  <T> ContextConc(final Context parent, final Key<T> key, final T value); @Override Context withValue(final Key<T> key, final T value); @SuppressWarnings("unchecked") @Override T get(final Key<T> key); @SuppressWarnings("unchecked") @Override T getOrDefault(final Key<T> key, final T defaultValue); @Override Context withScope(final String scope); @Override String getScope();  }