Browse Source

Fix example in Javadoc for Assert.notNull(object, messageSupplier)

Closes gh-25774
pull/23967/head
Sam Brannen 5 years ago
parent
commit
547a13985a
  1. 15
      spring-core/src/main/java/org/springframework/util/Assert.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -80,8 +80,8 @@ public abstract class Assert { @@ -80,8 +80,8 @@ public abstract class Assert {
* <p>Call {@link #isTrue} if you wish to throw an {@code IllegalArgumentException}
* on an assertion failure.
* <pre class="code">
* Assert.state(id == null,
* () -&gt; "ID for " + entity.getName() + " must not already be initialized");
* Assert.state(entity.getId() == null,
* () -&gt; "ID for entity " + entity.getName() + " must not already be initialized");
* </pre>
* @param expression a boolean expression
* @param messageSupplier a supplier for the exception message to use if the
@ -202,7 +202,8 @@ public abstract class Assert { @@ -202,7 +202,8 @@ public abstract class Assert {
/**
* Assert that an object is not {@code null}.
* <pre class="code">
* Assert.notNull(clazz, () -&gt; "The class '" + clazz.getName() + "' must not be null");
* Assert.notNull(entity.getId(),
* () -&gt; "ID for entity " + entity.getName() + " must not be null");
* </pre>
* @param object the object to check
* @param messageSupplier a supplier for the exception message to use if the
@ -244,7 +245,8 @@ public abstract class Assert { @@ -244,7 +245,8 @@ public abstract class Assert {
* Assert that the given String is not empty; that is,
* it must not be {@code null} and not the empty String.
* <pre class="code">
* Assert.hasLength(name, () -&gt; "Name for account '" + account.getId() + "' must not be empty");
* Assert.hasLength(account.getName(),
* () -&gt; "Name for account '" + account.getId() + "' must not be empty");
* </pre>
* @param text the String to check
* @param messageSupplier a supplier for the exception message to use if the
@ -289,7 +291,8 @@ public abstract class Assert { @@ -289,7 +291,8 @@ public abstract class Assert {
* Assert that the given String contains valid text content; that is, it must not
* be {@code null} and must contain at least one non-whitespace character.
* <pre class="code">
* Assert.hasText(name, () -&gt; "Name for account '" + account.getId() + "' must not be empty");
* Assert.hasText(account.getName(),
* () -&gt; "Name for account '" + account.getId() + "' must not be empty");
* </pre>
* @param text the String to check
* @param messageSupplier a supplier for the exception message to use if the

Loading…
Cancel
Save