[java-metadata-aggregator] 01/02: JSSH-27 - Prototype ensureId method

Ian Young ian at iay.org.uk
Wed Apr 19 09:57:14 UTC 2023


This is an automated email from the git hooks/post-receive script.

iay pushed a commit to branch main
in repository java-metadata-aggregator.

View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=8c01aeeb0f2f4e937a6efddce6b946a2d8289d5e

commit 8c01aeeb0f2f4e937a6efddce6b946a2d8289d5e
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed Apr 19 07:28:58 2023 +0100

    JSSH-27 - Prototype ensureId method
    
    https://shibboleth.atlassian.net/browse/JSSH-27
---
 .../shibboleth/metadata/pipeline/AbstractStage.java   | 19 +++++++++++++++++++
 .../shibboleth/metadata/validate/BaseValidator.java   | 19 +++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/pipeline/AbstractStage.java b/mda-framework/src/main/java/net/shibboleth/metadata/pipeline/AbstractStage.java
index c18fb04..2a84308 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/pipeline/AbstractStage.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/pipeline/AbstractStage.java
@@ -79,6 +79,25 @@ public abstract class AbstractStage<T> extends AbstractIdentifiableInitializable
         }
     }
 
+    /**
+     * Return the ID of this component, guaranteeing a non-<code>null</code>
+     * result.
+     *
+     * @return the ID of this component, never <code>null</code>
+     * @throws IllegalStateException if called before the ID has been set
+     *
+     * @see #getId()
+     *
+     * @since 0.10.0
+     */
+    protected final @Nonnull String ensureId() {
+        final var id = getId();
+        if (id == null) {
+            throw new IllegalStateException();
+        }
+        return id;
+    }
+
     /**
      * Performs the stage processing on the given Item collection.
      * 
diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/validate/BaseValidator.java b/mda-framework/src/main/java/net/shibboleth/metadata/validate/BaseValidator.java
index 4f778d9..a93e320 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/validate/BaseValidator.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/validate/BaseValidator.java
@@ -151,4 +151,23 @@ public abstract class BaseValidator extends AbstractIdentifiableInitializableCom
         addError(mess, item, stageId);
     }
 
+    /**
+     * Return the ID of this component, guaranteeing a non-<code>null</code>
+     * result.
+     *
+     * @return the ID of this component, never <code>null</code>
+     * @throws IllegalStateException if called before the ID has been set
+     *
+     * @see #getId()
+     *
+     * @since 0.10.0
+     */
+    protected final @Nonnull String ensureId() {
+        final var id = getId();
+        if (id == null) {
+            throw new IllegalStateException();
+        }
+        return id;
+    }
+
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list