[java-support] branch maint-8 updated: Add a factory method for a constant non-null supplier.
Scott Cantor
cantor.2 at osu.edu
Mon Dec 5 14:45:43 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch maint-8
in repository java-support.
View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=3cd84bbcf902d622e12537f8b20ae1fb9df9dca2
The following commit(s) were added to refs/heads/maint-8 by this push:
new 3cd84bb Add a factory method for a constant non-null supplier.
3cd84bb is described below
commit 3cd84bbcf902d622e12537f8b20ae1fb9df9dca2
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Dec 5 09:45:40 2022 -0500
Add a factory method for a constant non-null supplier.
---
.../java/support/primitive/NonnullSupplier.java | 28 ++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/main/java/net/shibboleth/utilities/java/support/primitive/NonnullSupplier.java b/src/main/java/net/shibboleth/utilities/java/support/primitive/NonnullSupplier.java
index 488187c..2675b75 100644
--- a/src/main/java/net/shibboleth/utilities/java/support/primitive/NonnullSupplier.java
+++ b/src/main/java/net/shibboleth/utilities/java/support/primitive/NonnullSupplier.java
@@ -24,9 +24,33 @@ import javax.annotation.Nonnull;
/**
* Implementation of {@link Supplier} that carries the nonnull annotation
* on the {@link #get()} method.
+ *
+ * @param <T> type of supplier output
+ *
+ * @since 8.4.0
*/
public interface NonnullSupplier<T> extends Supplier<T> {
/** {@inheritDoc} */
- @Override @Nonnull T get();
-}
+ @Nonnull T get();
+
+
+ /**
+ * Return a {@link NonnullSupplier} that returns the input argument.
+ *
+ * @param <T> argument type
+ * @param input input argument to return
+ *
+ * @return the input argument
+ */
+ @Nonnull static public <T> NonnullSupplier<T> of(@Nonnull final T input) {
+
+ return new NonnullSupplier<T>() {
+ @Override
+ @Nonnull public T get() {
+ return input;
+ }
+ };
+ }
+
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list