Пример #1
0
 @Override
 default <U> Tree<U> map(Function<? super T, ? extends U> mapper) {
   Objects.requireNonNull(mapper, "mapper is null");
   return isEmpty() ? Empty.instance() : TreeModule.Map.apply((Node<T>) this, mapper);
 }
Пример #2
0
 static <T, U> Node<U> apply(Node<T> node, Function<? super T, ? extends U> mapper) {
   final U value = mapper.apply(node.getValue());
   final List<Node<U>> children = node.getChildren().map(child -> Map.apply(child, mapper));
   return new Node<>(value, children);
 }