You can't do it directly, you should provide your own way to check this. Eg.

class MyClass {
  Object attr1, attr2, attr3;

  public boolean isValid() {
    return attr1 != null && attr2 != null && attr3 != null;
  }
}

Or make all fields final and initialize them in constructors so that you can be sure that everything is initialized.

Answer from Jack on Stack Overflow
🌐
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 …
Discussions

[JAVA] is there a way to check if all fields in an object are not empty?

You could use reflection, but I would not recommend using it unless absolutely necessary. You could use streams to make the check a bit more readable, something like

Stream.of(object.name, object.date)
    .allMatch(Objects::nonNull);

I don't know where you are checking this, but i think this probably should be a method in your class, since this is validator type thingy, not responsibility of the place wherever you add your stuff to a list.

So something like:

public class SomeClass {
	String name;
	Date date;

	public boolean hasAllDetailsEntered() {
		return Stream.of(this.name, this.date)
    		.allMatch(Objects::nonNull);

	}
}
More on reddit.com
🌐 r/learnprogramming
8
3
March 12, 2019
?.let vs if not null - Kotlin Discussions
Case 2 doesn’t work with mutating properties, instead in case 1 the variable it is always not null · While I use the first for the reason described by fvasco (you’d have to use varable!! in many cases), I don’t find it to be really clear for those new to the language. More on discuss.kotlinlang.org
🌐 discuss.kotlinlang.org
6
June 28, 2017
Cleanest way to check for null on a String?
If all you're doing is returning an Optional, use the features of the Optional: return Optional.ofNullable(someObject.get("someKey")); If you need to do some additional processing on the string value, call .map() on the Optional. More on reddit.com
🌐 r/java
11
3
May 8, 2024
Fetching a value without having to null check in Java - Software Engineering Stack Exchange
Many times I find myself null checking when fetching a value from some data hierarchy to avoid NullPointerExceptions, which I find to be prone to errors and a needs a lot of boilerplate. I've writ... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
January 15, 2017
🌐
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.
🌐
LabEx
labex.io › tutorials › java-how-to-check-if-an-object-is-null-in-java-560011
How to Check If an Object Is Null in Java | LabEx
Learn how to check if an object is null in Java using the equality operator, combining null and type checks, and the Optional class to prevent NullPointerException errors and write more robust code.
🌐
Better Programming
betterprogramming.pub › checking-for-nulls-in-java-minimize-using-if-else-edae27016474
Checking for Nulls in Java? Minimize Using “If Else”
January 26, 2022 - Checks that the specified object reference is not null and throws a customized NullPointerExceptionif it is. This method is designed primarily for doing parameter validation in methods and constructors with multiple parameters.² · Returns the first argument if it is non-null and otherwise returns the non-null second argument.³
🌐
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 - To exemplify, we’ll use the Car class defined below: ... The simplest way is using a sequence of if statements to check field by field if they are null or not and, in the end, return a combination of their results.
🌐
GeeksforGeeks
geeksforgeeks.org › java › properties-isempty-method-in-java-with-examples
Properties isEmpty() method in Java with Examples - GeeksforGeeks
July 11, 2025 - The isEmpty() method of Properties class is used to check if this Properties object is empty or not. Syntax: public boolean isEmpty() Parameters: This method accepts no parameters Returns: This method returns a boolean value stating if this ...
Find elsewhere
🌐
Stack Abuse
stackabuse.com › java-check-if-string-is-null-empty-or-blank
Java: Check if String is Null, Empty or Blank
February 28, 2023 - if (StringUtils.isNotEmpty("")) ... for string manipulation. In this article, we have used some of these methods such as isEmpty(), equals(), StringUtils.isEmpty() and length() to check if the String is null, empty or blank....
🌐
Coderanch
coderanch.com › t › 399530 › java › check-Object-empty
How can i check if an Object[][] is empty (Beginning Java forum at Coderanch)
May 3, 2005 - In this case you just check for a null reference: 2) The array has length 0. The check is quite similar to the above: 3) The subarrays are all null or length 0. In this case you have to check each subarray similar to 1 or 2 above. 4) The individual elements in the array are set to null. In this case, you need to check each individual element. So what do you mean by "empty"? Layne ... [I see that Layne posted an answer while I was composing mine, but I think I'll go ahead anyhow. It gives me a warm fuzzy that we had basically the same idea.] There are any number of levels of "empty". Something declared as Object[][] is a reference to an array object that holds M references to array objects that each hold N references to Objects.
🌐
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.
🌐
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....
🌐
Quora
quora.com › What-is-the-correct-way-to-determine-if-Java-object-is-null-or-not-in-tasker
What is the correct way to determine if Java object is null or not in tasker? - Quora
Answer (1 of 2): There are two ways you can do null checking of Java objects. The first way, direct from the userguide, is checking of the object [code ]Equals null[/code]: If A Java object can be directly referenced in a condition. Null-value objects are replaced with text representation [code...
🌐
Kotlin Discussions
discuss.kotlinlang.org › t › let-vs-if-not-null › 3542
?.let vs if not null - Kotlin Discussions
June 28, 2017 - What is actually the difference and what is the preferred to use: variable?.let { //... } or if (variable != null) { //... }
🌐
Javatpoint
javatpoint.com › java-8-object-null-check
Java 8 Object Null Check - Javatpoint
Java 8 Object Null Check with java tutorial, features, history, variables, programs, operators, oops concept, array, string, map, math, methods, examples etc.
🌐
Reddit
reddit.com › r/java › cleanest way to check for null on a string?
Cleanest way to check for null on a String? : r/java
May 8, 2024 - But as an FYI instead of "String.valueOf" you can use "java.util.Objects.toString(Object o, String nullDefault)" instead, which was added in Java 1.7. If you replaced String.valueOf(someObject.get("someKey")) with Objects.toString(someObject.get("someKey"), null) then it works just fine when ...
🌐
Quora
quora.com › What-is-the-best-way-to-check-if-a-variable-is-null-before-trying-to-access-its-value-in-Java
What is the best way to check if a variable is null before trying to access its value in Java? - Quora
Answer (1 of 5): I̲n̲ ̲J̲a̲v̲a̲ ̲,̲ ̲t̲h̲e̲ ̲s̲t̲a̲n̲d̲a̲r̲d ̲w̲a̲y ̲i̲s̲ ̲t̲o̲ ̲j̲u̲st̲ ̲d̲o̲ ̲a̲ ̲s̲t̲r̲a̲i̲g̲h̲t̲f̲o̲r̲w̲a̲r̲d̲ ̲n̲u̲l̲l̲ ̲c̲h̲e̲c̲k̲ ̲w̲i̲t̲h̲ ̲`̲i̲f̲ ̲(̲v̲a̲r̲i̲a̲b̲l̲e̲ ̲=̲=̲ ...
🌐
Coderanch
coderanch.com › t › 99773 › engineering › Null-Empty-object-Return-Type
Null or Empty object (Return Type) (OO, Patterns, UML and Refactoring forum at Coderanch)
I hate having to do things like "if ( (s != null) && (s.length()>0))" over and over. Sooner or later, I will end up throwing an Exception in a case like that, but it will end up being the less informative NullPointerException that comes from having buggy code, having forgotten that one last null check. Sometimes one has to make a distinction between, for example, returning an empty string and a null (think HttpServletRequest.getParameter(), for example).