[weld-commits] Weld SVN: r4744 - core/trunk/impl/src/main/java/org/jboss/weld/util.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Sat Nov 7 14:56:51 EST 2009
Author: pete.muir at jboss.org
Date: 2009-11-07 14:56:51 -0500 (Sat, 07 Nov 2009)
New Revision: 4744
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/util/Names.java
Log:
reduce code duplication
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Names.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Names.java 2009-11-07 19:56:06 UTC (rev 4743)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Names.java 2009-11-07 19:56:51 UTC (rev 4744)
@@ -23,6 +23,7 @@
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -162,23 +163,8 @@
return modifiers;
}
- /**
- * Gets a string representation from an array of annotations
- *
- * @param annotations The annotations
- * @return The string representation
- */
- private static String annotationsToString(Annotation[] annotations)
- {
- StringBuilder buffer = new StringBuilder();
- for (Annotation annotation : annotations)
- {
- buffer.append("@" + annotation.annotationType().getSimpleName());
- buffer.append(" ");
- }
- return buffer.toString();
- }
+
/**
* Gets a string representation from a field
*
@@ -315,24 +301,35 @@
return buffer.toString();
}
- public static String annotationsToString(Set<Annotation> annotations)
+ public static String annotationsToString(Iterable<Annotation> annotations)
{
- StringBuilder buffer = new StringBuilder();
+ StringBuilder builder = new StringBuilder();
int i = 0;
- buffer.append("[");
+ builder.append("[");
for (Annotation annotation : annotations)
{
if (i > 0)
{
- buffer.append(", ");
+ builder.append(", ");
}
- buffer.append("@").append(annotation.annotationType().getSimpleName());
+ builder.append("@").append(annotation.annotationType().getSimpleName());
i++;
}
- buffer.append("]");
- return buffer.toString();
+ builder.append("]");
+ return builder.toString();
}
+ /**
+ * Gets a string representation from an array of annotations
+ *
+ * @param annotations The annotations
+ * @return The string representation
+ */
+ public static String annotationsToString(Annotation[] annotations)
+ {
+ return annotationsToString(Arrays.asList(annotations));
+ }
+
public static String version(Package pkg)
{
if (pkg != null)
More information about the weld-commits
mailing list