@@ -48,9 +48,10 @@ public static <T, U> U requireNonNullElseGet(T value, Function<? super T, ? exte
4848
4949 /**
5050 * Construct a mutable map by given key-value pairs.
51+ *
5152 * @param pairs entries in the new map
52- * @param <K> the type of keys
53- * @param <V> the type of values
53+ * @param <K> the type of keys
54+ * @param <V> the type of values
5455 * @return the map which contains data in {@code pairs}.
5556 */
5657 @ SafeVarargs
@@ -60,9 +61,10 @@ public static <K, V> Map<K, V> mapOf(Pair<K, V>... pairs) {
6061
6162 /**
6263 * Construct a mutable map by given key-value pairs.
64+ *
6365 * @param pairs entries in the new map
64- * @param <K> the type of keys
65- * @param <V> the type of values
66+ * @param <K> the type of keys
67+ * @param <V> the type of values
6668 * @return the map which contains data in {@code pairs}.
6769 */
6870 public static <K , V > Map <K , V > mapOf (Iterable <Pair <K , V >> pairs ) {
@@ -122,9 +124,10 @@ public static <T> T ignoringException(ExceptionalSupplier<T, ?> supplier, T defa
122124
123125 /**
124126 * Cast {@code obj} to V dynamically.
125- * @param obj the object reference to be cast.
127+ *
128+ * @param obj the object reference to be cast.
126129 * @param clazz the class reference of {@code V}.
127- * @param <V> the type that {@code obj} is being cast to.
130+ * @param <V> the type that {@code obj} is being cast to.
128131 * @return {@code obj} in the type of {@code V}.
129132 */
130133 public static <V > Optional <V > tryCast (Object obj , Class <V > clazz ) {
@@ -154,8 +157,8 @@ public static <T> List<T> removingDuplicates(List<T> list) {
154157 /**
155158 * Join two collections into one list.
156159 *
157- * @param a one collection, to be joined.
158- * @param b another collection to be joined.
160+ * @param a one collection, to be joined.
161+ * @param b another collection to be joined.
159162 * @param <T> the super type of elements in {@code a} and {@code b}
160163 * @return the joint collection
161164 */
@@ -172,6 +175,16 @@ public static <T> List<T> copyList(List<T> list) {
172175 return list == null ? null : list .isEmpty () ? null : new ArrayList <>(list );
173176 }
174177
178+ public static <T > int indexWhere (List <T > list , Predicate <T > predicate ) {
179+ int idx = 0 ;
180+ for (T value : list ) {
181+ if (predicate .test (value ))
182+ return idx ;
183+ idx ++;
184+ }
185+ return -1 ;
186+ }
187+
175188 public static void executeDelayed (Runnable runnable , TimeUnit timeUnit , long timeout , boolean isDaemon ) {
176189 thread (() -> {
177190 try {
@@ -185,6 +198,7 @@ public static void executeDelayed(Runnable runnable, TimeUnit timeUnit, long tim
185198
186199 /**
187200 * Start a thread invoking {@code runnable} immediately.
201+ *
188202 * @param runnable code to run.
189203 * @return the reference of the started thread
190204 */
@@ -194,8 +208,9 @@ public static Thread thread(Runnable runnable) {
194208
195209 /**
196210 * Start a thread invoking {@code runnable} immediately.
211+ *
197212 * @param runnable code to run
198- * @param name the name of thread
213+ * @param name the name of thread
199214 * @return the reference of the started thread
200215 */
201216 public static Thread thread (Runnable runnable , String name ) {
@@ -204,8 +219,9 @@ public static Thread thread(Runnable runnable, String name) {
204219
205220 /**
206221 * Start a thread invoking {@code runnable} immediately.
222+ *
207223 * @param runnable code to run
208- * @param name the name of thread
224+ * @param name the name of thread
209225 * @param isDaemon true if thread will be terminated when only daemon threads are running.
210226 * @return the reference of the started thread
211227 */
@@ -258,7 +274,8 @@ public static Double toDoubleOrNull(Object string) {
258274
259275 /**
260276 * Find the first non-null reference in given list.
261- * @param t nullable references list.
277+ *
278+ * @param t nullable references list.
262279 * @param <T> the type of nullable references
263280 * @return the first non-null reference.
264281 */
0 commit comments