asList 추가

master
mjkhan21 1 year ago
parent 97df00b484
commit a012929bc7

@ -1,6 +1,7 @@
package cokr.xit.foundation.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.StreamSupport;
@ -25,14 +26,23 @@ public class ListSupport<T> {
return this;
}
/**iterable List .
* @param iterable Collection
* @return List
*/
public List<T> asList(Iterable<T> iterable) {
return iterable == null ? Collections.emptyList() :
iterable instanceof List<T> ?
(List<T>)iterable :
StreamSupport.stream(iterable.spliterator(), false).toList();
}
/**List Collection .
* @param iterable Collection
* @return ListSupport
*/
public ListSupport<T> setIterable(Iterable<T> iterable) {
this.list = iterable instanceof List<T> ?
(List<T>)iterable :
StreamSupport.stream(iterable.spliterator(), false).toList();
this.list = asList(iterable);
return this;
}

Loading…
Cancel
Save