aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/mammoth/util/MammothIterables.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/zwobble/mammoth/util/MammothIterables.java')
-rw-r--r--src/main/java/org/zwobble/mammoth/util/MammothIterables.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/org/zwobble/mammoth/util/MammothIterables.java b/src/main/java/org/zwobble/mammoth/util/MammothIterables.java
new file mode 100644
index 0000000..89caf61
--- /dev/null
+++ b/src/main/java/org/zwobble/mammoth/util/MammothIterables.java
@@ -0,0 +1,11 @@
+package org.zwobble.mammoth.util;
+
+import com.google.common.collect.Iterables;
+
+import java.util.Optional;
+
+public class MammothIterables {
+ public static <T> Optional<T> tryGetLast(Iterable<T> iterable) {
+ return Optional.ofNullable(Iterables.getLast(iterable, null));
+ }
+}