Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public final class BuilderUtils {
- private BuilderUtils () {
- throw new UnsupportedOperationException("do not call")
- }
- public static <B> List<B> convertBuilderList(List<? extends ModelBuilder<B>> toConvert) {
- if (CollectionUtils.isEmpty(toConvert)) {
- return Collections.emptyList();
- }
- final List<B> results = new ArrayList<B>(toConvert.size());
- for (ModelBuilder<B> elem : toConvert) {
- if (elem != null) {
- results.add(elem.build());
- }
- }
- return Collections.unmodifiableList(results);
- }
- public static <B> Collection<B> convertBuilderCollection(Collection<? extends ModelBuilder<B>> toConvert) {
- if (CollectionUtils.isEmpty(toConvert)) {
- return Collections.emptyList();
- }
- final Collection<B> results = new ArrayList<B>(toConvert.size());
- for (ModelBuilder<B> elem : toConvert) {
- if (elem != null) {
- results.add(elem.build());
- }
- }
- return Collections.unmodifiableCollection(results);
- }
- public static <B> Set<B> convertBuilderSet(Collection<? extends ModelBuilder<B>> toConvert) {
- if (CollectionUtils.isEmpty(toConvert)) {
- return Collections.emptySet();
- }
- final Set<B> results = new HashSet<B>(toConvert.size());
- for (ModelBuilder<B> elem : toConvert) {
- if (elem != null) {
- results.add(elem.build());
- }
- }
- return Collections.unmodifiableSet(results);
- }
- }
Add Comment
Please, Sign In to add comment