### Question:
ArrayListTransformer extends AbstractVisitor { public List<?> transform(List<?> list){ int size = list.size(); switch(size){ case 0: return Collections.emptyList(); case 1: return Collections.singletonList(list.get(0)); case 2: return new DoubletonList<>(list.get(0), list.get(1)); default: return list; } }  @Override VisitorAction visit(PMMLObject object); List<?> transform(List<?> list);  }### Answer:
@Test public void transform(){ Node node1a = new BranchNode(); Node node2a = new BranchNode(); Node node2b = new LeafNode(); node1a.addNodes(node2a, node2b); Array array = new ComplexArray() .setType(Array.Type.INT) .setValue(Arrays.asList(-1, 1)); Predicate predicate = new SimpleSetPredicate(FieldName.create("x"), SimpleSetPredicate.BooleanOperator.IS_IN, array); Node node3a = new LeafNode(null, predicate); node2a.addNodes(node3a); assertTrue(node1a.getNodes() instanceof ArrayList); assertTrue(node2a.getNodes() instanceof ArrayList); Object value = array.getValue(); assertTrue(value instanceof ArrayList); assertTrue(value instanceof ComplexValue); TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, new MiningSchema(), node1a); ArrayListTransformer transformer = new ArrayListTransformer(); transformer.applyTo(treeModel); assertTrue(node1a.getNodes() instanceof DoubletonList); assertFalse(node2a.getNodes() instanceof ArrayList); value = array.getValue(); assertTrue(value instanceof ArrayList); assertTrue(value instanceof ComplexValue); }