Exemplo n.º 1
0
 @SuppressWarnings("unchecked")
 @Override
 default <T1, T2, T3> Tuple3<Tree<T1>, Tree<T2>, Tree<T3>> unzip3(
     Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) {
   Objects.requireNonNull(unzipper, "unzipper is null");
   if (isEmpty()) {
     return Tuple.of(Empty.instance(), Empty.instance(), Empty.instance());
   } else {
     return (Tuple3<Tree<T1>, Tree<T2>, Tree<T3>>) (Object) Unzip.apply3((Node<T>) this, unzipper);
   }
 }
Exemplo n.º 2
0
 static <T, T1, T2, T3> Tuple3<Node<T1>, Node<T2>, Node<T3>> apply3(
     Node<T> node,
     Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>> unzipper) {
   final Tuple3<? extends T1, ? extends T2, ? extends T3> value =
       unzipper.apply(node.getValue());
   final List<Tuple3<Node<T1>, Node<T2>, Node<T3>>> children =
       node.getChildren().map(child -> Unzip.apply3(child, unzipper));
   final Node<T1> node1 = new Node<>(value._1, children.map(t -> t._1));
   final Node<T2> node2 = new Node<>(value._2, children.map(t -> t._2));
   final Node<T3> node3 = new Node<>(value._3, children.map(t -> t._3));
   return Tuple.of(node1, node2, node3);
 }