Skip to content

Commit

Permalink
Changed API of setEnumValue to support multiple enum values needed fo…
Browse files Browse the repository at this point in the history
…r e.g. Qualifiers
  • Loading branch information
wombat committed Dec 20, 2011
1 parent 8e8496d commit 8200a58
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Expand Up @@ -63,7 +63,7 @@ public interface Annotation<O extends JavaSource<O>> extends Internal, Origin<O>

Annotation<O> setEnumValue(String name, Enum<?> value);

Annotation<O> setEnumValue(Enum<?> value);
Annotation<O> setEnumValue(Enum<?>... value);

Annotation<O> setLiteralValue(String value);

Expand Down
Expand Up @@ -383,19 +383,37 @@ public Annotation<O> setEnumValue(final String name, final Enum<?> value)
}

@Override
public Annotation<O> setEnumValue(final Enum<?> value)
public Annotation<O> setEnumValue(final Enum<?>... values)
{
O origin = getOrigin();

String result = new String();// = "{";

if(values.length > 1) {
result = "{";
}

if (origin instanceof JavaSource)
{
JavaSource<?> source = origin;
if (!source.hasImport(value.getDeclaringClass()))
{
source.addImport(value.getDeclaringClass());

for(Enum<?> value : values) {
if (!source.hasImport(value.getDeclaringClass()))
{
source.addImport(value.getDeclaringClass());
}

result = result.concat(value.getDeclaringClass().getSimpleName() + "." + value.name() + ",");
}

result = result.substring(0, result.length()-1);

if(values.length > 1) {
result = result.concat("}");
}
}
return setLiteralValue(value.getDeclaringClass().getSimpleName() + "." + value.name());

return setLiteralValue(result);
}

/*
Expand Down

0 comments on commit 8200a58

Please sign in to comment.