kennknowles commented on code in PR #17819:
URL: https://github.com/apache/beam/pull/17819#discussion_r951882036


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/util/Preconditions.java:
##########
@@ -472,4 +472,63 @@ public class Preconditions {
     }
     return reference;
   }
+
+  /**
+   * Ensures that a piece of state passed as a parameter to the calling method 
is not null.
+   *
+   * @param obj an object reference
+   * @param errorMessageTemplate a template for the exception message should 
the check fail. The
+   *     message is formed by replacing each {@code %s} placeholder in the 
template with an
+   *     argument. These are matched by position - the first {@code %s} gets 
{@code
+   *     errorMessageArgs[0]}, etc. Unmatched arguments will be appended to 
the formatted message in
+   *     square braces. Unmatched placeholders will be left as-is.
+   * @param errorMessageArgs the arguments to be substituted into the message 
template. Arguments
+   *     are converted to strings using {@link String#valueOf(Object)}.
+   * @return the non-null reference that was validated
+   * @throws IllegalStateException if {@code obj} is null
+   */
+  @CanIgnoreReturnValue
+  @EnsuresNonNull("#1")
+  public static <T extends @NonNull Object> T checkStateNotNull(
+      @Nullable T obj,
+      @Nullable String errorMessageTemplate,
+      @Nullable Object... errorMessageArgs) {
+    if (obj == null) {
+      throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, 
errorMessageArgs));
+    }
+    return obj;
+  }
+
+  /**
+   * Ensures that a piece of state is not null.
+   *
+   * <p>See {@link #checkStateNotNull(Object, String, Object...)} for details.
+   */
+  @CanIgnoreReturnValue
+  @EnsuresNonNull("#1")
+  public static <T extends @NonNull Object> T checkStateNotNull(
+      @Nullable T obj, @Nullable String errorMessageTemplate, @Nullable Object 
p1) {
+    if (obj == null) {
+      throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1));
+    }
+    return obj;
+  }
+
+  /**
+   * Ensures that an object reference passed as a parameter to the calling 
method is not null.
+   *
+   * <p>See {@link #checkArgumentNotNull(Object, String, Object...)} for 
details.
+   */
+  @CanIgnoreReturnValue
+  @EnsuresNonNull("#1")
+  public static <T extends @NonNull Object> T checkStateNotNull(
+      @Nullable T obj,
+      @Nullable String errorMessageTemplate,
+      @Nullable Object p1,
+      @Nullable Object p2) {
+    if (obj == null) {
+      throw new IllegalStateException(lenientFormat(errorMessageTemplate, p1));

Review Comment:
   Fixed



##########
sdks/java/core/src/main/java/org/apache/beam/sdk/values/TypeDescriptor.java:
##########
@@ -180,7 +178,7 @@ public Class<? super T> getRawType() {
 
   /** Returns the component type if this type is an array type, otherwise 
returns {@code null}. */

Review Comment:
   Fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to