protected void processResult(int[] lastResult) { boolean foundError = false; for (int i : lastResult) { if (i == Statement.EXECUTE_FAILED) foundError = true; results.add(i); } // A little bit of paranoid checking here? Most drivers will throw BatchUpdateException perhaps? if (batchCount != lastResult.length) { log.warning("Problem executing batch - expected result length of " + batchCount + " but got " + lastResult.length); } else if (foundError) { log.warning("Problem executing batch - at least one result failed in: " + DefaultGroovyMethods.toList(lastResult)); } else { log.fine("Successfully executed batch with " + lastResult.length + " command(s)"); } }
public ReplaceState(Map<CharSequence, CharSequence> replacements) { this.noMoreMatches = new boolean[replacements.size()]; this.replacementsList = DefaultGroovyMethods.toList((Iterable<Map.Entry<CharSequence,CharSequence>>) replacements.entrySet()); }
public static <T> List<List<T>> inits(Iterable<T> collections) { List<T> copy = DefaultGroovyMethods.toList(collections); List<List<T>> result = new ArrayList<List<T>>(); for (int i = copy.size(); i >= 0; i--) { List<T> next = copy.subList(0, i); result.add(next); } return result; }
public static <T> List<List<T>> tails(Iterable<T> collections) { List<T> copy = DefaultGroovyMethods.toList(collections); List<List<T>> result = new ArrayList<List<T>>(); for (int i = 0; i <= copy.size(); i++) { List<T> next = copy.subList(i, copy.size()); result.add(next); } return result; }
/** * Selects the minimum value found from the Object array using the given comparator. * * @param self an array * @param comparator a Comparator * @return the minimum value * @see #min(java.util.Collection, java.util.Comparator) * @since 1.5.5 */ public static <T> T min(T[] self, Comparator<T> comparator) { return min((Iterable<T>)toList(self), comparator); }
/** * Adds max() method to Iterator objects. The iterator will become * exhausted of elements after determining the maximum value. * * @param self an Iterator * @return the maximum value * @see groovy.util.GroovyCollections#max(java.util.Collection) * @since 1.5.5 */ public static <T> T max(Iterator<T> self) { return max((Iterable<T>)toList(self)); }
/** * Flatten an array. This array and any nested arrays or * collections have their contents (recursively) added to the new collection. * * @param self a char Array to flatten * @return a flattened Collection * @since 1.6.0 */ public static Collection flatten(char[] self) { return flatten(toList(self), new ArrayList()); }
/** * Adds min() method to Object arrays. * * @param self an array * @return the minimum value * @see #min(java.util.Collection) * @since 1.5.5 */ public static <T> T min(T[] self) { return min((Iterable<T>)toList(self)); }
/** * Selects the maximum value found from the Iterator using the given comparator. * * @param self an Iterator * @param comparator a Comparator * @return the maximum value * @since 1.5.5 */ public static <T> T max(Iterator<T> self, Comparator<T> comparator) { return max((Iterable<T>)toList(self), comparator); }
/** * Flatten an array. This array and any nested arrays or * collections have their contents (recursively) added to the new collection. * * @param self a short Array to flatten * @return a flattened Collection * @since 1.6.0 */ public static Collection flatten(short[] self) { return flatten(toList(self), new ArrayList()); }
/** * Sums the items from an Iterator. This is equivalent to invoking the * "plus" method on all items from the Iterator. The iterator will become * exhausted of elements after determining the sum value. * * @param self an Iterator for the values to add together * @return The sum of all of the items * @since 1.5.5 */ public static Object sum(Iterator<Object> self) { return sum(toList(self), null, true); }
/** * Sums the items in an array, adding the result to some initial value. * * @param self an array of values to sum * @param initialValue the items in the array will be summed to this initial value * @return The sum of all of the items. * @since 1.7.1 */ public static Object sum(Object[] self, Object initialValue) { return sum(toList(self), initialValue, false); }
/** * Selects the maximum value found from the Object array using the given comparator. * * @param self an array * @param comparator a Comparator * @return the maximum value * @since 1.5.5 */ public static <T> T max(T[] self, Comparator<T> comparator) { return max((Iterable<T>)toList(self), comparator); }
/** * Reverses the iterator. The original iterator will become * exhausted of elements after determining the reversed values. * A new iterator for iterating through the reversed values is returned. * * @param self an Iterator * @return a reversed Iterator * @since 1.5.5 */ public static <T> Iterator<T> reverse(Iterator<T> self) { return new ReverseListIterator<T>(toList(self)); }
/** * Flatten an array. This array and any nested arrays or * collections have their contents (recursively) added to the new collection. * * @param self a long Array to flatten * @return a flattened Collection * @since 1.6.0 */ public static Collection flatten(long[] self) { return flatten(toList(self), new ArrayList()); }
/** * Flatten an array. This array and any nested arrays or * collections have their contents (recursively) added to the new collection. * * @param self a float Array to flatten * @return a flattened Collection * @since 1.6.0 */ public static Collection flatten(float[] self) { return flatten(toList(self), new ArrayList()); }
/** * Adds min() method to Iterator objects. The iterator will become * exhausted of elements after determining the minimum value. * * @param self an Iterator * @return the minimum value * @see #min(java.util.Collection) * @since 1.5.5 */ public static <T> T min(Iterator<T> self) { return min((Iterable<T>)toList(self)); }
/** * Flatten an array. This array and any nested arrays or * collections have their contents (recursively) added to the new collection. * * @param self an Array to flatten * @return a flattened Collection * @since 1.6.0 */ public static Collection flatten(Object[] self) { return flatten(toList(self), new ArrayList()); }
/** * Flatten an array. This array and any nested arrays or * collections have their contents (recursively) added to the new collection. * * @param self a boolean Array to flatten * @return a flattened Collection * @since 1.6.0 */ public static Collection flatten(boolean[] self) { return flatten(toList(self), new ArrayList()); }
/** * Flatten an array. This array and any nested arrays or * collections have their contents (recursively) added to the new collection. * * @param self a double Array to flatten * @return a flattened Collection * @since 1.6.0 */ public static Collection flatten(double[] self) { return flatten(toList(self), new ArrayList()); }