return (boolean[]) remove((Object) array, index);
return (long[]) remove((Object) array, index);
return (char[]) remove((Object) array, index);
return (float[]) remove((Object) array, index);
return (byte[]) remove((Object) array, index);
/** * Local helper method to unroll variables in a type bounds array. * * @param typeArguments assignments {@link Map} * @param bounds in which to expand variables * @return {@code bounds} with any variables reassigned * @since 3.2 */ private static Type[] unrollBounds(final Map<TypeVariable<?>, Type> typeArguments, final Type[] bounds) { Type[] result = bounds; int i = 0; for (; i < result.length; i++) { final Type unrolled = unrollVariables(typeArguments, result[i]); if (unrolled == null) { result = ArrayUtils.remove(result, i--); } else { result[i] = unrolled; } } return result; }
public void removeCustomCriteria(String criteria) { int pos = getCriteriaIndex(criteria); if (pos >= 0) { customCriteria = ArrayUtils.remove(customCriteria, pos); } }
@Test(expected = IndexOutOfBoundsException.class) public void testRemoveAllNullObjectArray() { ArrayUtils.remove((Object[]) null, 0); }
public static Object[] createArgsForFallback(Object[] args, MetaHolder metaHolder, Throwable exception) { if (metaHolder.isExtendedFallback()) { if (metaHolder.isExtendedParentFallback()) { args[args.length - 1] = exception; } else { args = Arrays.copyOf(args, args.length + 1); args[args.length - 1] = exception; } } else { if (metaHolder.isExtendedParentFallback()) { args = ArrayUtils.remove(args, args.length - 1); } } return args; } }
@Test public void testRemoveNumberArray(){ final Number[] inarray = {Integer.valueOf(1),Long.valueOf(2),Byte.valueOf((byte) 3)}; assertEquals(3, inarray.length); Number[] outarray; outarray = ArrayUtils.remove(inarray, 1); assertEquals(2, outarray.length); assertEquals(Number.class, outarray.getClass().getComponentType()); outarray = ArrayUtils.remove(outarray, 1); assertEquals(1, outarray.length); assertEquals(Number.class, outarray.getClass().getComponentType()); outarray = ArrayUtils.remove(outarray, 0); assertEquals(0, outarray.length); assertEquals(Number.class, outarray.getClass().getComponentType()); }
@Override public void removeChildAtIndex(final int childIndex) { if (0 <= childIndex && childIndex < jjtGetNumChildren()) { // Remove the child at the given index children = ArrayUtils.remove(children, childIndex); // Update the remaining & left-shifted children indexes for (int i = childIndex; i < jjtGetNumChildren(); i++) { jjtGetChild(i).jjtSetChildIndex(i); } } }
@Test public void testRemoveLongArray() { long[] array; array = ArrayUtils.remove(new long[] {1}, 0); assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array)); assertEquals(Long.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new long[] {1, 2}, 0); assertTrue(Arrays.equals(new long[] {2}, array)); assertEquals(Long.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new long[] {1, 2}, 1); assertTrue(Arrays.equals(new long[] {1}, array)); assertEquals(Long.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new long[] {1, 2, 1}, 1); assertTrue(Arrays.equals(new long[] {1, 1}, array)); assertEquals(Long.TYPE, array.getClass().getComponentType()); try { ArrayUtils.remove(new long[] {1, 2}, -1); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove(new long[] {1, 2}, 2); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove((long[]) null, 0); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} }
@Test public void testRemoveCharArray() { char[] array; array = ArrayUtils.remove(new char[] {'a'}, 0); assertTrue(Arrays.equals(ArrayUtils.EMPTY_CHAR_ARRAY, array)); assertEquals(Character.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new char[] {'a', 'b'}, 0); assertTrue(Arrays.equals(new char[] {'b'}, array)); assertEquals(Character.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new char[] {'a', 'b'}, 1); assertTrue(Arrays.equals(new char[] {'a'}, array)); assertEquals(Character.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new char[] {'a', 'b', 'c'}, 1); assertTrue(Arrays.equals(new char[] {'a', 'c'}, array)); assertEquals(Character.TYPE, array.getClass().getComponentType()); try { ArrayUtils.remove(new char[] {'a', 'b'}, -1); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove(new char[] {'a', 'b'}, 2); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove((char[]) null, 0); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} }
@Test public void testRemoveDoubleArray() { double[] array; array = ArrayUtils.remove(new double[] {1}, 0); assertTrue(Arrays.equals(ArrayUtils.EMPTY_DOUBLE_ARRAY, array)); assertEquals(Double.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new double[] {1, 2}, 0); assertTrue(Arrays.equals(new double[] {2}, array)); assertEquals(Double.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new double[] {1, 2}, 1); assertTrue(Arrays.equals(new double[] {1}, array)); assertEquals(Double.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new double[] {1, 2, 1}, 1); assertTrue(Arrays.equals(new double[] {1, 1}, array)); assertEquals(Double.TYPE, array.getClass().getComponentType()); try { ArrayUtils.remove(new double[] {1, 2}, -1); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove(new double[] {1, 2}, 2); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove((double[]) null, 0); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} }
@Test public void testRemoveBooleanArray() { boolean[] array; array = ArrayUtils.remove(new boolean[] {true}, 0); assertTrue(Arrays.equals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, array)); assertEquals(Boolean.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new boolean[] {true, false}, 0); assertTrue(Arrays.equals(new boolean[] {false}, array)); assertEquals(Boolean.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new boolean[] {true, false}, 1); assertTrue(Arrays.equals(new boolean[] {true}, array)); assertEquals(Boolean.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new boolean[] {true, false, true}, 1); assertTrue(Arrays.equals(new boolean[] {true, true}, array)); assertEquals(Boolean.TYPE, array.getClass().getComponentType()); try { ArrayUtils.remove(new boolean[] {true, false}, -1); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove(new boolean[] {true, false}, 2); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove((boolean[]) null, 0); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} }
@Test public void testRemoveByteArray() { byte[] array; array = ArrayUtils.remove(new byte[] {1}, 0); assertTrue(Arrays.equals(ArrayUtils.EMPTY_BYTE_ARRAY, array)); assertEquals(Byte.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new byte[] {1, 2}, 0); assertTrue(Arrays.equals(new byte[] {2}, array)); assertEquals(Byte.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new byte[] {1, 2}, 1); assertTrue(Arrays.equals(new byte[] {1}, array)); assertEquals(Byte.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new byte[] {1, 2, 1}, 1); assertTrue(Arrays.equals(new byte[] {1, 1}, array)); assertEquals(Byte.TYPE, array.getClass().getComponentType()); try { ArrayUtils.remove(new byte[] {1, 2}, -1); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove(new byte[] {1, 2}, 2); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove((byte[]) null, 0); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} }
@Test public void testRemoveFloatArray() { float[] array; array = ArrayUtils.remove(new float[] {1}, 0); assertTrue(Arrays.equals(ArrayUtils.EMPTY_FLOAT_ARRAY, array)); assertEquals(Float.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new float[] {1, 2}, 0); assertTrue(Arrays.equals(new float[] {2}, array)); assertEquals(Float.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new float[] {1, 2}, 1); assertTrue(Arrays.equals(new float[] {1}, array)); assertEquals(Float.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new float[] {1, 2, 1}, 1); assertTrue(Arrays.equals(new float[] {1, 1}, array)); assertEquals(Float.TYPE, array.getClass().getComponentType()); try { ArrayUtils.remove(new float[] {1, 2}, -1); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove(new float[] {1, 2}, 2); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove((float[]) null, 0); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} }
@Test public void testRemoveObjectArray() { Object[] array; array = ArrayUtils.remove(new Object[] {"a"}, 0); assertTrue(Arrays.equals(ArrayUtils.EMPTY_OBJECT_ARRAY, array)); assertEquals(Object.class, array.getClass().getComponentType()); array = ArrayUtils.remove(new Object[] {"a", "b"}, 0); assertTrue(Arrays.equals(new Object[] {"b"}, array)); assertEquals(Object.class, array.getClass().getComponentType()); array = ArrayUtils.remove(new Object[] {"a", "b"}, 1); assertTrue(Arrays.equals(new Object[] {"a"}, array)); assertEquals(Object.class, array.getClass().getComponentType()); array = ArrayUtils.remove(new Object[] {"a", "b", "c"}, 1); assertTrue(Arrays.equals(new Object[] {"a", "c"}, array)); assertEquals(Object.class, array.getClass().getComponentType()); try { ArrayUtils.remove(new Object[] {"a", "b"}, -1); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove(new Object[] {"a", "b"}, 2); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove((Object[]) null, 0); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} }
@Test public void testRemoveIntArray() { int[] array; array = ArrayUtils.remove(new int[] {1}, 0); assertTrue(Arrays.equals(ArrayUtils.EMPTY_INT_ARRAY, array)); assertEquals(Integer.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new int[] {1, 2}, 0); assertTrue(Arrays.equals(new int[] {2}, array)); assertEquals(Integer.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new int[] {1, 2}, 1); assertTrue(Arrays.equals(new int[] {1}, array)); assertEquals(Integer.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new int[] {1, 2, 1}, 1); assertTrue(Arrays.equals(new int[] {1, 1}, array)); assertEquals(Integer.TYPE, array.getClass().getComponentType()); try { ArrayUtils.remove(new int[] {1, 2}, -1); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove(new int[] {1, 2}, 2); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove((int[]) null, 0); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} }
@Test public void testRemoveShortArray() { short[] array; array = ArrayUtils.remove(new short[] {1}, 0); assertTrue(Arrays.equals(ArrayUtils.EMPTY_SHORT_ARRAY, array)); assertEquals(Short.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new short[] {1, 2}, 0); assertTrue(Arrays.equals(new short[] {2}, array)); assertEquals(Short.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new short[] {1, 2}, 1); assertTrue(Arrays.equals(new short[] {1}, array)); assertEquals(Short.TYPE, array.getClass().getComponentType()); array = ArrayUtils.remove(new short[] {1, 2, 1}, 1); assertTrue(Arrays.equals(new short[] {1, 1}, array)); assertEquals(Short.TYPE, array.getClass().getComponentType()); try { ArrayUtils.remove(new short[] {1, 2}, -1); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove(new short[] {1, 2}, 2); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} try { ArrayUtils.remove((short[]) null, 0); fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} }