Skip to content

Commit 5cf3fa1

Browse files
authored
Renamed the method for compacting the list
1 parent 3d90a8e commit 5cf3fa1

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/main/java/com/github/underscore/U.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public Chain<T> compact() {
242242

243243
@Override
244244
public Chain<T> compact(final T falsyValue) {
245-
return new Chain<>(Underscore.compact(value(), falsyValue));
245+
return new Chain<>(Underscore.compactList(value(), falsyValue));
246246
}
247247

248248
@Override

src/main/java/com/github/underscore/Underscore.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,21 +1490,21 @@ public static <E> E[] compact(final E... array) {
14901490
return (E[]) compact(Arrays.asList(array)).toArray();
14911491
}
14921492

1493-
public static <E> List<E> compact(final List<E> list, final E falsyValue) {
1493+
public static <E> List<E> compactList(final List<E> list, final E falsyValue) {
14941494
return filter(list, arg -> !(Objects.equals(arg, falsyValue)));
14951495
}
14961496

14971497
@SuppressWarnings("unchecked")
14981498
public static <E> E[] compact(final E[] array, final E falsyValue) {
1499-
return (E[]) compact(Arrays.asList(array), falsyValue).toArray();
1499+
return (E[]) compactList(Arrays.asList(array), falsyValue).toArray();
15001500
}
15011501

15021502
public List<T> compact() {
15031503
return compact((List<T>) iterable);
15041504
}
15051505

15061506
public List<T> compact(final T falsyValue) {
1507-
return compact((List<T>) iterable, falsyValue);
1507+
return compactList((List<T>) iterable, falsyValue);
15081508
}
15091509

15101510
/*
@@ -2898,7 +2898,7 @@ public Chain<T> compact() {
28982898
}
28992899

29002900
public Chain<T> compact(final T falsyValue) {
2901-
return new Chain<>(Underscore.compact(list, falsyValue));
2901+
return new Chain<>(Underscore.compactList(list, falsyValue));
29022902
}
29032903

29042904
@SuppressWarnings("unchecked")

src/test/java/com/github/underscore/ArraysTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ void lastOrNull() {
659659
void compact() {
660660
final List<?> result = Underscore.compact(asList(0, 1, false, 2, "", 3));
661661
assertEquals("[1, 2, 3]", result.toString());
662-
final List<?> result2 = Underscore.compact(Arrays.<Object>asList(0, 1, false, 2, "", 3), 1);
662+
final List<?> result2 = Underscore.compactList(Arrays.<Object>asList(0, 1, false, 2, "", 3), 1);
663663
assertEquals("[0, false, 2, , 3]", result2.toString());
664664
final List<?> result3 = Underscore.compact(asList(0, 1, null, 2, "", 3));
665665
assertEquals("[1, 2, 3]", result3.toString());

0 commit comments

Comments
 (0)