Skip to content

Commit f2e898d

Browse files
committed
Polish
1 parent bd4b386 commit f2e898d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static boolean isCheckedException(Throwable ex) {
7878

7979
/**
8080
* Check whether the given exception is compatible with the specified
81-
* exception types, as declared in a throws clause.
81+
* exception types, as declared in a {@code throws} clause.
8282
* @param ex the exception to check
8383
* @param declaredExceptions the exception types declared in the throws clause
8484
* @return whether the given exception is compatible
@@ -143,7 +143,7 @@ public static boolean isEmpty(@Nullable Object obj) {
143143
}
144144

145145
if (obj instanceof Optional<?> optional) {
146-
return !optional.isPresent();
146+
return optional.isEmpty();
147147
}
148148
if (obj instanceof CharSequence charSequence) {
149149
return charSequence.length() == 0;
@@ -172,7 +172,7 @@ public static boolean isEmpty(@Nullable Object obj) {
172172
@Nullable
173173
public static Object unwrapOptional(@Nullable Object obj) {
174174
if (obj instanceof Optional<?> optional) {
175-
if (!optional.isPresent()) {
175+
if (optional.isEmpty()) {
176176
return null;
177177
}
178178
Object result = optional.get();
@@ -900,10 +900,10 @@ public static String nullSafeToString(@Nullable short[] array) {
900900
* <p>Returns:
901901
* <ul>
902902
* <li>{@code "null"} if {@code obj} is {@code null}</li>
903-
* <li>{@code"Optional.empty"} if {@code obj} is an empty {@link Optional}</li>
904-
* <li>{@code"Optional[<concise-string>]"} if {@code obj} is a non-empty {@code Optional},
905-
* where {@code <concise-string>} is the result of invoking {@link #nullSafeConciseToString}
906-
* on the object contained in the {@code Optional}</li>
903+
* <li>{@code "Optional.empty"} if {@code obj} is an empty {@link Optional}</li>
904+
* <li>{@code "Optional[<concise-string>]"} if {@code obj} is a non-empty {@code Optional},
905+
* where {@code <concise-string>} is the result of invoking this method on the object
906+
* contained in the {@code Optional}</li>
907907
* <li>{@code "{}"} if {@code obj} is an empty array</li>
908908
* <li>{@code "{...}"} if {@code obj} is a {@link Map} or a non-empty array</li>
909909
* <li>{@code "[...]"} if {@code obj} is a {@link Collection}</li>

0 commit comments

Comments
 (0)