@Test(expected = ArrayIndexOutOfBoundsException.class) public void testItemAtOutOfBounds() { ItemAt action = new ItemAt(); action.setIndex(2); ObjectFieldActions.itemAt(action, Arrays.asList(new Object[] {"one", "two"})); }
@AtlasActionProcessor public static Object itemAt(ItemAt itemAt, List<Object> inputs) { if (inputs == null) { return null; } Integer index = itemAt.getIndex() == null ? 0 : itemAt.getIndex(); Object[] array = inputs.toArray(new Object[0]); if (array.length > index) { return array[index]; } else { throw new ArrayIndexOutOfBoundsException(String.format( "Collection '%s' has fewer (%s) than expected (%s)", array, array.length, index)); } }
ObjectFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Object itemAt(ItemAt itemAt, List<Object> inputs) { if (inputs == null) { return null; } Integer index = itemAt.getIndex() == null ? 0 : itemAt.getIndex(); Object[] array = inputs.toArray(new Object[0]); if (array.length > index) { return array[index]; } else { throw new ArrayIndexOutOfBoundsException(String.format( "Collection '%s' has fewer (%s) than expected (%s)", array, array.length, index)); } } }
ObjectFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Object itemAt(ItemAt itemAt, List<Object> inputs) { if (inputs == null) { return null; } Integer index = itemAt.getIndex() == null ? 0 : itemAt.getIndex(); Object[] array = inputs.toArray(new Object[0]); if (array.length > index) { return array[index]; } else { throw new ArrayIndexOutOfBoundsException(String.format( "Collection '%s' has fewer (%s) than expected (%s)", array, array.length, index)); } }  }
ObjectFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Object itemAt(ItemAt itemAt, List<Object> inputs) { if (inputs == null) { return null; } Integer index = itemAt.getIndex() == null ? 0 : itemAt.getIndex(); Object[] array = inputs.toArray(new Object[0]); if (array.length > index) { return array[index]; } else { throw new ArrayIndexOutOfBoundsException(String.format( "Collection '%s' has fewer (%s) than expected (%s)", array, array.length, index)); } }  @AtlasActionProcessor static Integer count(Count action, List<Object> inputs); @AtlasActionProcessor static Boolean contains(Contains contains, List<Object> inputs); @AtlasActionProcessor static Boolean equals(Equals equals, Object input); @AtlasActionProcessor static Boolean isNull(IsNull action, Object input); @AtlasActionProcessor static Object itemAt(ItemAt itemAt, List<Object> inputs); @AtlasActionProcessor static Integer length(Length length, Object input); }
ObjectFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Object itemAt(ItemAt itemAt, List<Object> inputs) { if (inputs == null) { return null; } Integer index = itemAt.getIndex() == null ? 0 : itemAt.getIndex(); Object[] array = inputs.toArray(new Object[0]); if (array.length > index) { return array[index]; } else { throw new ArrayIndexOutOfBoundsException(String.format( "Collection '%s' has fewer (%s) than expected (%s)", array, array.length, index)); } }  @AtlasActionProcessor static Integer count(Count action, List<Object> inputs); @AtlasActionProcessor static Boolean contains(Contains contains, List<Object> inputs); @AtlasActionProcessor static Boolean equals(Equals equals, Object input); @AtlasActionProcessor static Boolean isNull(IsNull action, Object input); @AtlasActionProcessor static Object itemAt(ItemAt itemAt, List<Object> inputs); @AtlasActionProcessor static Integer length(Length length, Object input);  }