@Test public void testWithValue() { final Context instance = EmptyContext.getInstance(); final Key<String> key = Key.of(randomUUID().toString(), String.class); final String expected = randomUUID().toString(); final Context context = instance.withValue(key, expected); final String actual = context.get(key); assertEquals(expected, actual); }
@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); }
EmptyContext 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); } }
EmptyContext 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); } EmptyContext(); }
EmptyContext 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); } EmptyContext(); static Context getInstance(); @Override Context withValue(final Key<T> key, final T value); @Override T get(final Key<T> key); @Override T getOrDefault(final Key<T> key, final T defaultValue); @Override Context withScope(final String scope); @Override String getScope(); }
EmptyContext 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); } EmptyContext(); static Context getInstance(); @Override Context withValue(final Key<T> key, final T value); @Override T get(final Key<T> key); @Override T getOrDefault(final Key<T> key, final T defaultValue); @Override Context withScope(final String scope); @Override String getScope();  }