| | |
| | | |
| | | import com.zy.acs.framework.common.Cools; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.*; |
| | | import java.util.concurrent.ThreadLocalRandom; |
| | | import java.util.function.BiConsumer; |
| | | import java.util.function.Function; |
| | | |
| | |
| | | if (parentId.equals(dParentId)) { |
| | | R dId = idMapper.apply(d); |
| | | List<T> children = toTreeData(data, dId, parentIdMapper, idMapper, consumer); |
| | | if(children.size() > 0) { |
| | | if(!children.isEmpty()) { |
| | | consumer.accept(d, children); |
| | | } |
| | | result.add(d); |
| | |
| | | |
| | | /** |
| | | * 数组倒序 |
| | | * @param bytes |
| | | * @param <T> |
| | | */ |
| | | public static <T> byte[] reverse(byte[] bytes) { |
| | | if (bytes == null) return null; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 大驼峰 转 symbol小驼峰 |
| | | */ |
| | | public static String toSymbolCase(String str, char symbol) { |
| | | if (str == null) { |
| | | return null; |
| | |
| | | return list; |
| | | } |
| | | |
| | | public static String convertToSnakeCaseForOrderByStr(String input) { |
| | | String[] parts = input.split("\\s+"); |
| | | String fieldName = parts[0]; |
| | | String order = parts.length > 1 ? parts[1] : ""; |
| | | |
| | | String snakeCaseField = fieldName.replaceAll("([a-z])([A-Z])", "$1_$2").toLowerCase(); |
| | | |
| | | return snakeCaseField + (order.isEmpty() ? "" : " " + order); |
| | | } |
| | | |
| | | public static String processTemplate(String template, Map<String, Object> params) { |
| | | if (template == null || params == null) { |
| | | return template; |
| | | } |
| | | String processed = template; |
| | | for (Map.Entry<String, Object> entry : params.entrySet()) { |
| | | processed = processed.replace("${" + entry.getKey() + "}", entry.getValue().toString()); |
| | | } |
| | | return processed; |
| | | } |
| | | |
| | | public static String randomNumbers(int length) { |
| | | String baseString = "0123456789"; |
| | | |
| | | if (length < 1) { |
| | | length = 1; |
| | | } |
| | | |
| | | StringBuilder sb = new StringBuilder(length); |
| | | int baseLength = baseString.length(); |
| | | |
| | | for(int i = 0; i < length; ++i) { |
| | | int number = ThreadLocalRandom.current().nextInt(baseLength); |
| | | sb.append(baseString.charAt(number)); |
| | | } |
| | | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | } |