|
|
@ -1,6 +1,7 @@
|
|
|
|
package cokr.xit.foundation.util;
|
|
|
|
package cokr.xit.foundation.util;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
import java.util.stream.StreamSupport;
|
|
|
|
import java.util.stream.StreamSupport;
|
|
|
@ -25,14 +26,23 @@ public class ListSupport<T> {
|
|
|
|
return this;
|
|
|
|
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을 설정한다.
|
|
|
|
/**List로 변환할 Collection을 설정한다.
|
|
|
|
* @param iterable Collection
|
|
|
|
* @param iterable Collection
|
|
|
|
* @return 현재 ListSupport
|
|
|
|
* @return 현재 ListSupport
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public ListSupport<T> setIterable(Iterable<T> iterable) {
|
|
|
|
public ListSupport<T> setIterable(Iterable<T> iterable) {
|
|
|
|
this.list = iterable instanceof List<T> ?
|
|
|
|
this.list = asList(iterable);
|
|
|
|
(List<T>)iterable :
|
|
|
|
|
|
|
|
StreamSupport.stream(iterable.spliterator(), false).toList();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|