Upgrade guice to 4.2
Test: m checkbuild
Change-Id: I7df64e3d67f5b6c586ff444f45636cd7b2935c1f
diff --git a/examples/src/example/xml/Contact.java b/examples/src/example/xml/Contact.java
index 160dbdc..a5c1c56 100644
--- a/examples/src/example/xml/Contact.java
+++ b/examples/src/example/xml/Contact.java
@@ -1,5 +1,3 @@
package example.xml;
-public class Contact {
-
-}
+public class Contact {}
diff --git a/examples/src/example/xml/FromFlash.java b/examples/src/example/xml/FromFlash.java
index def2044..ba45f9d 100644
--- a/examples/src/example/xml/FromFlash.java
+++ b/examples/src/example/xml/FromFlash.java
@@ -1,7 +1,8 @@
package example.xml;
-import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.*;
+import java.lang.annotation.Retention;
+
@Retention(RUNTIME)
-public @interface FromFlash {}
\ No newline at end of file
+public @interface FromFlash {}
diff --git a/examples/src/example/xml/FromSim.java b/examples/src/example/xml/FromSim.java
index 47ed416..5a83d95 100644
--- a/examples/src/example/xml/FromSim.java
+++ b/examples/src/example/xml/FromSim.java
@@ -1,7 +1,8 @@
package example.xml;
-import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.*;
+import java.lang.annotation.Retention;
+
@Retention(RUNTIME)
public @interface FromSim {}
diff --git a/examples/src/example/xml/Main.java b/examples/src/example/xml/Main.java
index 6983dec..0e73cd3 100644
--- a/examples/src/example/xml/Main.java
+++ b/examples/src/example/xml/Main.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright (C) 2007 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,26 +16,25 @@
package example.xml;
-import com.google.inject.Guice;
import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
import com.google.inject.Injector;
import java.net.URL;
-/**
- *
- *
- */
+/** */
public class Main {
public static void main(String[] args) {
final URL xmlUrl = Main.class.getResource("phone.xml");
- Injector injector = Guice.createInjector(new AbstractModule() {
- protected void configure() {
- bind(Contacts.class).to(SimCard.class);
- install(new XmlBeanModule(xmlUrl));
- }
- });
+ Injector injector =
+ Guice.createInjector(
+ new AbstractModule() {
+ protected void configure() {
+ bind(Contacts.class).to(SimCard.class);
+ install(new XmlBeanModule(xmlUrl));
+ }
+ });
Phone phone = injector.getInstance(Phone.class);
diff --git a/examples/src/example/xml/SimCard.java b/examples/src/example/xml/SimCard.java
index 71cf39b..8454cee 100644
--- a/examples/src/example/xml/SimCard.java
+++ b/examples/src/example/xml/SimCard.java
@@ -7,4 +7,4 @@
public Iterable<Contact> findByName(String name) {
return Collections.emptyList();
}
-}
\ No newline at end of file
+}
diff --git a/examples/src/example/xml/XmlBeanModule.java b/examples/src/example/xml/XmlBeanModule.java
index 8701d68..99c0ad6 100644
--- a/examples/src/example/xml/XmlBeanModule.java
+++ b/examples/src/example/xml/XmlBeanModule.java
@@ -1,9 +1,9 @@
package example.xml;
+import com.google.inject.Binder;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.Provider;
-import com.google.inject.Binder;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.InvocationTargetException;
@@ -47,8 +47,7 @@
Reader in = new InputStreamReader(xmlUrl.openStream());
Parsers.parse(in, beans.getContentHandler());
- }
- catch (Exception e) {
+ } catch (Exception e) {
originalBinder.addError(e);
}
}
@@ -71,8 +70,7 @@
Class<?> type;
try {
type = Class.forName(typeString);
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
sourced.addError(e);
return;
}
@@ -80,8 +78,7 @@
// Look for a no-arg constructor.
try {
type.getConstructor();
- }
- catch (NoSuchMethodException e) {
+ } catch (NoSuchMethodException e) {
sourced.addError("%s doesn't have a no-arg constructor.");
return;
}
@@ -135,21 +132,18 @@
// Validate number of parameters.
Type[] parameterTypes = setter.getGenericParameterTypes();
if (parameterTypes.length != 1) {
- sourced.addError("%s.%s() must take one argument.",
- setterName, type.getName());
+ sourced.addError("%s.%s() must take one argument.", setterName, type.getName());
return;
}
// Add property descriptor to builder.
Provider<?> provider = sourced.getProvider(Key.get(parameterTypes[0]));
- beanBuilder.properties.add(
- new Property(setter, provider));
+ beanBuilder.properties.add(new Property(setter, provider));
}
}
static String capitalize(String s) {
- return Character.toUpperCase(s.charAt(0)) +
- s.substring(1);
+ return Character.toUpperCase(s.charAt(0)) + s.substring(1);
}
static class Property {
@@ -165,19 +159,17 @@
void setOn(Object o) {
try {
setter.invoke(o, provider.get());
- }
- catch (IllegalAccessException e) {
+ } catch (IllegalAccessException e) {
throw new RuntimeException(e);
- }
- catch (InvocationTargetException e) {
+ } catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}
}
class BeanBuilder {
-
- final List<Property> properties = new ArrayList<Property>();
+
+ final List<Property> properties = new ArrayList<>();
final Class<?> type;
BeanBuilder(Class<?> type) {
@@ -189,8 +181,10 @@
}
<T> void addBinding(Class<T> type) {
- originalBinder.withSource(xmlSource())
- .bind(type).toProvider(new BeanProvider<T>(type, properties));
+ originalBinder
+ .withSource(xmlSource())
+ .bind(type)
+ .toProvider(new BeanProvider<T>(type, properties));
}
}
@@ -211,11 +205,9 @@
property.setOn(t);
}
return t;
- }
- catch (InstantiationException e) {
+ } catch (InstantiationException e) {
throw new RuntimeException(e);
- }
- catch (IllegalAccessException e) {
+ } catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}