You can using java-8 Stream#anyMatch to checking the strings is whether null or empty. for example:

boolean hasNullOrEmptyString = Stream.of(myField1,myField2,...,myFieldN)
                                     .anyMatch(it-> it==null || it.isEmpty());

OR you can replace lambda expression with method reference expression which the method can be reused later:

boolean hasNullOrEmptyString = Stream.of(myField1,myField2,...,myFieldN)
                                     .anyMatch(this::isNullOrEmptyString);

boolean isNullOrEmptyString(String it){
  return it==null || it.isEmpty();
}

OR as I see your question that marked as spring, and spring already has a utility method StringUtils#isEmpty for check a String whether is null or empty:

boolean hasNullOrEmptyString = Stream.of(myField1,myField2,...,myFieldN)
                                     .anyMatch(StringUtils::isEmpty);
Answer from holi-java on Stack Overflow
🌐
Java Guides
javaguides.net › 2024 › 05 › java-check-if-object-is-null-or-empty.html
Java: Check If Object Is Null or Empty
May 29, 2024 - This guide will cover various ways to check if different types of objects (like String, Collection, Map, and custom objects) are null or empty.
🌐
Medium
tamerardal.medium.com › simplify-null-checks-in-java-writing-clean-code-with-apache-commons-lang-3-e7d3aea207bd
Simplify Null Checks in Java: Writing Clean Code with Apache Commons Lang 3 | by Tamer Ardal | Medium
September 18, 2024 - Simplify Null Checks in Java: Writing Clean Code with Apache Commons Lang 3 In Java, null checks are generally done using == or !=. In addition, if we want to do an empty check, our condition will …
🌐
Baeldung
baeldung.com › home › java › core java › check if all the variables of an object are null
Check If All the Variables of an Object Are Null | Baeldung
January 8, 2024 - >> Flexible Pub/Sub Messaging With Spring Boot and Dapr · In this tutorial, we’ll learn four approaches to check if all variables of an object are null. The null value in Java means the absence of a variable’s value. Technically, a variable containing null doesn’t point to any position in memory or wasn’t initialized yet.
🌐
Spring
docs.spring.io › spring-framework › docs › current › javadoc-api › org › springframework › util › ObjectUtils.html
ObjectUtils (Spring Framework 7.0.3 API)
Return a content-based String representation if obj is not null; otherwise returns an empty String. ... Return a hex String form of an object's identity hash code.
🌐
Better Programming
betterprogramming.pub › checking-for-nulls-in-java-minimize-using-if-else-edae27016474
Checking for Nulls in Java? Minimize Using “If Else” | by Itır ...
January 26, 2022 - When you want id, name, and classes fields not be null or empty, you could just put these annotations as below in Student class: @NotNull private Long id; @NotEmpty private String name; @NotEmpty private List<SchoolClass> classes; private Map<Integer, Teacher> teacherMap; And if you are using Spring Boot you can combine these annotations with @Validated annotation for the request body of API as below.
🌐
Stack Overflow
stackoverflow.com › questions › 71219473 › null-check-on-input-object-in-spring-boot-jpa-query
java - Null check on input object in spring boot jpa query - Stack Overflow
@Query(value= " ... and ( :subPhaseId is null or ... //row2 ... " ) List<Phase> load( ... @Param("phaseId") Long phaseId, @Param("subPhaseId") Long subPhaseId ... ); ... Upcoming initiatives on Stack Overflow and across the Stack Exchange network... Site maintenance - Wednesday, October 23, 2024, 9:00 PM-10:00 PM EDT... Proposed designs to update the homepage for logged-in users · 140 Spring data JPA query with parameter properties
Find elsewhere
🌐
Educative
educative.io › answers › what-is-objectutilsisempty-in-java
What is ObjectUtils.isEmpty in Java?
System.out.println("The output of ObjectUtils.isEmpty() when an empty set is passed is " + ObjectUtils.isEmpty(input)); ... System.out.println("The output of ObjectUtils.isEmpty() when an object of custom class is passed is " + ObjectUtils....
🌐
Javatpoint
javatpoint.com › how-to-check-null-in-java
How to Check null in Java
How to Check null in Java with java tutorial, features, history, variables, object, programs, operators, oops concept, array, string, map, math, methods, examples etc.
🌐
Baeldung
baeldung.com › home › java › avoid check for null statement in java
Avoid Check for Null Statement in Java | Baeldung
April 8, 2019 - A quick and practical guide to null-safety annotations in Spring. ... According to the Javadoc for NullPointerException, it’s thrown when an application attempts to use null in a case where an object is required, such as:
🌐
Medium
medium.com › @ecetasci.iu › checking-for-null-or-empty-strings-in-java-19518fa1e553
Checking for Null or Empty Strings in Java | by Ece Tasci | Medium
February 25, 2025 - In Java, calling a method on a null reference will result in a NullPointerException, one of the most common runtime errors. To prevent this, it is crucial to check for null before performing operations on a variable. An empty String ("") has zero characters but still exists in memory, specifically in the heap where Java stores objects.
🌐
Blogger
javarevisited.blogspot.com › 2016 › 01 › how-to-check-if-string-is-not-null-and-empty-in-java-example.html
How to check if String is not null and empty in Java? Example
Sometimes you need to use the trim() method if your program's requirement doesn't consider a String with the only whitespace as non-empty, but other times, you might want to use the length() function to consider String with just whitespaces as empty String in Java. As suggested by others, if you are using Google Guava, Spring, or Apache commons then just check their StringUtils class, you might get a method that does this for you like StringUtils.isBlank() from Apache Commons.
🌐
Baeldung
baeldung.com › home › java › java string › checking for empty or blank strings in java
Checking for Empty or Blank Strings in Java | Baeldung
January 8, 2024 - It checks whether a given string is null or empty, but it won’t check for whitespace-only strings. Furthermore, the Spring Core library provided a class named StringUtils which has a method to check if a string is empty. However, the class was deprecated in the Spring 5.3.0 version and above. It’s replaced with the ObjectUtils class.
🌐
Java Guides
javaguides.net › 2019 › 04 › check-if-string-is-empty-or-null-in-java-utility-methods.html
How to Check if a String is Null or Empty in Java
August 2, 2023 - I would suggest creating the Utility methods for null checks in your Java projects. ... [NEW] Python full course for beginners with essential libraries like NumPy, Pandas, and Matplotlib for data science. ... In this course, you will learn Spring Core, Spring Boot 3, REST API, Spring MVC, WebFlux, Spring Security, Spring Data JPA, Docker, Thymeleaf & Building Projects.