mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 19:15:52 +01:00
fix annotation processing with array values
This commit is contained in:
@@ -61,7 +61,9 @@ import java.io.InputStream;
|
||||
import java.io.Writer;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -311,6 +313,31 @@ public final class ScmAnnotationProcessor extends AbstractProcessor
|
||||
return doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param obj
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String prepareArrayElement(Object obj)
|
||||
{
|
||||
String v = obj.toString();
|
||||
|
||||
if (v.startsWith("\""))
|
||||
{
|
||||
v = v.substring(1);
|
||||
|
||||
if (v.endsWith(""))
|
||||
{
|
||||
v = v.substring(0, v.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -510,7 +537,7 @@ public final class ScmAnnotationProcessor extends AbstractProcessor
|
||||
? extends AnnotationValue> entry : am.getElementValues().entrySet())
|
||||
{
|
||||
attributes.put(entry.getKey().getSimpleName().toString(),
|
||||
entry.getValue().getValue().toString());
|
||||
getValue(entry.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -518,6 +545,45 @@ public final class ScmAnnotationProcessor extends AbstractProcessor
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param v
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getValue(AnnotationValue v)
|
||||
{
|
||||
String value;
|
||||
Object object = v.getValue();
|
||||
|
||||
if (object instanceof Iterable)
|
||||
{
|
||||
Iterator<?> it = ((Iterable<?>) object).iterator();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
while (it.hasNext())
|
||||
{
|
||||
buffer.append(prepareArrayElement(it.next()));
|
||||
|
||||
if (it.hasNext())
|
||||
{
|
||||
buffer.append(",");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
value = buffer.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
value = object.toString();
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user