Skip to content

Commit 547a139

Browse files
committed
Fix example in Javadoc for Assert.notNull(object, messageSupplier)
Closes gh-25774
1 parent 216c4a1 commit 547a139

File tree

1 file changed

+9
-6
lines changed
  • spring-core/src/main/java/org/springframework/util

1 file changed

+9
-6
lines changed

spring-core/src/main/java/org/springframework/util/Assert.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -80,8 +80,8 @@ public static void state(boolean expression, String message) {
8080
* <p>Call {@link #isTrue} if you wish to throw an {@code IllegalArgumentException}
8181
* on an assertion failure.
8282
* <pre class="code">
83-
* Assert.state(id == null,
84-
* () -&gt; "ID for " + entity.getName() + " must not already be initialized");
83+
* Assert.state(entity.getId() == null,
84+
* () -&gt; "ID for entity " + entity.getName() + " must not already be initialized");
8585
* </pre>
8686
* @param expression a boolean expression
8787
* @param messageSupplier a supplier for the exception message to use if the
@@ -202,7 +202,8 @@ public static void notNull(@Nullable Object object, String message) {
202202
/**
203203
* Assert that an object is not {@code null}.
204204
* <pre class="code">
205-
* Assert.notNull(clazz, () -&gt; "The class '" + clazz.getName() + "' must not be null");
205+
* Assert.notNull(entity.getId(),
206+
* () -&gt; "ID for entity " + entity.getName() + " must not be null");
206207
* </pre>
207208
* @param object the object to check
208209
* @param messageSupplier a supplier for the exception message to use if the
@@ -244,7 +245,8 @@ public static void hasLength(@Nullable String text, String message) {
244245
* Assert that the given String is not empty; that is,
245246
* it must not be {@code null} and not the empty String.
246247
* <pre class="code">
247-
* Assert.hasLength(name, () -&gt; "Name for account '" + account.getId() + "' must not be empty");
248+
* Assert.hasLength(account.getName(),
249+
* () -&gt; "Name for account '" + account.getId() + "' must not be empty");
248250
* </pre>
249251
* @param text the String to check
250252
* @param messageSupplier a supplier for the exception message to use if the
@@ -289,7 +291,8 @@ public static void hasText(@Nullable String text, String message) {
289291
* Assert that the given String contains valid text content; that is, it must not
290292
* be {@code null} and must contain at least one non-whitespace character.
291293
* <pre class="code">
292-
* Assert.hasText(name, () -&gt; "Name for account '" + account.getId() + "' must not be empty");
294+
* Assert.hasText(account.getName(),
295+
* () -&gt; "Name for account '" + account.getId() + "' must not be empty");
293296
* </pre>
294297
* @param text the String to check
295298
* @param messageSupplier a supplier for the exception message to use if the

0 commit comments

Comments
 (0)