mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
Added collector to LibraryList
This commit is contained in:
parent
a76588cf5d
commit
1db3aabaab
@ -30,8 +30,15 @@ package processing.app.packages;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.BinaryOperator;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
|
||||||
import processing.app.helpers.FileUtils;
|
import processing.app.helpers.FileUtils;
|
||||||
|
|
||||||
@ -76,5 +83,36 @@ public class LibraryList extends LinkedList<UserLibrary> {
|
|||||||
if (l == lib) return true;
|
if (l == lib) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
public static Collector<UserLibrary, LibraryList, LibraryList> collector() {
|
||||||
|
return new Collector<UserLibrary, LibraryList, LibraryList>() {
|
||||||
|
@Override
|
||||||
|
public Supplier<LibraryList> supplier() {
|
||||||
|
return () -> new LibraryList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiConsumer<LibraryList, UserLibrary> accumulator() {
|
||||||
|
return (libs, lib) -> libs.add(lib);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BinaryOperator<LibraryList> combiner() {
|
||||||
|
return (we, they) -> {
|
||||||
|
we.addAll(they);
|
||||||
|
return we;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Function<LibraryList, LibraryList> finisher() {
|
||||||
|
return (libs) -> libs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Collector.Characteristics> characteristics() {
|
||||||
|
return EnumSet.noneOf(Characteristics.class);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user