Skip to content

Commit a8a62d9

Browse files
authored
Rename Block with Consumer and Function with Supplier.
Replace Function1 with Function, remove Function2 and Function4. Rename classes in lodash, math and string plugin.
1 parent e8e5050 commit a8a62d9

File tree

29 files changed

+577
-591
lines changed

29 files changed

+577
-591
lines changed

lodash-plugin/src/main/java/com/github/underscore/lodash/$.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright 2015-2017 Valentyn Kolesnikov
4+
* Copyright 2015-2018 Valentyn Kolesnikov
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -23,8 +23,8 @@
2323
*/
2424
package com.github.underscore.lodash;
2525

26-
import com.github.underscore.Block;
27-
import com.github.underscore.Function1;
26+
import com.github.underscore.Consumer;
27+
import com.github.underscore.Function;
2828
import com.github.underscore.Function3;
2929
import com.github.underscore.FunctionAccum;
3030
import com.github.underscore.Predicate;
@@ -157,7 +157,7 @@ public Chain flatten() {
157157
return new Chain($.flatten(value()));
158158
}
159159

160-
public <F> Chain<F> map(final Function1<? super T, F> func) {
160+
public <F> Chain<F> map(final Function<? super T, F> func) {
161161
return new Chain<F>($.map(value(), func));
162162
}
163163

@@ -202,7 +202,7 @@ public Chain<Comparable> max() {
202202
return new Chain<Comparable>($.max((Collection) value()));
203203
}
204204

205-
public <F extends Comparable<? super F>> Chain<T> max(final Function1<T, F> func) {
205+
public <F extends Comparable<? super F>> Chain<T> max(final Function<T, F> func) {
206206
return new Chain<T>($.max(value(), func));
207207
}
208208

@@ -211,7 +211,7 @@ public Chain<Comparable> min() {
211211
return new Chain<Comparable>($.min((Collection) value()));
212212
}
213213

214-
public <F extends Comparable<? super F>> Chain<T> min(final Function1<T, F> func) {
214+
public <F extends Comparable<? super F>> Chain<T> min(final Function<T, F> func) {
215215
return new Chain<T>($.min(value(), func));
216216
}
217217

@@ -225,7 +225,7 @@ public <F extends Comparable<? super F>> Chain<F> sortWith(final Comparator<F> c
225225
return new Chain<F>($.sortWith((List<F>) value(), comparator));
226226
}
227227

228-
public <F extends Comparable<? super F>> Chain<T> sortBy(final Function1<T, F> func) {
228+
public <F extends Comparable<? super F>> Chain<T> sortBy(final Function<T, F> func) {
229229
return new Chain<T>($.sortBy(value(), func));
230230
}
231231

@@ -234,15 +234,15 @@ public <K> Chain<Map<K, Comparable>> sortBy(final K key) {
234234
return new Chain<Map<K, Comparable>>($.sortBy((List<Map<K, Comparable>>) value(), key));
235235
}
236236

237-
public <F> Chain<Map<F, List<T>>> groupBy(final Function1<T, F> func) {
237+
public <F> Chain<Map<F, List<T>>> groupBy(final Function<T, F> func) {
238238
return new Chain<Map<F, List<T>>>($.groupBy(value(), func));
239239
}
240240

241241
public Chain<Map<Object, List<T>>> indexBy(final String property) {
242242
return new Chain<Map<Object, List<T>>>($.indexBy(value(), property));
243243
}
244244

245-
public <F> Chain<Map<F, Integer>> countBy(final Function1<T, F> func) {
245+
public <F> Chain<Map<F, Integer>> countBy(final Function<T, F> func) {
246246
return new Chain<Map<F, Integer>>($.countBy(value(), func));
247247
}
248248

@@ -258,17 +258,17 @@ public Chain<T> sample(final int howMany) {
258258
return new Chain<T>($.newArrayList($.sample(value(), howMany)));
259259
}
260260

261-
public Chain<T> tap(final Block<T> func) {
261+
public Chain<T> tap(final Consumer<T> func) {
262262
$.tap(value(), func);
263263
return new Chain<T>(value());
264264
}
265265

266-
public Chain<T> forEach(final Block<T> func) {
266+
public Chain<T> forEach(final Consumer<T> func) {
267267
$.forEach(value(), func);
268268
return new Chain<T>(value());
269269
}
270270

271-
public Chain<T> forEachRight(final Block<T> func) {
271+
public Chain<T> forEachRight(final Consumer<T> func) {
272272
$.forEachRight(value(), func);
273273
return new Chain<T>(value());
274274
}
@@ -310,7 +310,7 @@ public Chain<T> uniq() {
310310
}
311311

312312
@SuppressWarnings("unchecked")
313-
public <F> Chain<T> uniq(final Function1<T, F> func) {
313+
public <F> Chain<T> uniq(final Function<T, F> func) {
314314
return new Chain<T>($.newArrayList($.uniq(value(), func)));
315315
}
316316

@@ -319,7 +319,7 @@ public Chain<T> distinct() {
319319
}
320320

321321
@SuppressWarnings("unchecked")
322-
public <F> Chain<F> distinctBy(final Function1<T, F> func) {
322+
public <F> Chain<F> distinctBy(final Function<T, F> func) {
323323
return new Chain<F>($.newArrayList((Iterable<F>) $.uniq(value(), func)));
324324
}
325325

@@ -478,7 +478,7 @@ public <F extends Number> Chain<F> sum() {
478478
return new Chain<F>($.sum((List<F>) value()));
479479
}
480480

481-
public <F extends Number> Chain<F> sum(final Function1<T, F> func) {
481+
public <F extends Number> Chain<F> sum(final Function<T, F> func) {
482482
return new Chain<F>($.sum(value(), func));
483483
}
484484

@@ -781,7 +781,7 @@ public static <T> List<T> remove(final List<T> list, final Predicate<T> pred) {
781781
final List<T> result = newArrayList();
782782
for (final Iterator<T> iterator = list.iterator(); iterator.hasNext(); ) {
783783
final T object = iterator.next();
784-
if (pred.apply(object)) {
784+
if (pred.test(object)) {
785785
result.add(object);
786786
iterator.remove();
787787
}
@@ -884,7 +884,7 @@ public static <T extends Number> T sum(final Iterable<T> iterable) {
884884
return result;
885885
}
886886

887-
public static <E, F extends Number> F sum(final Iterable<E> iterable, final Function1<E, F> func) {
887+
public static <E, F extends Number> F sum(final Iterable<E> iterable, final Function<E, F> func) {
888888
F result = null;
889889
for (final E item : iterable) {
890890
result = add(result, func.apply(item));
@@ -898,7 +898,7 @@ public <F extends Number> F sum() {
898898
}
899899

900900
@SuppressWarnings("unchecked")
901-
public <E, F extends Number> F sum(final Function1<E, F> func) {
901+
public <E, F extends Number> F sum(final Function<E, F> func) {
902902
return sum((List<E>) getIterable(), func);
903903
}
904904

@@ -1047,9 +1047,9 @@ public static List<String> words(final String string) {
10471047
return result;
10481048
}
10491049

1050-
private static Function1<String, String> createCompounder(
1050+
private static Function<String, String> createCompounder(
10511051
final Function3<String, String, Integer, String> callback) {
1052-
return new Function1<String, String>() {
1052+
return new Function<String, String>() {
10531053
public String apply(final String string) {
10541054
int index = -1;
10551055
List<String> array = words(deburr(string));
@@ -1064,8 +1064,8 @@ public String apply(final String string) {
10641064
};
10651065
}
10661066

1067-
private static Function1<String, String> createCaseFirst(final String methodName) {
1068-
return new Function1<String, String>() {
1067+
private static Function<String, String> createCaseFirst(final String methodName) {
1068+
return new Function<String, String>() {
10691069
public String apply(final String string) {
10701070
final String localString = baseToString(string);
10711071
final String chr = localString.isEmpty() ? "" : localString.substring(0, 1);

0 commit comments

Comments
 (0)