There is no canonical definition of 'empty value' for either Integer or Date.
You just program what you mean, and 'empty' is not a valid answer to the question 'what do you mean'.
For example: "Empty strings, the 0 integer, and sentinel instant value with epochmillis 0 (Date
is a lie. It does not represent dates; it represents instants, and badly at that; use java.time.Instant
instead normally)".
Then, you just.. program that:
for (Object obj : result) {
if (obj == null) return false;
if (obj instanceof Date) {
if (((Date) obj).getTime() == 0) return false;
} else if (obj instanceof String) {
if (((String) obj).isEmpty()) return false;
} else if (obj instanceof Integer) {
if (((Integer) obj).intValue() == 0) return false;
} else throw new IllegalStateException("Unexpected type: " + obj.getClass());
return true;
}
It's an if
for every type because there is no such thing as CouldBeEmpty
as an interface that all these types implement. Said differently, "an empty Date" isn't a thing.