MCPcopy Index your code
hub / github.com/XF-FS/APIKit / randomChoice

Method randomChoice

src/main/java/burp/utils/CommonUtils.java:144–158  ·  view source on GitHub ↗
(Collection<? extends E> input)

Source from the content-addressed store, hash-verified

142 }
143
144 @SuppressWarnings("unchecked")
145 public static <E> E randomChoice(Collection<? extends E> input) {
146 if (input == null || input.isEmpty()) {
147 return null;
148 }
149
150 int idx = new SecureRandom().nextInt(input.size());
151
152 if (input instanceof List) {
153 return ((List<E>) input).get(idx);
154 }
155
156 // 如果不是 List,则转换为 ArrayList 后再获取
157 return new ArrayList<>(input).get(idx);
158 }
159
160 public static String exceptionToString(Throwable throwable) {
161 StringWriter sw = new StringWriter();

Callers 1

exportToQueryMethod · 0.95

Calls 1

getMethod · 0.80

Tested by

no test coverage detected