@Test public void testWithValue() { final Key<String> parentKey = Key.of(randomUUID().toString(), String.class); final String parentValue = randomUUID().toString(); final Context parent = new ContextConc(root, parentKey, parentValue); final Key<String> childKey = Key.of(randomUUID().toString(), String.class); final String childValue = randomUUID().toString(); final Context child = parent.withValue(childKey, childValue); assertEquals(child.get(parentKey), parentValue); assertEquals(child.get(childKey), childValue); }
@Override public <T> Context withValue(final Key<T> key, final T value) { assertNotNull(key, "Key must not null"); assertNotNull(value, "Value must not null"); logger.trace("New context with parent: {}, key: {}, value: {}", this, key, value); return new ContextConc(this, key, value); }
ContextConc implements Context { @Override public <T> Context withValue(final Key<T> key, final T value) { assertNotNull(key, "Key must not null"); assertNotNull(value, "Value must not null"); logger.trace("New context with parent: {}, key: {}, value: {}", this, key, value); return new ContextConc(this, key, value); } }
ContextConc implements Context { @Override public <T> Context withValue(final Key<T> key, final T value) { assertNotNull(key, "Key must not null"); assertNotNull(value, "Value must not null"); logger.trace("New context with parent: {}, key: {}, value: {}", this, key, value); return new ContextConc(this, key, value); } <T> ContextConc(final Context parent, final String scope);  <T> ContextConc(final Context parent, final Key<T> key, final T value); }
ContextConc implements Context { @Override public <T> Context withValue(final Key<T> key, final T value) { assertNotNull(key, "Key must not null"); assertNotNull(value, "Value must not null"); logger.trace("New context with parent: {}, key: {}, value: {}", this, key, value); return new ContextConc(this, key, value); } <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 { @Override public <T> Context withValue(final Key<T> key, final T value) { assertNotNull(key, "Key must not null"); assertNotNull(value, "Value must not null"); logger.trace("New context with parent: {}, key: {}, value: {}", this, key, value); return new ContextConc(this, key, value); } <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();  }