added getCommaListString method

This commit is contained in:
2019-10-11 18:43:33 +02:00
parent 113cb4a641
commit 06fe2231ec

View File

@ -144,4 +144,19 @@ public abstract class StringUtil {
return null; return null;
} }
} }
public static <T> String getCommaListString(Class<T> clazz, T[] typeArray, String methodName) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
String returnValue = "";
Method method = clazz.getMethod(methodName);
for (T currentProject : typeArray) {
@SuppressWarnings("unchecked")
String value = (String) method.invoke(currentProject) + ",";
returnValue += value;
}
if (returnValue.endsWith(",")) {
returnValue = returnValue.substring(0, returnValue.length() - 1);
}
return returnValue;
}
} }