remove unnecessary explicit type parameters now that we are on java7

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145716288
This commit is contained in:
lukes
2017-03-21 15:28:23 -04:00
committed by Ron Shapiro
parent 4e0cdc3561
commit dcf7bdacc2
69 changed files with 149 additions and 152 deletions
@@ -55,7 +55,7 @@ public abstract class AbstractBindingBuilder<T> {
this.binder = binder;
this.elements = elements;
this.position = elements.size();
this.binding = new UntargettedBindingImpl<T>(source, key, Scoping.UNSCOPED);
this.binding = new UntargettedBindingImpl<>(source, key, Scoping.UNSCOPED);
elements.add(position, this.binding);
}
@@ -102,7 +102,7 @@ final class BindingProcessor extends AbstractBindingProcessor {
Initializable<T> ref =
initializer.requestInjection(
injector, instance, (Binding<T>) binding, source, injectionPoints);
ConstantFactory<? extends T> factory = new ConstantFactory<T>(ref);
ConstantFactory<? extends T> factory = new ConstantFactory<>(ref);
InternalFactory<? extends T> scopedFactory =
Scoping.scope(key, injector, factory, source, scoping);
putBinding(
@@ -175,7 +175,7 @@ final class BindingProcessor extends AbstractBindingProcessor {
errors.recursiveBinding();
}
FactoryProxy<T> factory = new FactoryProxy<T>(injector, key, linkedKey, source);
FactoryProxy<T> factory = new FactoryProxy<>(injector, key, linkedKey, source);
bindingData.addCreationListener(factory);
InternalFactory<? extends T> scopedFactory =
Scoping.scope(key, injector, factory, source, scoping);
@@ -245,7 +245,7 @@ final class BindingProcessor extends AbstractBindingProcessor {
}
private <T> void bindExposed(PrivateElements privateElements, Key<T> key) {
ExposedKeyFactory<T> exposedKeyFactory = new ExposedKeyFactory<T>(key, privateElements);
ExposedKeyFactory<T> exposedKeyFactory = new ExposedKeyFactory<>(key, privateElements);
bindingData.addCreationListener(exposedKeyFactory);
putBinding(
new ExposedBindingImpl<T>(
@@ -68,10 +68,10 @@ final class ConstructionContext<T> {
}
if (invocationHandlers == null) {
invocationHandlers = new ArrayList<DelegatingInvocationHandler<T>>();
invocationHandlers = new ArrayList<>();
}
DelegatingInvocationHandler<T> invocationHandler = new DelegatingInvocationHandler<T>();
DelegatingInvocationHandler<T> invocationHandler = new DelegatingInvocationHandler<>();
invocationHandlers.add(invocationHandler);
// TODO: if I create a proxy which implements all the interfaces of
@@ -66,7 +66,7 @@ final class ConstructorBindingImpl<T> extends BindingImpl<T>
InjectionPoint constructorInjectionPoint,
Set<InjectionPoint> injectionPoints) {
super(source, key, scoping);
this.factory = new Factory<T>(false, key);
this.factory = new Factory<>(false, key);
ConstructionProxy<T> constructionProxy =
new DefaultConstructionProxyFactory<T>(constructorInjectionPoint).create();
this.constructorInjectionPoint = constructorInjectionPoint;
@@ -134,7 +134,7 @@ final class ConstructorBindingImpl<T> extends BindingImpl<T>
errors.throwIfNewErrors(numErrors);
Factory<T> factoryFactory = new Factory<T>(failIfNotLinked, key);
Factory<T> factoryFactory = new Factory<>(failIfNotLinked, key);
InternalFactory<? extends T> scopedFactory =
Scoping.scope(key, injector, factoryFactory, source, scoping);
@@ -79,10 +79,10 @@ final class ConstructorInjectorStore {
membersInjector.getAddedAspects().isEmpty()
? injectorAspects
: ImmutableList.copyOf(concat(injectorAspects, membersInjector.getAddedAspects()));
ConstructionProxyFactory<T> factory = new ProxyFactory<T>(injectionPoint, methodAspects);
ConstructionProxyFactory<T> factory = new ProxyFactory<>(injectionPoint, methodAspects);
/*end[AOP]*/
/*if[NO_AOP]
ConstructionProxyFactory<T> factory = new DefaultConstructionProxyFactory<T>(injectionPoint);
ConstructionProxyFactory<T> factory = new DefaultConstructionProxyFactory<>(injectionPoint);
end[NO_AOP]*/
errors.throwIfNewErrors(numErrorsBefore);
@@ -48,14 +48,14 @@ final class DeferredLookups implements Lookups {
@Override
public <T> Provider<T> getProvider(Key<T> key) {
ProviderLookup<T> lookup = new ProviderLookup<T>(key, key);
ProviderLookup<T> lookup = new ProviderLookup<>(key, key);
lookups.add(lookup);
return lookup.getProvider();
}
@Override
public <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> type) {
MembersInjectorLookup<T> lookup = new MembersInjectorLookup<T>(type, type);
MembersInjectorLookup<T> lookup = new MembersInjectorLookup<>(type, type);
lookups.add(lookup);
return lookup.getMembersInjector();
}
@@ -197,7 +197,7 @@ public final class Errors implements Serializable {
sb.append(format("No implementation for %s was bound.", key));
// Keys which have similar strings as the desired key
List<String> possibleMatches = new ArrayList<String>();
List<String> possibleMatches = new ArrayList<>();
// Check for other keys that may have the same type,
// but not the same annotation
@@ -136,7 +136,7 @@ final class InjectorImpl implements Injector, Lookups {
// No ThreadLocal.initialValue(), as that would cause classloader leaks. See
// https://github.com/google/guice/issues/288#issuecomment-48216933,
// https://github.com/google/guice/issues/288#issuecomment-48216944
localContext = new ThreadLocal<Object[]>();
localContext = new ThreadLocal<>();
}
}
@@ -805,7 +805,7 @@ final class InjectorImpl implements Injector, Lookups {
// Look up the target binding.
final Key<? extends T> targetKey = Key.get(subclass);
Object source = rawType;
FactoryProxy<T> factory = new FactoryProxy<T>(this, key, targetKey, source);
FactoryProxy<T> factory = new FactoryProxy<>(this, key, targetKey, source);
factory.notify(errors); // causes the factory to initialize itself internally
return new LinkedBindingImpl<T>(
this,
@@ -61,7 +61,7 @@ final class InternalContext {
ConstructionContext<T> constructionContext =
(ConstructionContext<T>) constructionContexts.get(key);
if (constructionContext == null) {
constructionContext = new ConstructionContext<T>();
constructionContext = new ConstructionContext<>();
constructionContexts.put(key, constructionContext);
}
return constructionContext;
@@ -191,7 +191,7 @@ public final class InternalInjectorCreator {
* while we're binding these singletons are not be eager.
*/
void loadEagerSingletons(InjectorImpl injector, Stage stage, final Errors errors) {
List<BindingImpl<?>> candidateBindings = new ArrayList<BindingImpl<?>>();
List<BindingImpl<?>> candidateBindings = new ArrayList<>();
@SuppressWarnings("unchecked") // casting Collection<Binding> to Collection<BindingImpl> is safe
Collection<BindingImpl<?>> bindingsAtThisLevel =
(Collection) injector.state.getExplicitBindingsThisLevel().values();
@@ -93,7 +93,7 @@ final class MembersInjectorStore {
ImmutableList<SingleMemberInjector> injectors = getInjectors(injectionPoints, errors);
errors.throwIfNewErrors(numErrorsBefore);
EncounterImpl<T> encounter = new EncounterImpl<T>(errors, injector.lookups);
EncounterImpl<T> encounter = new EncounterImpl<>(errors, injector.lookups);
Set<TypeListener> alreadySeenListeners = Sets.newHashSet();
for (TypeListenerBinding binding : typeListenerBindings) {
TypeListener typeListener = binding.getListener();
@@ -257,7 +257,7 @@ public final class RealMapBinder<K, V> implements Module {
TypeLiteral<V> valueType,
Key<Map<K, V>> mapKey,
RealMultibinder<Map.Entry<K, Provider<V>>> entrySetBinder) {
this.bindingSelection = new BindingSelection<K, V>(keyType, valueType, mapKey, entrySetBinder);
this.bindingSelection = new BindingSelection<>(keyType, valueType, mapKey, entrySetBinder);
this.binder = binder;
this.entrySetBinder = entrySetBinder;
}
@@ -309,7 +309,7 @@ public final class RealMapBinder<K, V> implements Module {
(Provider) providerMapProvider;
binder.bind(bindingSelection.getJavaxProviderMapKey()).toProvider(javaxProviderMapProvider);
RealMapProvider<K, V> mapProvider = new RealMapProvider<K, V>(bindingSelection);
RealMapProvider<K, V> mapProvider = new RealMapProvider<>(bindingSelection);
binder.bind(bindingSelection.getMapKey()).toProvider(mapProvider);
// The Map.Entries are all ProviderMapEntry instances which do not allow setValue, so it is
@@ -420,7 +420,7 @@ public final class RealMapBinder<K, V> implements Module {
// we have those, it's easy to iterate through them to organize them by K.
Map<K, ImmutableSet.Builder<Binding<V>>> bindingMultimapMutable =
new LinkedHashMap<K, ImmutableSet.Builder<Binding<V>>>();
Map<K, Binding<V>> bindingMapMutable = new LinkedHashMap<K, Binding<V>>();
Map<K, Binding<V>> bindingMapMutable = new LinkedHashMap<>();
Multimap<K, Indexer.IndexedBinding> index = HashMultimap.create();
Indexer indexer = new Indexer(injector);
Multimap<K, Binding<V>> duplicates = null;
@@ -1134,7 +1134,7 @@ public final class RealMapBinder<K, V> implements Module {
(SingleParameterInjector<V>[])
injector.getParametersInjectors(dependenciesForKey, errors);
perKeyDatas[i] = new PerKeyData<K, V>(entry.getKey(), bindingsArray, injectors);
perKeyDatas[i] = new PerKeyData<>(entry.getKey(), bindingsArray, injectors);
i++;
}
@@ -53,7 +53,7 @@ public final class RealMultibinder<T> implements Module {
/** Implementation of newSetBinder. */
public static <T> RealMultibinder<T> newRealSetBinder(Binder binder, Key<T> key) {
binder = binder.skipSources(RealMultibinder.class);
RealMultibinder<T> result = new RealMultibinder<T>(binder, key);
RealMultibinder<T> result = new RealMultibinder<>(binder, key);
binder.install(result);
return result;
}
@@ -86,7 +86,7 @@ public final class RealMultibinder<T> implements Module {
RealMultibinder(Binder binder, Key<T> key) {
this.binder = checkNotNull(binder, "binder");
this.bindingSelection = new BindingSelection<T>(key);
this.bindingSelection = new BindingSelection<>(key);
}
@Override
@@ -59,7 +59,7 @@ import javax.inject.Qualifier;
public final class RealOptionalBinder<T> implements Module {
public static <T> RealOptionalBinder<T> newRealOptionalBinder(Binder binder, Key<T> type) {
binder = binder.skipSources(RealOptionalBinder.class);
RealOptionalBinder<T> optionalBinder = new RealOptionalBinder<T>(binder, type);
RealOptionalBinder<T> optionalBinder = new RealOptionalBinder<>(binder, type);
binder.install(optionalBinder);
return optionalBinder;
}
@@ -185,7 +185,7 @@ public final class RealOptionalBinder<T> implements Module {
private final Binder binder;
private RealOptionalBinder(Binder binder, Key<T> typeKey) {
this.bindingSelection = new BindingSelection<T>(typeKey);
this.bindingSelection = new BindingSelection<>(typeKey);
this.binder = binder;
}
@@ -101,7 +101,7 @@ public class SingletonScope implements Scope {
* Circular proxies are used when potential deadlocks are detected. Guarded by itself.
* ConstructionContext is not thread-safe, so each call should be synchronized.
*/
final ConstructionContext<T> constructionContext = new ConstructionContext<T>();
final ConstructionContext<T> constructionContext = new ConstructionContext<>();
/** For each binding there is a separate lock that we hold during object creation. */
final CycleDetectingLock<Key<?>> creationLock = cycleDetectingLockFactory.create(key);
@@ -55,9 +55,8 @@ public class StackTraceElements {
/*end[AOP]*/
private static final ConcurrentMap<InMemoryStackTraceElement, InMemoryStackTraceElement>
elementCache = new ConcurrentHashMap<InMemoryStackTraceElement, InMemoryStackTraceElement>();
private static final ConcurrentMap<String, String> stringCache =
new ConcurrentHashMap<String, String>();
elementCache = new ConcurrentHashMap<>();
private static final ConcurrentMap<String, String> stringCache = new ConcurrentHashMap<>();
private static final String UNKNOWN_SOURCE = "Unknown Source";
+1 -1
View File
@@ -408,7 +408,7 @@ public final class Elements {
@Override
public <T> Provider<T> getProvider(final Dependency<T> dependency) {
final ProviderLookup<T> element = new ProviderLookup<T>(getElementSource(), dependency);
final ProviderLookup<T> element = new ProviderLookup<>(getElementSource(), dependency);
elements.add(element);
return element.getProvider();
}
@@ -38,7 +38,6 @@ import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
@@ -566,14 +565,14 @@ public final class InjectionPoint {
if (bySignature == null) {
// We encountered a method in a subclass. Time to index the
// methods in the parent class.
bySignature = new HashMap<Signature, List<InjectableMethod>>();
bySignature = new HashMap<>();
for (InjectableMember member = injectableMembers.head;
member != null;
member = member.next) {
if (!(member instanceof InjectableMethod)) continue;
InjectableMethod im = (InjectableMethod) member;
if (im.isFinal()) continue;
List<InjectableMethod> methods = new ArrayList<InjectableMethod>();
List<InjectableMethod> methods = new ArrayList<>();
methods.add(im);
bySignature.put(new Signature(im.method), methods);
}
@@ -624,7 +623,7 @@ public final class InjectionPoint {
: new Signature(injectableMethod.method);
List<InjectableMethod> methods = bySignature.get(signature);
if (methods == null) {
methods = new ArrayList<InjectableMethod>();
methods = new ArrayList<>();
bySignature.put(signature, methods);
}
methods.add(injectableMethod);
@@ -789,7 +788,7 @@ public final class InjectionPoint {
}
private static List<TypeLiteral<?>> hierarchyFor(TypeLiteral<?> type) {
List<TypeLiteral<?>> hierarchy = new ArrayList<TypeLiteral<?>>();
List<TypeLiteral<?>> hierarchy = new ArrayList<>();
TypeLiteral<?> current = type;
while (current.getRawType() != Object.class) {
hierarchy.add(current);
+1 -1
View File
@@ -190,7 +190,7 @@ public final class Modules {
}
final Binder binder = baseBinder.skipSources(this.getClass());
final LinkedHashSet<Element> elements = new LinkedHashSet<Element>(baseElements);
final LinkedHashSet<Element> elements = new LinkedHashSet<>(baseElements);
final Module scannersModule = extractScanners(elements);
final List<Element> overrideElements =
Elements.getElements(
+5 -5
View File
@@ -16,7 +16,6 @@
package com.google.inject;
import static com.google.inject.internal.InternalFlags.IncludeStackTraceOption;
import static com.google.inject.internal.InternalFlags.getIncludeStackTraceOption;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
@@ -28,6 +27,7 @@ import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.testing.GcFinalization;
import com.google.inject.internal.InternalFlags.IncludeStackTraceOption;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -172,8 +172,8 @@ public class Asserts {
public static void awaitFullGc() {
// GcFinalization *should* do it, but doesn't work well in practice...
// so we put a second latch and wait for a ReferenceQueue to tell us.
ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
WeakReference ref = new WeakReference<Object>(new Object(), queue);
ReferenceQueue<Object> queue = new ReferenceQueue<>();
WeakReference<Object> ref = new WeakReference<>(new Object(), queue);
GcFinalization.awaitFullGc();
try {
assertSame("queue didn't return ref in time", ref, queue.remove(5000));
@@ -191,8 +191,8 @@ public class Asserts {
ReferenceQueue<Object> queue = null;
WeakReference extraRef = null;
if (data != null) {
queue = new ReferenceQueue<Object>();
extraRef = new WeakReference<Object>(data, queue);
queue = new ReferenceQueue<>();
extraRef = new WeakReference<>(data, queue);
data = null;
}
GcFinalization.awaitClear(ref);
@@ -61,7 +61,7 @@ public class BindingOrderTest extends TestCase {
public void testBindingWithExtraThreads() throws InterruptedException {
final CountDownLatch ready = new CountDownLatch(1);
final CountDownLatch done = new CountDownLatch(1);
final AtomicReference<B> ref = new AtomicReference<B>();
final AtomicReference<B> ref = new AtomicReference<>();
final Object createsAThread =
new Object() {
+1 -1
View File
@@ -634,7 +634,7 @@ public class BindingTest extends TestCase {
}
}
private static List<Butter> butters = new ArrayList<Butter>();
private static List<Butter> butters = new ArrayList<>();
private static interface Sandwitch {};
@@ -86,7 +86,7 @@ public class EagerSingletonTest extends TestCase {
public void testJustInTimeEagerSingletons_multipleThreads() throws Exception {
// in order to make the data race more likely we need a lot of jit bindings. The easiest thing
// is just to 'copy' out class for B a bunch of times.
final List<Class<?>> jitBindings = new ArrayList<Class<?>>();
final List<Class<?>> jitBindings = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
jitBindings.add(copyClass(B.class));
}
@@ -424,7 +424,7 @@ public class InjectorTest extends TestCase {
public void testJitBindingFromAnotherThreadDuringInjection() {
final ExecutorService executorService = Executors.newSingleThreadExecutor();
final AtomicReference<JustInTime> got = new AtomicReference<JustInTime>();
final AtomicReference<JustInTime> got = new AtomicReference<>();
Guice.createInjector(
new AbstractModule() {
+2 -2
View File
@@ -332,7 +332,7 @@ public class KeyTest extends TestCase {
binder().requestInjection(new TypeLiteral<Object>() {}, foo);
}
};
WeakReference<Module> moduleRef = new WeakReference<Module>(module);
WeakReference<Module> moduleRef = new WeakReference<>(module);
final Injector injector = Guice.createInjector(module);
module = null;
awaitClear(moduleRef); // Make sure anonymous keys & typeliterals don't hold the module.
@@ -345,7 +345,7 @@ public class KeyTest extends TestCase {
injector.getInstance(Key.get(new TypeLiteral<Typed<Integer>>() {}));
}
};
WeakReference<Runnable> runnerRef = new WeakReference<Runnable>(runner);
WeakReference<Runnable> runnerRef = new WeakReference<>(runner);
runner.run();
runner = null;
awaitClear(runnerRef); // also make sure anonymous keys & typeliterals don't hold for JITs
@@ -94,7 +94,7 @@ public class MembersInjectorTest extends TestCase {
}
});
A<C> injectableA = new A<C>();
A<C> injectableA = new A<>();
aMembersInjectorReference.get().injectMembers(injectableA);
assertSame(myFavouriteC, injectableA.t);
assertSame(myFavouriteC, injectableA.b.c);
@@ -122,7 +122,7 @@ public class MembersInjectorTest extends TestCase {
injector.getMembersInjector(new TypeLiteral<A<C>>() {});
MembersInjector<B> bMembersInjector = injector.getMembersInjector(B.class);
A<C> injectableA = new A<C>();
A<C> injectableA = new A<>();
aMembersInjector.injectMembers(injectableA);
assertSame(myFavouriteC, injectableA.t);
assertSame(myFavouriteC, injectableA.b.c);
@@ -183,7 +183,7 @@ public class MembersInjectorTest extends TestCase {
})
.getInstance(InjectsMembersInjector.class);
A<C> a = new A<C>();
A<C> a = new A<>();
injectsMembersInjector.aMembersInjector.injectMembers(a);
assertSame(myFavouriteC, a.t);
assertSame(myFavouriteC, a.b.c);
@@ -250,7 +250,7 @@ public class MembersInjectorTest extends TestCase {
MembersInjector<A<C>> membersInjector =
injector.getInstance(new Key<MembersInjector<A<C>>>() {});
A<C> a = new A<C>();
A<C> a = new A<>();
membersInjector.injectMembers(a);
assertSame(myFavouriteC, a.t);
assertSame(myFavouriteC, a.b.c);
@@ -121,7 +121,7 @@ public class MethodInterceptionTest extends TestCase {
}
public void testGetThis() {
final AtomicReference<Object> lastTarget = new AtomicReference<Object>();
final AtomicReference<Object> lastTarget = new AtomicReference<>();
Injector injector =
Guice.createInjector(
@@ -528,7 +528,7 @@ public class ProvisionListenerTest extends TestCase {
private static class CountAndCaptureExceptionListener implements ProvisionListener {
int beforeProvision = 0;
int afterProvision = 0;
AtomicReference<RuntimeException> capture = new AtomicReference<RuntimeException>();
AtomicReference<RuntimeException> capture = new AtomicReference<>();
@Override
public <T> void onProvision(ProvisionInvocation<T> provision) {
+4 -4
View File
@@ -1181,18 +1181,18 @@ public class ScopesTest extends TestCase {
}
});
FutureTask<I0> firstThreadResult = new FutureTask<I0>(fetchClass(injector, I0.class));
FutureTask<I0> firstThreadResult = new FutureTask<>(fetchClass(injector, I0.class));
Thread i0Thread = new Thread(firstThreadResult, "I0.class");
// we need to call toString() now, because the toString() changes after the thread exits.
String i0ThreadString = i0Thread.toString();
i0Thread.start();
FutureTask<J0> secondThreadResult = new FutureTask<J0>(fetchClass(injector, J0.class));
FutureTask<J0> secondThreadResult = new FutureTask<>(fetchClass(injector, J0.class));
Thread j0Thread = new Thread(secondThreadResult, "J0.class");
String j0ThreadString = j0Thread.toString();
j0Thread.start();
FutureTask<K0> thirdThreadResult = new FutureTask<K0>(fetchClass(injector, K0.class));
FutureTask<K0> thirdThreadResult = new FutureTask<>(fetchClass(injector, K0.class));
Thread k0Thread = new Thread(thirdThreadResult, "K0.class");
String k0ThreadString = k0Thread.toString();
k0Thread.start();
@@ -1222,7 +1222,7 @@ public class ScopesTest extends TestCase {
}
// verification of error messages generated
List<Message> errors = new ArrayList<Message>();
List<Message> errors = new ArrayList<>();
errors.addAll(((ProvisionException) firstException).getErrorMessages());
errors.addAll(((ProvisionException) secondException).getErrorMessages());
errors.addAll(((ProvisionException) thirdException).getErrorMessages());
@@ -415,9 +415,8 @@ public class TypeListenerTest extends TestCase {
}
public void testLookupsAtInjectorCreateTime() {
final AtomicReference<Provider<B>> bProviderReference = new AtomicReference<Provider<B>>();
final AtomicReference<MembersInjector<A>> aMembersInjectorReference =
new AtomicReference<MembersInjector<A>>();
final AtomicReference<Provider<B>> bProviderReference = new AtomicReference<>();
final AtomicReference<MembersInjector<A>> aMembersInjectorReference = new AtomicReference<>();
final InjectionListener<Object> lookupsTester =
new InjectionListener<Object>() {
@@ -40,7 +40,7 @@ public class CycleDetectingLockTest extends TestCase {
final CyclicBarrier signal1 = new CyclicBarrier(2);
final CyclicBarrier signal2 = new CyclicBarrier(2);
final CyclicBarrier signal3 = new CyclicBarrier(2);
final CycleDetectingLockFactory<String> lockFactory = new CycleDetectingLockFactory<String>();
final CycleDetectingLockFactory<String> lockFactory = new CycleDetectingLockFactory<>();
final CycleDetectingLock<String> lockA =
new ReentrantCycleDetectingLock<String>(
lockFactory,
@@ -131,9 +131,9 @@ public class CycleDetectingLockTest extends TestCase {
*/
public void testCycleDetectingLockFactoriesDoNotDeadlock() throws Exception {
final CycleDetectingLockFactory<String> factoryA = new CycleDetectingLockFactory<String>();
final CycleDetectingLockFactory<String> factoryA = new CycleDetectingLockFactory<>();
final CycleDetectingLock<String> lockA = factoryA.create("A");
final CycleDetectingLockFactory<String> factoryB = new CycleDetectingLockFactory<String>();
final CycleDetectingLockFactory<String> factoryB = new CycleDetectingLockFactory<>();
final CycleDetectingLock<String> lockB = factoryB.create("B");
final CyclicBarrier eachThreadAcquiredFirstLock = new CyclicBarrier(2);
Future<Boolean> threadA =
@@ -192,7 +192,7 @@ public class CycleDetectingLockTest extends TestCase {
*/
public void testCycleReporting() throws Exception {
final CycleDetectingLockFactory<String> factory = new CycleDetectingLockFactory<String>();
final CycleDetectingLockFactory<String> factory = new CycleDetectingLockFactory<>();
final CycleDetectingLock<String> lockA = factory.create("a");
final CycleDetectingLock<String> lockB = factory.create("b");
final CycleDetectingLock<String> lockC = factory.create("c");
@@ -1235,7 +1235,7 @@ public class MapBinderTest extends TestCase {
@SuppressWarnings("unchecked")
private <K, V> Map<K, V> mapOf(Object... elements) {
Map<K, V> result = new HashMap<K, V>();
Map<K, V> result = new HashMap<>();
for (int i = 0; i < elements.length; i += 2) {
result.put((K) elements[i], (V) elements[i + 1]);
}
@@ -1286,7 +1286,7 @@ public class MapBinderTest extends TestCase {
// This ensures that MultiBinder is internally using the correct set name --
// making sure that instances of marker annotations have the same set name as
// MarkerAnnotation.class.
Map<Integer, Integer> expected = new HashMap<Integer, Integer>();
Map<Integer, Integer> expected = new HashMap<>();
expected.put(1, 1);
expected.put(2, 2);
assertEquals(expected, s1);
@@ -1357,7 +1357,7 @@ public class MapBinderTest extends TestCase {
binder.addBinding("bar").toInstance("foo");
}
});
WeakReference<Injector> weakRef = new WeakReference<Injector>(childInjector);
WeakReference<Injector> weakRef = new WeakReference<>(childInjector);
WeakKeySetUtils.assertBlacklisted(parentInjector, mapKey);
// Clear the ref, GC, and ensure that we are no longer blacklisting.
@@ -1036,7 +1036,7 @@ public class MultibinderTest extends TestCase {
}
static Set<String> values(Iterable<StringGrabber> grabbers) {
Set<String> result = new HashSet<String>();
Set<String> result = new HashSet<>();
for (StringGrabber grabber : grabbers) {
result.add(grabber.string);
}
@@ -1302,7 +1302,7 @@ public class MultibinderTest extends TestCase {
// This ensures that MultiBinder is internally using the correct set name --
// making sure that instances of marker annotations have the same set name as
// MarkerAnnotation.class.
Set<Integer> expected = new HashSet<Integer>();
Set<Integer> expected = new HashSet<>();
expected.add(1);
expected.add(2);
assertEquals(expected, s1);
@@ -1433,7 +1433,7 @@ public class OptionalBinderTest extends TestCase {
.toInstance(4);
}
});
WeakReference<Injector> weakRef = new WeakReference<Injector>(childInjector);
WeakReference<Injector> weakRef = new WeakReference<>(childInjector);
WeakKeySetUtils.assertBlacklisted(parentInjector, Key.get(Integer.class));
// Clear the ref, GC, and ensure that we are no longer blacklisting.
@@ -43,7 +43,7 @@ public class ProxyFactoryTest extends TestCase {
InjectionPoint injectionPoint = InjectionPoint.forConstructorOf(Simple.class);
aspects.add(new MethodAspect(any(), any(), interceptor));
ProxyFactory<Simple> factory = new ProxyFactory<Simple>(injectionPoint, aspects);
ProxyFactory<Simple> factory = new ProxyFactory<>(injectionPoint, aspects);
ConstructionProxy<Simple> constructionProxy = factory.create();
@@ -151,7 +151,7 @@ public class SpiUtils {
int expectedMapBindings,
MapResult... results) {
Injector injector = Guice.createInjector(modules);
Visitor<T> visitor = new Visitor<T>();
Visitor<T> visitor = new Visitor<>();
Binding<T> mapBinding = injector.getBinding(mapKey);
MapBinderBinding<T> mapbinder = (MapBinderBinding<T>) mapBinding.acceptTargetVisitor(visitor);
assertNotNull(mapbinder);
@@ -320,7 +320,7 @@ public class SpiUtils {
int expectedMapBindings,
MapResult<?, ?>... results) {
Set<Element> elements = ImmutableSet.copyOf(Elements.getElements(modules));
Visitor<T> visitor = new Visitor<T>();
Visitor<T> visitor = new Visitor<>();
MapBinderBinding<T> mapbinder = null;
Map<Key<?>, Binding<?>> keyMap = Maps.newHashMap();
for (Element element : elements) {
@@ -571,7 +571,7 @@ public class SpiUtils {
Key<?> collectionOfProvidersKey = setKey.ofType(collectionOfProvidersOf(elementType));
Key<?> collectionOfJavaxProvidersKey = setKey.ofType(collectionOfJavaxProvidersOf(elementType));
Injector injector = Guice.createInjector(modules);
Visitor<Set<T>> visitor = new Visitor<Set<T>>();
Visitor<Set<T>> visitor = new Visitor<>();
Binding<Set<T>> binding = injector.getBinding(setKey);
MultibinderBinding<Set<T>> multibinder =
(MultibinderBinding<Set<T>>) binding.acceptTargetVisitor(visitor);
@@ -666,7 +666,7 @@ public class SpiUtils {
Key<?> collectionOfJavaxProvidersKey = setKey.ofType(collectionOfJavaxProvidersOf(elementType));
List<BindResult> bindResults = Lists.newArrayList(results);
List<Element> elements = Elements.getElements(modules);
Visitor<T> visitor = new Visitor<T>();
Visitor<T> visitor = new Visitor<>();
MultibinderBinding<Set<T>> multibinder = null;
for (Element element : elements) {
if (element instanceof Binding && ((Binding) element).getKey().equals(setKey)) {
@@ -678,7 +678,7 @@ public class SpiUtils {
assertEquals(elementType, multibinder.getElementTypeLiteral());
List<Object> otherMultibinders = Lists.newArrayList();
Set<Element> otherContains = new HashSet<Element>();
Set<Element> otherContains = new HashSet<>();
List<Element> otherElements = Lists.newArrayList();
int duplicates = 0;
Set<IndexedBinding> setOfIndexed = Sets.newHashSet();
@@ -67,7 +67,7 @@ public class WeakKeySetTest extends TestCase {
Key<Integer> key = Key.get(Integer.class);
Object source = new Object();
WeakReference<Key<Integer>> weakKeyRef = new WeakReference<Key<Integer>>(key);
WeakReference<Key<Integer>> weakKeyRef = new WeakReference<>(key);
set.add(key, state, source);
assertInSet(set, key, 1, source);
@@ -88,7 +88,7 @@ public class WeakKeySetTest extends TestCase {
Key<Integer> key = Key.get(Integer.class);
Object source = null;
WeakReference<Key<Integer>> weakKeyRef = new WeakReference<Key<Integer>>(key);
WeakReference<Key<Integer>> weakKeyRef = new WeakReference<>(key);
set.add(key, state, source);
assertInSet(set, key, 1, source);
@@ -118,10 +118,10 @@ public class WeakKeySetTest extends TestCase {
set.add(key2, state2, source2);
assertInSet(set, key2, 2, source1, source2);
WeakReference<Key<Integer>> weakKey1Ref = new WeakReference<Key<Integer>>(key1);
WeakReference<Key<Integer>> weakKey2Ref = new WeakReference<Key<Integer>>(key2);
WeakReference<Object> weakSource1Ref = new WeakReference<Object>(source1);
WeakReference<Object> weakSource2Ref = new WeakReference<Object>(source2);
WeakReference<Key<Integer>> weakKey1Ref = new WeakReference<>(key1);
WeakReference<Key<Integer>> weakKey2Ref = new WeakReference<>(key2);
WeakReference<Object> weakSource1Ref = new WeakReference<>(source1);
WeakReference<Object> weakSource2Ref = new WeakReference<>(source2);
Key<Integer> key = key1 = key2 = Key.get(Integer.class);
state1 = null;
@@ -166,8 +166,8 @@ public class WeakKeySetTest extends TestCase {
set.add(key2, state2, source2);
assertInSet(set, key2, 2, source1, source2);
WeakReference<Key<Integer>> weakKey1Ref = new WeakReference<Key<Integer>>(key1);
WeakReference<Key<Integer>> weakKey2Ref = new WeakReference<Key<Integer>>(key2);
WeakReference<Key<Integer>> weakKey1Ref = new WeakReference<>(key1);
WeakReference<Key<Integer>> weakKey2Ref = new WeakReference<>(key2);
Key<Integer> key = key1 = key2 = Key.get(Integer.class);
@@ -195,9 +195,9 @@ public class WeakKeySetTest extends TestCase {
assertInSet(set, key2, 1, source);
assertInSet(set, key1, 1, source);
WeakReference<Key<Integer>> weakKey1Ref = new WeakReference<Key<Integer>>(key1);
WeakReference<Key<Integer>> weakKey2Ref = new WeakReference<Key<Integer>>(key2);
WeakReference<Object> weakSourceRef = new WeakReference<Object>(source);
WeakReference<Key<Integer>> weakKey1Ref = new WeakReference<>(key1);
WeakReference<Key<Integer>> weakKey2Ref = new WeakReference<>(key2);
WeakReference<Object> weakSourceRef = new WeakReference<>(source);
Key<Integer> key = key1 = key2 = Key.get(Integer.class);
state1 = null;
@@ -237,9 +237,9 @@ public class WeakKeySetTest extends TestCase {
// Same source so still only one value.
assertInSet(set, key2, 1, source);
WeakReference<Key<Integer>> weakKey1Ref = new WeakReference<Key<Integer>>(key1);
WeakReference<Key<Integer>> weakKey2Ref = new WeakReference<Key<Integer>>(key2);
WeakReference<Object> weakSourceRef = new WeakReference<Object>(source);
WeakReference<Key<Integer>> weakKey1Ref = new WeakReference<>(key1);
WeakReference<Key<Integer>> weakKey2Ref = new WeakReference<>(key2);
WeakReference<Object> weakSourceRef = new WeakReference<>(source);
Key<Integer> key = key1 = key2 = Key.get(Integer.class);
state1 = null;
@@ -289,12 +289,12 @@ public class WeakKeySetTest extends TestCase {
set.add(key3, state3, source3);
assertInSet(set, key1, 3, source1, source2, source3);
WeakReference<Key<Integer>> weakKey1Ref = new WeakReference<Key<Integer>>(key1);
WeakReference<Key<Integer>> weakKey2Ref = new WeakReference<Key<Integer>>(key2);
WeakReference<Key<Integer>> weakKey3Ref = new WeakReference<Key<Integer>>(key3);
WeakReference<Object> weakSource1Ref = new WeakReference<Object>(source1);
WeakReference<Object> weakSource2Ref = new WeakReference<Object>(source2);
WeakReference<Object> weakSource3Ref = new WeakReference<Object>(source3);
WeakReference<Key<Integer>> weakKey1Ref = new WeakReference<>(key1);
WeakReference<Key<Integer>> weakKey2Ref = new WeakReference<>(key2);
WeakReference<Key<Integer>> weakKey3Ref = new WeakReference<>(key3);
WeakReference<Object> weakSource1Ref = new WeakReference<>(source1);
WeakReference<Object> weakSource2Ref = new WeakReference<>(source2);
WeakReference<Object> weakSource3Ref = new WeakReference<>(source3);
Key<Integer> key = key1 = key2 = key3 = Key.get(Integer.class);
state1 = null;
@@ -350,7 +350,7 @@ public class WeakKeySetTest extends TestCase {
bind(String.class).toInstance("bar");
}
});
WeakReference<Injector> weakRef = new WeakReference<Injector>(childInjector);
WeakReference<Injector> weakRef = new WeakReference<>(childInjector);
assertBlacklisted(parentInjector, Key.get(String.class));
// Clear the ref, GC, and ensure that we are no longer blacklisting.
@@ -379,7 +379,7 @@ public class WeakKeySetTest extends TestCase {
bind(String.class).toInstance("foo");
}
});
WeakReference<Injector> weakRef1 = new WeakReference<Injector>(childInjector1);
WeakReference<Injector> weakRef1 = new WeakReference<>(childInjector1);
assertBlacklisted(parentInjector, Key.get(String.class));
assertNotBlacklisted(parentInjector, Key.get(Long.class));
@@ -391,7 +391,7 @@ public class WeakKeySetTest extends TestCase {
bind(Long.class).toInstance(6L);
}
});
WeakReference<Injector> weakRef2 = new WeakReference<Injector>(childInjector2);
WeakReference<Injector> weakRef2 = new WeakReference<>(childInjector2);
assertBlacklisted(parentInjector, Key.get(String.class));
assertBlacklisted(parentInjector, Key.get(Long.class));
@@ -427,7 +427,7 @@ public class WeakKeySetTest extends TestCase {
bind(String.class).toInstance("foo");
}
});
WeakReference<Injector> weakRef1 = new WeakReference<Injector>(childInjector1);
WeakReference<Injector> weakRef1 = new WeakReference<>(childInjector1);
assertBlacklisted(parentInjector, Key.get(String.class));
Injector childInjector2 =
@@ -438,7 +438,7 @@ public class WeakKeySetTest extends TestCase {
bind(String.class).toInstance("bar");
}
});
WeakReference<Injector> weakRef2 = new WeakReference<Injector>(childInjector2);
WeakReference<Injector> weakRef2 = new WeakReference<>(childInjector2);
assertBlacklisted(parentInjector, Key.get(String.class));
// Clear ref1, GC, and ensure that we still blacklist.
@@ -879,7 +879,7 @@ public class ElementsTest extends TestCase {
final AtomicReference<MembersInjector<String>> membersInjectorFromBinder =
new AtomicReference<MembersInjector<String>>();
final AtomicReference<String> lastInjected = new AtomicReference<String>();
final AtomicReference<String> lastInjected = new AtomicReference<>();
final MembersInjector<String> stringInjector =
new MembersInjector<String>() {
@Override
@@ -449,7 +449,7 @@ public class ProviderMethodsTest extends TestCase implements Module {
}
public void testInjectsJustOneLogger() {
AtomicReference<Logger> loggerRef = new AtomicReference<Logger>();
AtomicReference<Logger> loggerRef = new AtomicReference<>();
Injector injector = Guice.createInjector(new FooModule(loggerRef));
assertNull(loggerRef.get());
@@ -404,7 +404,7 @@ public class OverrideModuleTest extends TestCase {
}
public void testOverrideIsLazy() {
final AtomicReference<String> value = new AtomicReference<String>("A");
final AtomicReference<String> value = new AtomicReference<>("A");
Module overridden =
Modules.override(
new AbstractModule() {
+1 -1
View File
@@ -169,7 +169,7 @@ public class XmlBeanModule implements Module {
class BeanBuilder {
final List<Property> properties = new ArrayList<Property>();
final List<Property> properties = new ArrayList<>();
final Class<?> type;
BeanBuilder(Class<?> type) {
@@ -52,7 +52,7 @@ class AssistedConstructor<T> {
Annotation[][] annotations = constructor.getParameterAnnotations();
List<Type> typeList = Lists.newArrayList();
allParameters = new ArrayList<Parameter>();
allParameters = new ArrayList<>();
// categorize params as @Assisted or @Injected
for (int i = 0; i < parameterTypes.size(); i++) {
@@ -313,7 +313,7 @@ public final class FactoryModuleBuilder {
return new AbstractModule() {
@Override
protected void configure() {
Provider<F> provider = new FactoryProvider2<F>(factoryInterface, bindings);
Provider<F> provider = new FactoryProvider2<>(factoryInterface, bindings);
bind(factoryInterface).toProvider(provider);
}
};
@@ -432,7 +432,7 @@ final class FactoryProvider2<F>
@Override
public Set<Dependency<?>> getDependencies() {
Set<Dependency<?>> combinedDeps = new HashSet<Dependency<?>>();
Set<Dependency<?>> combinedDeps = new HashSet<>();
for (AssistData data : assistDataByMethod.values()) {
combinedDeps.addAll(data.dependencies);
}
@@ -34,7 +34,7 @@ class ParameterListKey {
private final List<Type> paramList;
public ParameterListKey(List<Type> paramList) {
this.paramList = new ArrayList<Type>(paramList);
this.paramList = new ArrayList<>(paramList);
}
public ParameterListKey(Type[] types) {
@@ -529,7 +529,7 @@ public class FactoryModuleBuilderTest extends TestCase {
private void validateDependencies(Set<Key<?>> expectedKeys, Binding<?> binding) {
Set<Dependency<?>> dependencies = ((HasDependencies) binding).getDependencies();
Set<Key<?>> actualKeys = new HashSet<Key<?>>();
Set<Key<?>> actualKeys = new HashSet<>();
for (Dependency<?> dependency : dependencies) {
actualKeys.add(dependency.getKey());
}
@@ -170,7 +170,7 @@ public class AbstractInjectorGrapherTest extends TestCase {
}
public void testProviderBindings() throws Exception {
final Wrapper<Provider<A2>> wrapper = new Wrapper<Provider<A2>>();
final Wrapper<Provider<A2>> wrapper = new Wrapper<>();
grapher.graph(
Guice.createInjector(
new AbstractModule() {
@@ -45,9 +45,9 @@ public final class MiniGuice {
private MiniGuice() {}
private final Map<Key, Provider<?>> bindings = new HashMap<Key, Provider<?>>();
private final Queue<RequiredKey> requiredKeys = new ArrayDeque<RequiredKey>();
private final Set<Key> singletons = new HashSet<Key>();
private final Map<Key, Provider<?>> bindings = new HashMap<>();
private final Queue<RequiredKey> requiredKeys = new ArrayDeque<>();
private final Set<Key> singletons = new HashSet<>();
/**
* Creates an injector defined by {@code modules} and immediately uses it to create an instance of
@@ -88,7 +88,7 @@ public final class MiniGuice {
}
private void addProviderBindings() {
Map<Key, Provider<?>> providerBindings = new HashMap<Key, Provider<?>>();
Map<Key, Provider<?>> providerBindings = new HashMap<>();
for (final Map.Entry<Key, Provider<?>> binding : bindings.entrySet()) {
Key key = binding.getKey();
final Provider<?> value = binding.getValue();
@@ -192,8 +192,8 @@ public final class MiniGuice {
/*
* Lookup the injectable fields and their corresponding keys.
*/
final List<Field> injectedFields = new ArrayList<Field>();
List<Object> fieldKeysList = new ArrayList<Object>();
final List<Field> injectedFields = new ArrayList<>();
List<Object> fieldKeysList = new ArrayList<>();
for (Class<?> c = type; c != Object.class; c = c.getSuperclass()) {
for (Field field : c.getDeclaredFields()) {
if (!field.isAnnotationPresent(javax.inject.Inject.class)) {
@@ -179,8 +179,8 @@ public final class MiniGuiceTest extends TestCase {
}
public void testSingletonBindingAnnotationAndProvider() {
final AtomicReference<A> a1 = new AtomicReference<A>();
final AtomicReference<A> a2 = new AtomicReference<A>();
final AtomicReference<A> a1 = new AtomicReference<>();
final AtomicReference<A> a2 = new AtomicReference<>();
L l =
MiniGuice.inject(
@@ -37,7 +37,7 @@ class JpaLocalTxnInterceptor implements MethodInterceptor {
private static class Internal {}
// Tracks if the unit of work was begun implicitly by this transaction.
private final ThreadLocal<Boolean> didWeStartWork = new ThreadLocal<Boolean>();
private final ThreadLocal<Boolean> didWeStartWork = new ThreadLocal<>();
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
@@ -36,7 +36,7 @@ import javax.persistence.Persistence;
/** @author Dhanji R. Prasanna (dhanji@gmail.com) */
@Singleton
class JpaPersistService implements Provider<EntityManager>, UnitOfWork, PersistService {
private final ThreadLocal<EntityManager> entityManager = new ThreadLocal<EntityManager>();
private final ThreadLocal<EntityManager> entityManager = new ThreadLocal<>();
private final String persistenceUnitName;
private final Map<?, ?> persistenceProperties;
@@ -49,7 +49,7 @@ public class EnsureJpaCanTakeObjectsInPropertiesTest extends TestCase {
@Override
protected void configure() {
Map<String, Object> p = new HashMap<String, Object>();
Map<String, Object> p = new HashMap<>();
p.put(Environment.CONNECTION_PROVIDER, InjectedDataSourceConnectionProvider.class.getName());
if (passDataSource) {
@@ -32,7 +32,7 @@ import javax.persistence.OneToMany;
@Entity
public class JpaParentTestEntity {
private Long id;
private List<JpaTestEntity> children = new ArrayList<JpaTestEntity>();
private List<JpaTestEntity> children = new ArrayList<>();
@Id
@GeneratedValue
@@ -47,7 +47,7 @@ class FilterDefinition implements ProviderWithExtensionVisitor<FilterDefinition>
private final Filter filterInstance;
// always set after init is called.
private final AtomicReference<Filter> filter = new AtomicReference<Filter>();
private final AtomicReference<Filter> filter = new AtomicReference<>();
public FilterDefinition(
Key<? extends Filter> filterKey,
@@ -47,7 +47,7 @@ class FiltersModuleBuilder {
}
private List<UriPatternMatcher> parsePatterns(UriPatternType type, List<String> patterns) {
List<UriPatternMatcher> patternMatchers = new ArrayList<UriPatternMatcher>();
List<UriPatternMatcher> patternMatchers = new ArrayList<>();
for (String pattern : patterns) {
UriPatternMatcher matcher = null;
try {
@@ -61,7 +61,7 @@ import javax.servlet.http.HttpServletResponse;
* @author dhanji@gmail.com (Dhanji R. Prasanna)
*/
public class GuiceFilter implements Filter {
static final ThreadLocal<Context> localContext = new ThreadLocal<Context>();
static final ThreadLocal<Context> localContext = new ThreadLocal<>();
static volatile FilterPipeline pipeline = new DefaultFilterPipeline();
/** We allow both the static and dynamic versions of the pipeline to exist. */
@@ -223,7 +223,7 @@ public class GuiceFilter implements Filter {
final ServletContext servletContext = filterConfig.getServletContext();
// Store servlet context in a weakreference, for injection
GuiceFilter.servletContext = new WeakReference<ServletContext>(servletContext);
GuiceFilter.servletContext = new WeakReference<>(servletContext);
// In the default pipeline, this is a noop. However, if replaced
// by a managed pipeline, a lazy init will be triggered the first time
@@ -40,7 +40,7 @@ public abstract class GuiceServletContextListener implements ServletContextListe
// Set the Servletcontext early for those people who are using this class.
// NOTE(dhanji): This use of the servletContext is deprecated.
GuiceFilter.servletContext = new WeakReference<ServletContext>(servletContext);
GuiceFilter.servletContext = new WeakReference<>(servletContext);
Injector injector = getInjector();
injector
@@ -57,7 +57,7 @@ class ServletDefinition implements ProviderWithExtensionVisitor<ServletDefinitio
private final HttpServlet servletInstance;
//always set in init, our servlet is always presumed to be a singleton
private final AtomicReference<HttpServlet> httpServlet = new AtomicReference<HttpServlet>();
private final AtomicReference<HttpServlet> httpServlet = new AtomicReference<>();
public ServletDefinition(
Key<? extends HttpServlet> servletKey,
@@ -49,7 +49,7 @@ public class ServletScopes {
* this scope map if no http request is available, and requires {@link #scopeRequest} to be called
* as an alternative.
*/
private static final ThreadLocal<Context> requestScopeContext = new ThreadLocal<Context>();
private static final ThreadLocal<Context> requestScopeContext = new ThreadLocal<>();
/** A sentinel attribute value representing null. */
enum NullObject {
@@ -77,7 +77,7 @@ final class ServletUtils {
// 1. decode and normalize safe percent escaped characters. e.g. %70 -> 'p'
// 2. decode and interpret dangerous character sequences. e.g. /%2E/ -> '/./' -> '/'
// 3. preserve dangerous encoded characters. e.g. '/%2F/' -> '///' -> '/%2F'
List<String> segments = new ArrayList<String>();
List<String> segments = new ArrayList<>();
for (String segment : SLASH_SPLITTER.split(path)) {
// This decodes all non-special characters from the path segment. so if someone passes
// /%2E/foo we will normalize it to /./foo and then /foo
@@ -51,7 +51,7 @@ class ServletsModuleBuilder {
}
private List<UriPatternMatcher> parsePatterns(UriPatternType type, List<String> patterns) {
List<UriPatternMatcher> patternMatchers = new ArrayList<UriPatternMatcher>();
List<UriPatternMatcher> patternMatchers = new ArrayList<>();
for (String pattern : patterns) {
if (!servletUris.add(pattern)) {
binder
@@ -285,7 +285,7 @@ public class FilterDispatchIntegrationTest extends TestCase {
public static class TestServlet extends HttpServlet {
public static final String FORWARD_FROM = "/index.html";
public static final String FORWARD_TO = "/forwarded.html";
public List<String> processedUris = new ArrayList<String>();
public List<String> processedUris = new ArrayList<>();
@Override
protected void service(
@@ -142,7 +142,7 @@ public class ServletPipelineRequestDispatcherTest extends TestCase {
mockResponse.resetBuffer();
expectLastCall().once();
final List<String> paths = new ArrayList<String>();
final List<String> paths = new ArrayList<>();
final HttpServlet mockServlet =
new HttpServlet() {
@Override
@@ -46,7 +46,7 @@ public class GuiceObjectFactory extends ObjectFactory {
Module module;
volatile Injector injector;
boolean developmentMode = false;
List<ProvidedInterceptor> interceptors = new ArrayList<ProvidedInterceptor>();
List<ProvidedInterceptor> interceptors = new ArrayList<>();
@Override
public boolean isNoArgConstructorRequired() {
@@ -71,7 +71,7 @@ public class GuiceObjectFactory extends ObjectFactory {
this.developmentMode = developmentMode.trim().equals("true");
}
Set<Class<?>> boundClasses = new HashSet<Class<?>>();
Set<Class<?>> boundClasses = new HashSet<>();
@Override
public Class getClassInstance(String name) throws ClassNotFoundException {
@@ -51,7 +51,7 @@ public class Struts2Factory extends ObjectFactory {
private static @com.google.inject.Inject Injector injector;
private final List<ProvidedInterceptor> interceptors = new ArrayList<ProvidedInterceptor>();
private final List<ProvidedInterceptor> interceptors = new ArrayList<>();
private volatile Injector strutsInjector;
@Override
@@ -67,7 +67,7 @@ public class Struts2Factory extends ObjectFactory {
+ " Please install your module via a GuiceServletContextListener instead.");
}
Set<Class<?>> boundClasses = new HashSet<Class<?>>();
Set<Class<?>> boundClasses = new HashSet<>();
@Override
public Class<?> getClassInstance(String name) throws ClassNotFoundException {
@@ -512,7 +512,7 @@ public class BoundFieldModuleTest extends TestCase {
}
public void testBindParameterizedTypeFails() {
ParameterizedObject<Integer> instance = new ParameterizedObject<Integer>(0);
ParameterizedObject<Integer> instance = new ParameterizedObject<>(0);
BoundFieldModule module = BoundFieldModule.of(instance);
@@ -82,7 +82,7 @@ public class CheckedProviderTest extends TestCase {
private final TypeLiteral<RemoteProvider<Foo>> remoteProviderOfFoo =
new TypeLiteral<RemoteProvider<Foo>>() {};
private final MockRemoteProvider<Foo> mockRemoteProvider = new MockRemoteProvider<Foo>();
private final MockRemoteProvider<Foo> mockRemoteProvider = new MockRemoteProvider<>();
private final TestScope testScope = new TestScope();
private Injector bindInjector;
@@ -299,8 +299,8 @@ public class CheckedProviderTest extends TestCase {
}
public void testAnnotations_Bind() throws Exception {
final MockRemoteProvider<Foo> mockRemoteProviderA = new MockRemoteProvider<Foo>();
final MockRemoteProvider<Foo> mockRemoteProviderB = new MockRemoteProvider<Foo>();
final MockRemoteProvider<Foo> mockRemoteProviderA = new MockRemoteProvider<>();
final MockRemoteProvider<Foo> mockRemoteProviderB = new MockRemoteProvider<>();
bindInjector =
Guice.createInjector(
new AbstractModule() {
@@ -320,8 +320,8 @@ public class CheckedProviderTest extends TestCase {
}
public void testAnnotations_Provides() throws Exception {
final MockRemoteProvider<Foo> mockRemoteProviderA = new MockRemoteProvider<Foo>();
final MockRemoteProvider<Foo> mockRemoteProviderB = new MockRemoteProvider<Foo>();
final MockRemoteProvider<Foo> mockRemoteProviderA = new MockRemoteProvider<>();
final MockRemoteProvider<Foo> mockRemoteProviderB = new MockRemoteProvider<>();
providesInjector =
Guice.createInjector(
new AbstractModule() {
@@ -37,7 +37,7 @@ class TestScope implements Scope {
@ScopeAnnotation
public @interface Scoped {}
private Map<Key, Object> inScopeObjectsMap = new HashMap<Key, Object>();
private Map<Key, Object> inScopeObjectsMap = new HashMap<>();
@Override
public <T> Provider<T> scope(final Key<T> key, final Provider<T> provider) {
@@ -56,6 +56,6 @@ class TestScope implements Scope {
}
public void beginNewScope() {
inScopeObjectsMap = new HashMap<Key, Object>();
inScopeObjectsMap = new HashMap<>();
}
}
@@ -62,7 +62,7 @@ public class ThrowingProviderTest extends TestCase {
private final TypeLiteral<RemoteProvider<String>> remoteProviderOfString =
new TypeLiteral<RemoteProvider<String>>() {};
private final MockRemoteProvider<String> mockRemoteProvider = new MockRemoteProvider<String>();
private final MockRemoteProvider<String> mockRemoteProvider = new MockRemoteProvider<>();
private final TestScope testScope = new TestScope();
private Injector bindInjector =
Guice.createInjector(
@@ -219,8 +219,8 @@ public class ThrowingProviderTest extends TestCase {
}
public void testAnnotations_Bind() throws RemoteException {
final MockRemoteProvider<String> mockRemoteProviderA = new MockRemoteProvider<String>();
final MockRemoteProvider<String> mockRemoteProviderB = new MockRemoteProvider<String>();
final MockRemoteProvider<String> mockRemoteProviderA = new MockRemoteProvider<>();
final MockRemoteProvider<String> mockRemoteProviderB = new MockRemoteProvider<>();
bindInjector =
Guice.createInjector(
new AbstractModule() {
@@ -240,8 +240,8 @@ public class ThrowingProviderTest extends TestCase {
}
public void testAnnotations_Provides() throws RemoteException {
final MockRemoteProvider<String> mockRemoteProviderA = new MockRemoteProvider<String>();
final MockRemoteProvider<String> mockRemoteProviderB = new MockRemoteProvider<String>();
final MockRemoteProvider<String> mockRemoteProviderA = new MockRemoteProvider<>();
final MockRemoteProvider<String> mockRemoteProviderB = new MockRemoteProvider<>();
providesInjector =
Guice.createInjector(
new AbstractModule() {