diff --git a/pom.xml b/pom.xml
index e74ea67..9460817 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
fi.solita.utils
functional-utils
- 0.12.53
+ 0.12.54
diff --git a/src/main/java/fi/solita/utils/functional/FunctionalS.java b/src/main/java/fi/solita/utils/functional/FunctionalS.java
index 823377f..db22f40 100644
--- a/src/main/java/fi/solita/utils/functional/FunctionalS.java
+++ b/src/main/java/fi/solita/utils/functional/FunctionalS.java
@@ -225,7 +225,7 @@ public static final Set intersection(Set e1, Set e2, Set e3, Set
* @return Set intersection of Sets in {@code es}.
*/
public static final Set intersection(Iterable extends Set> es) {
- return FunctionalImpl.fold(Collections.emptySet(), SemiGroups.setIntersection(), es);
+ return FunctionalImpl.fold(SemiGroups.setIntersection(), es).getOrElse(Collections.emptySet());
}
diff --git a/src/test/java/fi/solita/utils/functional/FunctionalTest.java b/src/test/java/fi/solita/utils/functional/FunctionalTest.java
index 997025d..d708369 100644
--- a/src/test/java/fi/solita/utils/functional/FunctionalTest.java
+++ b/src/test/java/fi/solita/utils/functional/FunctionalTest.java
@@ -1,5 +1,6 @@
package fi.solita.utils.functional;
import static fi.solita.utils.functional.Collections.emptyList;
+import static fi.solita.utils.functional.Collections.emptySet;
import static fi.solita.utils.functional.Collections.newList;
import static fi.solita.utils.functional.Collections.newMutableList;
import static fi.solita.utils.functional.Collections.newSet;
@@ -412,4 +413,14 @@ public void padRight() {
assertEquals("xx", Functional.padRight(2, '0', "xx").toString());
assertEquals("xxx", Functional.padRight(2, '0', "xxx").toString());
}
+
+ @Test
+ public void testIntersection() {
+ assertEquals(emptySet(), Functional.intersection(Collections.emptySet(), newSet(2,3)));
+ assertEquals(emptySet(), Functional.intersection(newSet(2,3), Collections.emptySet()));
+ assertEquals(emptySet(), Functional.intersection(Arrays.asList(Collections.emptySet(), newSet(2,3))));
+
+ assertEquals(newSet(2), Functional.intersection(newSet(1,2), newSet(2,3)));
+ assertEquals(newSet(2), Functional.intersection(Arrays.asList(newSet(1,2), newSet(2,3))));
+ }
}