Skip to content

Commit

Permalink
feat:优化assertNotNullMono
Browse files Browse the repository at this point in the history
  • Loading branch information
citmina committed Nov 19, 2023
1 parent 02831f9 commit c145679
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/com/gearwenxin/common/WenXinUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.gearwenxin.exception.WenXinException;
import com.gearwenxin.entity.Message;
import org.apache.commons.lang3.StringUtils;
import reactor.core.publisher.Mono;

import java.util.Deque;
import java.util.concurrent.ConcurrentLinkedDeque;
Expand Down Expand Up @@ -183,16 +184,20 @@ public static void assertNotBlank(String message, String... strings) {
}
}

public static void assertNotNull(Object obj, String message) {
public static Mono<Void> assertNotNullMono(Object obj, String message) {
if (obj == null) {
throw new WenXinException(ErrorCode.PARAMS_ERROR, message);
return Mono.error(() -> new WenXinException(ErrorCode.PARAMS_ERROR, message));
}
return Mono.empty();
}

public static void assertNotNullMono(Object obj, String message) {
if (obj == null) {
throw new WenXinException(ErrorCode.PARAMS_ERROR, message);
public static Mono<Void> assertNotBlankMono(String message, String... strings) {
for (String str : strings) {
if (StringUtils.isBlank(str)) {
return Mono.error(() -> new WenXinException(ErrorCode.PARAMS_ERROR, message));
}
}
return Mono.empty();
}

}

0 comments on commit c145679

Please sign in to comment.