org.simpleflatmapper.util.ImmutableListCollector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sfm-util Show documentation
Show all versions of sfm-util Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
The newest version!
package org.simpleflatmapper.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Implementation of {@link Consumer} that collect all the value into a list.
* Equivalent to a {@link java.util.stream.Collectors#toList()}.
* @param the type of the callback argument
*/
public final class ImmutableListCollector implements Consumer {
private final List list = new ArrayList();
@Override
public void accept(final T t) {
list.add(t);
}
/**
*
* @return the collected objects
*/
public List getList() {
return Collections.unmodifiableList(list);
}
}