Skip to content

Commit

Permalink
reduce code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Nov 7, 2009
1 parent 64cf4a9 commit 025cabe
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions impl/src/main/java/org/jboss/weld/util/Names.java
Expand Up @@ -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;
Expand Down Expand Up @@ -162,22 +163,7 @@ private static List<String> parseModifiers(int modifier)
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
Expand Down Expand Up @@ -315,22 +301,33 @@ public static String typesToString(Set<? extends Type> types)
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)
Expand Down

0 comments on commit 025cabe

Please sign in to comment.