|  |  | 
 |  |  |  | 
 |  |  | import javax.servlet.http.HttpServletResponse; | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.Iterator; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Optional; | 
 |  |  | import java.util.function.BiConsumer; | 
 |  |  | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | //    public static <T> List<T> treeRemove(List<T> data, String condition, | 
 |  |  | //                                         Function<? super T, ? extends String> fetcher, | 
 |  |  | //                                         Function<T, List<T>> childrenGetter, | 
 |  |  | //                                         BiConsumer<T, List<T>> childrenSetter) { | 
 |  |  | //        List<T> result = new ArrayList<>(); | 
 |  |  | //        for (T node : data) { | 
 |  |  | //            List<T> children = childrenGetter.apply(node); | 
 |  |  | // | 
 |  |  | //            if (children != null && !children.isEmpty()) { | 
 |  |  | //                List<T> newChildren = treeRemove(children, condition, fetcher, childrenGetter, childrenSetter); | 
 |  |  | //                childrenSetter.accept(node, newChildren); | 
 |  |  | //            } | 
 |  |  | // | 
 |  |  | //            if (fetcher.apply(node).contains(condition)) { | 
 |  |  | //                result.add(node); | 
 |  |  | //            } | 
 |  |  | //        } | 
 |  |  | //        return result; | 
 |  |  | //    } | 
 |  |  |  | 
 |  |  |     public static <T> void treeRemove(List<T> list, String condition, Function<? super T, ? extends String> fetcher, Function<T, List<T>> childrenGetter) { | 
 |  |  |         Iterator<T> iterator = list.iterator(); | 
 |  |  |         while (iterator.hasNext()) { | 
 |  |  |             T next = iterator.next(); | 
 |  |  |             List<T> children = childrenGetter.apply(next); | 
 |  |  |             if (children != null && !children.isEmpty()) { | 
 |  |  |                 treeRemove(children, condition, fetcher, childrenGetter); | 
 |  |  |             } else { | 
 |  |  |                 if (!fetcher.apply(next).contains(condition)) { | 
 |  |  |                     iterator.remove(); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 数组倒序 | 
 |  |  |      * @param bytes |