| | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.concurrent.ThreadLocalRandom; |
| | | import java.util.function.BiConsumer; |
| | | import java.util.function.Function; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Created by vincent on 2023/3/14 |
| | |
| | | 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(); |
| | | } |
| | | |
| | | } |