| package com.zy.asrs.wcs.utils; | 
|   | 
|   | 
| import java.io.Serializable; | 
| import java.util.function.Function; | 
|   | 
| /** | 
|  * Created by vincent on 2021/1/19 | 
|  */ | 
| public class NodeUtils { | 
|   | 
|     public StringBuilder path = new StringBuilder(); | 
|   | 
|     public StringBuilder pathName = new StringBuilder(); | 
|   | 
|     public interface NodeSupport<T> { | 
|         T query(T t); | 
|     } | 
|   | 
|     public <T, R extends Serializable> void generatePath0( | 
|             NodeSupport<T> support | 
|             , T t | 
|             , Function<? super T, ? extends Long> idMapper | 
|             , Function<? super T, ? extends String> nameMapper | 
|             , Function<? super T, ? extends Long> parentIdMapper) { | 
|         T parent = support.query(t); | 
|         if (null != parent) { | 
|             path.insert(0, idMapper.apply(parent)).insert(0,","); | 
|             pathName.insert(0, nameMapper.apply(parent)).insert(0,","); | 
|             if (parentIdMapper.apply(parent) != null && parentIdMapper.apply(parent) != 0) { | 
|                 generatePath0(support, parent, idMapper, nameMapper, parentIdMapper); | 
|             } else { | 
|                 path.deleteCharAt(0); | 
|                 pathName.deleteCharAt(0); | 
|             } | 
|         } | 
|     } | 
|   | 
|   | 
| } |