@Test public void shouldMergeOneArray() { final IJsonNode result = new ArrayMerger().evaluate( createArrayNode(createArrayNode(createObjectNode("fieldName", 1), createObjectNode("fieldName", 2), createObjectNode("fieldName", 3), createObjectNode("fieldName", 4), createObjectNode("fieldName", 5)))); Assert.assertEquals(createArrayNode(createObjectNode("fieldName", 1), createObjectNode("fieldName", 2), createObjectNode("fieldName", 3), createObjectNode("fieldName", 4), createObjectNode("fieldName", 5)), result); }
@Override public IJsonNode evaluate(final IJsonNode node) { this.result.clear(); for (final IJsonNode nextNode : (IArrayNode<?>) node) if (nextNode != NullNode.getInstance()) { final IArrayNode<?> array = (IArrayNode<?>) nextNode; for (int index = 0; index < array.size(); index++) if (this.result.size() <= index) this.result.add(array.get(index)); else if (this.isNull(this.result.get(index)) && !this.isNull(array.get(index))) this.result.set(index, array.get(index)); } return this.result; }
ArrayMerger extends EvaluationExpression { @Override public IJsonNode evaluate(final IJsonNode node) { this.result.clear(); for (final IJsonNode nextNode : (IArrayNode<?>) node) if (nextNode != NullNode.getInstance()) { final IArrayNode<?> array = (IArrayNode<?>) nextNode; for (int index = 0; index < array.size(); index++) if (this.result.size() <= index) this.result.add(array.get(index)); else if (this.isNull(this.result.get(index)) && !this.isNull(array.get(index))) this.result.set(index, array.get(index)); } return this.result; } }
ArrayMerger extends EvaluationExpression { @Override public IJsonNode evaluate(final IJsonNode node) { this.result.clear(); for (final IJsonNode nextNode : (IArrayNode<?>) node) if (nextNode != NullNode.getInstance()) { final IArrayNode<?> array = (IArrayNode<?>) nextNode; for (int index = 0; index < array.size(); index++) if (this.result.size() <= index) this.result.add(array.get(index)); else if (this.isNull(this.result.get(index)) && !this.isNull(array.get(index))) this.result.set(index, array.get(index)); } return this.result; }  }
ArrayMerger extends EvaluationExpression { @Override public IJsonNode evaluate(final IJsonNode node) { this.result.clear(); for (final IJsonNode nextNode : (IArrayNode<?>) node) if (nextNode != NullNode.getInstance()) { final IArrayNode<?> array = (IArrayNode<?>) nextNode; for (int index = 0; index < array.size(); index++) if (this.result.size() <= index) this.result.add(array.get(index)); else if (this.isNull(this.result.get(index)) && !this.isNull(array.get(index))) this.result.set(index, array.get(index)); } return this.result; }  @Override void appendAsString(final Appendable appendable); @Override IJsonNode evaluate(final IJsonNode node); }
ArrayMerger extends EvaluationExpression { @Override public IJsonNode evaluate(final IJsonNode node) { this.result.clear(); for (final IJsonNode nextNode : (IArrayNode<?>) node) if (nextNode != NullNode.getInstance()) { final IArrayNode<?> array = (IArrayNode<?>) nextNode; for (int index = 0; index < array.size(); index++) if (this.result.size() <= index) this.result.add(array.get(index)); else if (this.isNull(this.result.get(index)) && !this.isNull(array.get(index))) this.result.set(index, array.get(index)); } return this.result; }  @Override void appendAsString(final Appendable appendable); @Override IJsonNode evaluate(final IJsonNode node);  }