/** * * @ClassName: RemoveSingleChartUtil * @Description: TODO(移除單個字符id工具類) * @author 學渣要逆襲 * @date 2017年7月6日 上午10:03:51 * */ public class RemoveSingleChartUtil { public static Object resultObj (String[] array, String compareId,Object obj,String objMethod) throws Exception{ if (array.length == 1) { if (array[0].equals(compareId)) { array = (String[]) ArrayUtils.remove(array, 0); } } else { for (int i = 0; i < array.length;) { if (array[i].equals(compareId)) { if (array.length >= 1) { array = (String[]) ArrayUtils.remove(array, i); } i = 0; } else { ++i; } } } String handlMatterIds = StringUtils.join(array,","); Method method = obj.getClass().getDeclaredMethod(objMethod,String.class); method.invoke(obj, handlMatterIds); return obj; } }