From ebd97d704c85166d8325ba0599466ffbe46f3823 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 3 Apr 2014 10:48:59 -0400 Subject: contextual: Weaken generics on toContextSensitiveProvider() to match toProvider(). --- .../sangria/contextual/ContextSensitiveBinder.java | 36 +++++++++++----------- .../contextual/ContextSensitiveBindingBuilder.java | 8 ++--- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'sangria-contextual') diff --git a/sangria-contextual/src/main/java/com/tavianator/sangria/contextual/ContextSensitiveBinder.java b/sangria-contextual/src/main/java/com/tavianator/sangria/contextual/ContextSensitiveBinder.java index cf24cc4..7f86973 100644 --- a/sangria-contextual/src/main/java/com/tavianator/sangria/contextual/ContextSensitiveBinder.java +++ b/sangria-contextual/src/main/java/com/tavianator/sangria/contextual/ContextSensitiveBinder.java @@ -103,50 +103,50 @@ public class ContextSensitiveBinder { * Fluent binding builder implementation. */ private class BindingBuilder implements AnnotatedContextSensitiveBindingBuilder { - private final Key key; + private final Key bindingKey; private final DelayedError error; - BindingBuilder(Key key) { - this.key = key; - this.error = DelayedError.create(binder, "Missing call to toContextSensitiveProvider() for %s", key); + BindingBuilder(Key bindingKey) { + this.bindingKey = bindingKey; + this.error = DelayedError.create(binder, "Missing call to toContextSensitiveProvider() for %s", bindingKey); } @Override public ContextSensitiveBindingBuilder annotatedWith(Class annotationType) { error.cancel(); - return new BindingBuilder<>(Key.get(key.getTypeLiteral(), annotationType)); + return new BindingBuilder<>(Key.get(bindingKey.getTypeLiteral(), annotationType)); } @Override public ContextSensitiveBindingBuilder annotatedWith(Annotation annotation) { error.cancel(); - return new BindingBuilder<>(Key.get(key.getTypeLiteral(), annotation)); + return new BindingBuilder<>(Key.get(bindingKey.getTypeLiteral(), annotation)); } @Override - public void toContextSensitiveProvider(Class> type) { + public void toContextSensitiveProvider(Class> type) { toContextSensitiveProvider(Key.get(type)); } @Override - public void toContextSensitiveProvider(TypeLiteral> type) { + public void toContextSensitiveProvider(TypeLiteral> type) { toContextSensitiveProvider(Key.get(type)); } @Override - public void toContextSensitiveProvider(Key> type) { + public void toContextSensitiveProvider(Key> key) { error.cancel(); - binder.bind(key).toProvider(new ProviderAdapter<>(type)); - binder.bindListener(new BindingMatcher(key), new Trigger(key)); + binder.bind(bindingKey).toProvider(new ProviderAdapter<>(key)); + binder.bindListener(new BindingMatcher(bindingKey), new Trigger(bindingKey)); } @Override - public void toContextSensitiveProvider(ContextSensitiveProvider provider) { + public void toContextSensitiveProvider(ContextSensitiveProvider provider) { error.cancel(); - binder.bind(key).toProvider(new ProviderAdapter<>(provider)); - binder.bindListener(new BindingMatcher(key), new Trigger(key)); + binder.bind(bindingKey).toProvider(new ProviderAdapter<>(provider)); + binder.bindListener(new BindingMatcher(bindingKey), new Trigger(bindingKey)); // Match the behaviour of LinkedBindingBuilder#toProvider(Provider) binder.requestInjection(provider); } @@ -159,10 +159,10 @@ public class ContextSensitiveBinder { private static final ThreadLocal CURRENT_CONTEXT = new ThreadLocal<>(); private final Object equalityKey; - private final @Nullable Key> providerKey; - private Provider> provider; + private final @Nullable Key> providerKey; + private Provider> provider; - ProviderAdapter(Key> providerKey) { + ProviderAdapter(Key> providerKey) { this.equalityKey = providerKey; this.providerKey = providerKey; } @@ -190,7 +190,7 @@ public class ContextSensitiveBinder { @Override public T get() { - ContextSensitiveProvider delegate = provider.get(); + ContextSensitiveProvider delegate = provider.get(); InjectionPoint ip = CURRENT_CONTEXT.get(); if (ip != null) { return delegate.getInContext(ip); diff --git a/sangria-contextual/src/main/java/com/tavianator/sangria/contextual/ContextSensitiveBindingBuilder.java b/sangria-contextual/src/main/java/com/tavianator/sangria/contextual/ContextSensitiveBindingBuilder.java index dc2b60b..b5797de 100644 --- a/sangria-contextual/src/main/java/com/tavianator/sangria/contextual/ContextSensitiveBindingBuilder.java +++ b/sangria-contextual/src/main/java/com/tavianator/sangria/contextual/ContextSensitiveBindingBuilder.java @@ -31,20 +31,20 @@ public interface ContextSensitiveBindingBuilder { /** * See the EDSL examples {@link ContextSensitiveBinder here}. */ - void toContextSensitiveProvider(Class> type); + void toContextSensitiveProvider(Class> type); /** * See the EDSL examples {@link ContextSensitiveBinder here}. */ - void toContextSensitiveProvider(TypeLiteral> type); + void toContextSensitiveProvider(TypeLiteral> type); /** * See the EDSL examples {@link ContextSensitiveBinder here}. */ - void toContextSensitiveProvider(Key> type); + void toContextSensitiveProvider(Key> key); /** * See the EDSL examples {@link ContextSensitiveBinder here}. */ - void toContextSensitiveProvider(ContextSensitiveProvider provider); + void toContextSensitiveProvider(ContextSensitiveProvider provider); } -- cgit v1.2.3