Author: hlship
Date: Wed Apr 6 19:10:33 2011
New Revision: 1089572
URL: http://svn.apache.org/viewvc?rev=1089572&view=rev
Log:
TAP5-853: Reformat source
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java?rev=1089572&r1=1089571&r2=1089572&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/util/InternalUtils.java
Wed Apr 6 19:10:33 2011
@@ -251,14 +251,10 @@ public class InternalUtils
return locator.getService(serviceId, injectionType);
}
-
-
+
Named named = provider.getAnnotation(Named.class);
-
- if(named != null)
- {
- return locator.getService(named.value(), injectionType);
- }
+
+ if (named != null) { return locator.getService(named.value(),
injectionType); }
// In the absence of @InjectService, try some autowiring. First, does
the
// parameter type match one of the resources (the parameter defaults)?
@@ -397,17 +393,17 @@ public class InternalUtils
if (ap.getAnnotation(javax.inject.Inject.class) !=
null)
{
- Named named = ap.getAnnotation(Named.class);
-
- if(named == null)
- {
- inject(object, f,
locator.getObject(fieldType, ap));
- }
- else
- {
- inject(object, f,
locator.getService(named.value(), fieldType));
- }
-
+ Named named = ap.getAnnotation(Named.class);
+
+ if (named == null)
+ {
+ inject(object, f, locator.getObject(fieldType,
ap));
+ }
+ else
+ {
+ inject(object, f,
locator.getService(named.value(), fieldType));
+ }
+
return;
}
@@ -747,21 +743,21 @@ public class InternalUtils
if (c.getAnnotation(Inject.class) != null)
return c;
}
-
+
Constructor standardConstructor =
findConstructorByAnnotation(constructors, Inject.class);
Constructor javaxConstructor =
findConstructorByAnnotation(constructors, javax.inject.Inject.class);
-
- if(standardConstructor != null && javaxConstructor != null)
- throw new IllegalArgumentException(
- String.format("Too many autobuilt constructors
found. Please use either '@%s' or '@%s' annotation to mark a constructor for
autobuilding.",
- Inject.class.getName(),
javax.inject.Inject.class.getName()));
-
- if(standardConstructor != null)
- return standardConstructor;
-
- if(javaxConstructor != null)
- return javaxConstructor;
-
+
+ if (standardConstructor != null && javaxConstructor != null)
+ throw new IllegalArgumentException(
+ String.format(
+ "Too many autobuilt constructors found. Please use
either '@%s' or '@%s' annotation to mark a constructor for autobuilding.",
+ Inject.class.getName(),
javax.inject.Inject.class.getName()));
+
+ if (standardConstructor != null)
+ return standardConstructor;
+
+ if (javaxConstructor != null)
+ return javaxConstructor;
// Choose a constructor with the most parameters.
@@ -777,15 +773,16 @@ public class InternalUtils
return constructors[0];
}
-
- private static <T extends Annotation> Constructor
findConstructorByAnnotation(Constructor[] constructors, Class<T>
annotationClass)
+
+ private static <T extends Annotation> Constructor
findConstructorByAnnotation(Constructor[] constructors,
+ Class<T> annotationClass)
{
for (Constructor c : constructors)
{
if (c.getAnnotation(annotationClass) != null)
return c;
}
-
+
return null;
}
@@ -1112,7 +1109,7 @@ public class InternalUtils
};
}
-
+
/**
* @since 5.2.2
*/
@@ -1120,7 +1117,7 @@ public class InternalUtils
{
if (advisor instanceof AdvisorDef2)
return (AdvisorDef2) advisor;
-
+
return new AdvisorDef2()
{
@@ -1153,10 +1150,10 @@ public class InternalUtils
{
return null;
}
-
+
};
}
-
+
/**
* @since 5.2.2
*/
@@ -1164,7 +1161,7 @@ public class InternalUtils
{
if (decorator instanceof DecoratorDef2)
return (DecoratorDef2) decorator;
-
+
return new DecoratorDef2()
{
@@ -1197,7 +1194,7 @@ public class InternalUtils
{
return null;
}
-
+
};
}
@@ -1255,37 +1252,32 @@ public class InternalUtils
{
return uuidGenerator.incrementAndGet();
}
-
+
/**
* Extracts the service id from the passed annotated element. First the
{@link ServiceId} annotation is checked.
- * If present, its value is returned. Otherwise {@link Named} annotation
is checked. If present, its value is returned.
+ * If present, its value is returned. Otherwise {@link Named} annotation
is checked. If present, its value is
+ * returned.
* If neither of the annotations is present, <code>null</code> value is
returned
- *
- * @param annotated annotated element to get annotations from
*
+ * @param annotated
+ * annotated element to get annotations from
* @since 5.3.0
*/
public static String getServiceId(AnnotatedElement annotated)
- {
+ {
ServiceId serviceIdAnnotation =
annotated.getAnnotation(ServiceId.class);
- if (serviceIdAnnotation != null)
- {
- return serviceIdAnnotation.value();
- }
-
+ if (serviceIdAnnotation != null) { return serviceIdAnnotation.value();
}
+
Named namedAnnotation = annotated.getAnnotation(Named.class);
-
- if(namedAnnotation != null)
+
+ if (namedAnnotation != null)
{
- String value = namedAnnotation.value();
-
- if(InternalUtils.isNonBlank(value))
- {
- return value;
- }
+ String value = namedAnnotation.value();
+
+ if (InternalUtils.isNonBlank(value)) { return value; }
}
-
+
return null;
}