Skip to content

Commit 32d2baa

Browse files
committed
Remove redundant type casting in lodash plugin.
1 parent 802219e commit 32d2baa

File tree

2 files changed

+10
-10
lines changed
  • lodash-plugin/src

2 files changed

+10
-10
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public Chain<T> rest(int n) {
120120

121121
@SuppressWarnings("unchecked")
122122
public Chain flatten() {
123-
return new Chain((List<T>) $.flatten(value()));
123+
return new Chain($.flatten(value()));
124124
}
125125

126126
public <F> Chain<F> map(final Function1<? super T, F> func) {
@@ -353,7 +353,7 @@ public Chain<Object> fill(final Object value, final Integer start, final Integer
353353
}
354354

355355
public Chain<Object> flattenDeep() {
356-
return new Chain<Object>($.flattenDeep((List<?>) value()));
356+
return new Chain<Object>($.flattenDeep(value()));
357357
}
358358

359359
@SuppressWarnings("unchecked")
@@ -404,12 +404,12 @@ public Chain<T> at(final Integer ... indexes) {
404404
}
405405

406406
@SuppressWarnings("unchecked")
407-
public <T extends Number> Chain<T> sum() {
408-
return new Chain<T>($.sum((List<T>) value()));
407+
public <F extends Number> Chain<F> sum() {
408+
return new Chain<F>($.sum((List<F>) value()));
409409
}
410410

411411
public <F extends Number> Chain<F> sum(final Function1<T, F> func) {
412-
return new Chain<F>($.sum((List<T>) value(), func));
412+
return new Chain<F>($.sum(value(), func));
413413
}
414414

415415
@SuppressWarnings("unchecked")
@@ -822,13 +822,13 @@ public static <E, F extends Number> F sum(final Iterable<E> iterable, final Fun
822822
}
823823

824824
@SuppressWarnings("unchecked")
825-
public <T extends Number> T sum() {
826-
return (T) sum((List<T>) getIterable());
825+
public <F extends Number> F sum() {
826+
return sum((List<F>) getIterable());
827827
}
828828

829829
@SuppressWarnings("unchecked")
830830
public <E, F extends Number> F sum(final Function1<E, F> func) {
831-
return (F) sum((List<E>) getIterable(), func);
831+
return sum((List<E>) getIterable(), func);
832832
}
833833

834834
@SuppressWarnings("unchecked")

lodash-plugin/src/test/java/com/github/underscore/lodash/StringTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,11 @@ public void startCase() {
235235
public void startsWith() {
236236
assertTrue($.startsWith("abc", "a"));
237237
assertTrue(new $("abc").startsWith("a"));
238-
assertTrue((Boolean) $.chain("abc").startsWith("a").item());
238+
assertTrue($.chain("abc").startsWith("a").item());
239239
assertFalse($.startsWith("abc", "b"));
240240
assertTrue($.startsWith("abc", "b", 1));
241241
assertTrue(new $("abc").startsWith("b", 1));
242-
assertTrue((Boolean) $.chain("abc").startsWith("b", 1).item());
242+
assertTrue($.chain("abc").startsWith("b", 1).item());
243243
assertFalse($.startsWith("abc", "c", -4));
244244
assertFalse($.startsWith((String) null, (String) null));
245245
assertFalse($.startsWith("1", (String) null));

0 commit comments

Comments
 (0)