MCPcopy Index your code
hub / github.com/API-Security/APIKit / randomChoice

Method randomChoice

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

Source from the content-addressed store, hash-verified

92 }
93
94 public static <E> E randomChoice(Collection<? extends E> input) {
95 int idx = new SecureRandom().nextInt(input.size());
96 Iterator<? extends E> iterator = input.iterator();
97
98 if (input instanceof List) { // optimization
99 return ((List<? extends E>) input).get(idx);
100 } else {
101 Iterator<? extends E> iter = input.iterator();
102 for (int i = 0; i < idx; i++) {
103 iter.next();
104 }
105 return iter.next();
106 }
107 }
108
109 public static String exceptionToString(Throwable throwable) {
110 StringWriter sw = new StringWriter();

Callers 1

exportToQueryMethod · 0.95

Calls 1

getMethod · 0.80

Tested by

no test coverage detected