### Question:
BundleFilterForeach implements BundleFilter { @Override public boolean filter(Bundle row) { boolean success = true; ValueObject object = source.getValue(row); if (object == null) { return false; } ValueArray array = object.asArray(); for (int i = 0; i < array.size(); i++) { if (index != null) { index.setValue(row, ValueFactory.create(i)); } if (value != null) { value.setValue(row, array.get(i)); } success &= filter.filter(row); if (!success && exitOnFailure) { return false; } } if (index != null) { index.setValue(row, ValueFactory.create(array.size())); } return success; } @JsonCreator  BundleFilterForeach(@JsonProperty(value = "filter", required = true) BundleFilter filter,
                               @JsonProperty(value = "source", required = true) AutoField source,
                               @JsonProperty("index") AutoField index,
                               @JsonProperty("value") AutoField value,
                               @JsonProperty("exitOnFailure") boolean exitOnFailure); @Override boolean filter(Bundle row);  }### Answer:
@Test public void foreachUsingIndex() throws Exception { BundleFilterForeach filter = Configs.decodeObject(BundleFilterForeach.class, "filter: " + "[{op:field, from:SOURCE, to:ELEMENT, " + "filter:{op:index, index.field:INDEX }}, " + "{op:concat, in:[ OUTPUT, ELEMENT ], " + "out: OUTPUT, join: \":\"}]," + "source:SOURCE ," + "index:INDEX,"); ValueArray array = ValueFactory.createArray(3); array.add(ValueFactory.create("foo")); array.add(ValueFactory.create("bar")); array.add(ValueFactory.create("baz")); AutoField source = AutoField.newAutoField("SOURCE"); AutoField output = AutoField.newAutoField("OUTPUT"); ListBundle bundle = new ListBundle(); source.setValue(bundle, array); output.setValue(bundle, ValueFactory.create("")); assertTrue(filter.filter(bundle)); assertEquals(":foo:bar:baz", output.getString(bundle).get()); }
@Test public void foreachUsingValue() throws Exception { BundleFilterForeach filter = Configs.decodeObject(BundleFilterForeach.class, "filter: {op:concat, in:[ OUTPUT, ELEMENT ], " + "out: OUTPUT, join: \":\"}," + "source:SOURCE ," + "value:ELEMENT,"); ValueArray array = ValueFactory.createArray(3); array.add(ValueFactory.create("foo")); array.add(ValueFactory.create("bar")); array.add(ValueFactory.create("baz")); AutoField source = AutoField.newAutoField("SOURCE"); AutoField output = AutoField.newAutoField("OUTPUT"); ListBundle bundle = new ListBundle(); source.setValue(bundle, array); output.setValue(bundle, ValueFactory.create("")); assertTrue(filter.filter(bundle)); assertEquals(":foo:bar:baz", output.getString(bundle).get()); }