You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@onami.apache.org by si...@apache.org on 2013/01/20 15:54:10 UTC
svn commit: r1435859 -
/incubator/onami/trunk/test/src/main/java/org/apache/onami/test/handler/GuiceProvidedModuleHandler.java
Author: simonetripodi
Date: Sun Jan 20 14:54:10 2013
New Revision: 1435859
URL: http://svn.apache.org/viewvc?rev=1435859&view=rev
Log:
simplify error messages construction via String.format rather than concatenation
Modified:
incubator/onami/trunk/test/src/main/java/org/apache/onami/test/handler/GuiceProvidedModuleHandler.java
Modified: incubator/onami/trunk/test/src/main/java/org/apache/onami/test/handler/GuiceProvidedModuleHandler.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/test/src/main/java/org/apache/onami/test/handler/GuiceProvidedModuleHandler.java?rev=1435859&r1=1435858&r2=1435859&view=diff
==============================================================================
--- incubator/onami/trunk/test/src/main/java/org/apache/onami/test/handler/GuiceProvidedModuleHandler.java (original)
+++ incubator/onami/trunk/test/src/main/java/org/apache/onami/test/handler/GuiceProvidedModuleHandler.java Sun Jan 20 14:54:10 2013
@@ -19,6 +19,8 @@ package org.apache.onami.test.handler;
* under the License.
*/
+import static java.lang.String.format;
+
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
@@ -67,12 +69,12 @@ public final class GuiceProvidedModuleHa
if ( LOGGER.isLoggable( Level.FINER ) )
{
- LOGGER.finer( String.format( " Found %s annotated method, checking if return type '%s' is one of %s ( %s | Iterable<%s> | %s[] )",
- GuiceProvidedModules.class.getSimpleName(),
- returnType.getName(),
- Module.class.getName(),
- Module.class.getName(),
- Module.class.getName() ) );
+ LOGGER.finer( format( " Found %s annotated method, checking if return type '%s' is one of %s ( %s | Iterable<%s> | %s[] )",
+ GuiceProvidedModules.class.getSimpleName(),
+ returnType.getName(),
+ Module.class.getName(),
+ Module.class.getName(),
+ Module.class.getName() ) );
}
if ( !Modifier.isPublic( method.getModifiers() ) || !Modifier.isStatic( method.getModifiers() ) )
@@ -102,17 +104,13 @@ public final class GuiceProvidedModuleHa
}
else
{
- throw new ClassCastException("Incompatible return type: '" + returnType.getName() + "' of method '"
- + method.getName() + "'. \nThe return type must be one of "
- + " ('"
- + Module.class.getName()
- + "' | '"
- + "Iterable<" + Module.class.getName() + ">"
- + "' | '"
- + Module.class.getName() + "[]" +
- "' )" );
+ throw new ClassCastException( format( " Incompatible return type: %s.\nThe return type must be one of ( %s | Iterable<%s> | %s[] )",
+ returnType.getName(),
+ Module.class.getName(),
+ Module.class.getName(),
+ Module.class.getName() ) );
}
-
+
if ( LOGGER.isLoggable( Level.FINER ) )
{
LOGGER.finer( " Invoked method: " + method.toGenericString() );