/** * <p>Checks if the array is not null or empty. <p/> * * @param array th array to check * @return {@code true} if the array is not null or empty. */ public static boolean isNotEmpty(final Object[] array) { return !isEmpty(array); } }
/** * <p>Checks if the array is not null or empty. <p/> * * @param array th array to check * @return {@code true} if the array is not null or empty. */ public static boolean isNotEmpty(final Object[] array) { return !isEmpty(array); } }
static Throwable getThrowableCandidate(Object[] argArray) { if (ArrayUtils.isEmpty(argArray)) { return null; } final Object lastEntry = argArray[argArray.length - 1]; if (lastEntry instanceof Throwable) { return (Throwable) lastEntry; } return null; }
@Override public int[] merge(int[]... items) { if (ArrayUtils.isEmpty(items)) { return new int[0]; } int totalLen = 0; for (int[] array : items) { if (array != null) { totalLen += array.length; } } int[] result = new int[totalLen]; int index = 0; for (int[] array : items) { if (array != null) { for (int item : array) { result[index++] = item; } } } return result; }
@Override public byte[] merge(byte[]... items) { if (ArrayUtils.isEmpty(items)) { return new byte[0]; } int total = 0; for (byte[] array : items) { if (array != null) { total += array.length; } } byte[] result = new byte[total]; int index = 0; for (byte[] array : items) { if (array != null) { for (byte item : array) { result[index++] = item; } } } return result; }
@Override public boolean[] merge(boolean[]... items) { if (ArrayUtils.isEmpty(items)) { return new boolean[0]; } int totalLen = 0; for (boolean[] array : items) { if (array != null) { totalLen += array.length; } } boolean[] result = new boolean[totalLen]; int index = 0; for (boolean[] array : items) { if (array != null) { for (boolean item : array) { result[index++] = item; } } } return result; }
@Override public int[] merge(int[]... items) { if (ArrayUtils.isEmpty(items)) { return new int[0]; } int totalLen = 0; for (int[] array : items) { if (array != null) { totalLen += array.length; } } int[] result = new int[totalLen]; int index = 0; for (int[] array : items) { if (array != null) { for (int item : array) { result[index++] = item; } } } return result; }
static Object[] trimmedCopy(Object[] argArray) { if (ArrayUtils.isEmpty(argArray)) { throw new IllegalStateException("non-sensical empty or null argument array"); } final int trimmedLen = argArray.length - 1; Object[] trimmed = new Object[trimmedLen]; System.arraycopy(argArray, 0, trimmed, 0, trimmedLen); return trimmed; }
@Override public Map<?, ?> merge(Map<?, ?>... items) { if (ArrayUtils.isEmpty(items)) { return Collections.emptyMap(); } Map<Object, Object> result = new HashMap<Object, Object>(); for (Map<?, ?> item : items) { if (item != null) { result.putAll(item); } } return result; }
@Override public List<Object> merge(List<?>... items) { if (ArrayUtils.isEmpty(items)) { return Collections.emptyList(); } List<Object> result = new ArrayList<Object>(); for (List<?> item : items) { if (item != null) { result.addAll(item); } } return result; }
@Override public Map<?, ?> merge(Map<?, ?>... items) { if (ArrayUtils.isEmpty(items)) { return Collections.emptyMap(); } Map<Object, Object> result = new HashMap<Object, Object>(); for (Map<?, ?> item : items) { if (item != null) { result.putAll(item); } } return result; }
@Override public List<Object> merge(List<?>... items) { if (ArrayUtils.isEmpty(items)) { return Collections.emptyList(); } List<Object> result = new ArrayList<Object>(); for (List<?> item : items) { if (item != null) { result.addAll(item); } } return result; }
@Override public Set<Object> merge(Set<?>... items) { if (ArrayUtils.isEmpty(items)) { return Collections.emptySet(); } Set<Object> result = new HashSet<Object>(); for (Set<?> item : items) { if (item != null) { result.addAll(item); } } return result; } }
@Override public Set<Object> merge(Set<?>... items) { if (ArrayUtils.isEmpty(items)) { return Collections.emptySet(); } Set<Object> result = new HashSet<Object>(); for (Set<?> item : items) { if (item != null) { result.addAll(item); } } return result; } }
/** * join string. * * @param array String array. * @return String. */ public static String join(String[] array) { if (ArrayUtils.isEmpty(array)) { return EMPTY; } StringBuilder sb = new StringBuilder(); for (String s : array) { sb.append(s); } return sb.toString(); }
/** * join string. * * @param array String array. * @return String. */ public static String join(String[] array) { if (ArrayUtils.isEmpty(array)) { return EMPTY; } StringBuilder sb = new StringBuilder(); for (String s : array) { sb.append(s); } return sb.toString(); }
private static Map<String, String> convertAttachment(URL url, String[] keys) { if (ArrayUtils.isEmpty(keys)) { return null; } Map<String, String> attachment = new HashMap<String, String>(); for (String key : keys) { String value = url.getParameter(key); if (value != null && value.length() > 0) { attachment.put(key, value); } } return attachment; }
private static Map<String, String> convertAttachment(URL url, String[] keys) { if (ArrayUtils.isEmpty(keys)) { return null; } Map<String, String> attachment = new HashMap<String, String>(); for (String key : keys) { String value = url.getParameter(key); if (value != null && value.length() > 0) { attachment.put(key, value); } } return attachment; }
private void handleValue(ObjectInput in) throws IOException { try { Type[] returnTypes = RpcUtils.getReturnTypes(invocation); Object value = null; if (ArrayUtils.isEmpty(returnTypes)) { value = in.readObject(); } else if (returnTypes.length == 1) { value = in.readObject((Class<?>) returnTypes[0]); } else { value = in.readObject((Class<?>) returnTypes[0], returnTypes[1]); } setValue(value); } catch (ClassNotFoundException e) { rethrow(e); } }
private void handleValue(ObjectInput in) throws IOException { try { Type[] returnTypes = RpcUtils.getReturnTypes(invocation); Object value = null; if (ArrayUtils.isEmpty(returnTypes)) { value = in.readObject(); } else if (returnTypes.length == 1) { value = in.readObject((Class<?>) returnTypes[0]); } else { value = in.readObject((Class<?>) returnTypes[0], returnTypes[1]); } setValue(value); } catch (ClassNotFoundException e) { rethrow(e); } }