You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is similar to #1404 adding support of omitting empty values from toStringHelper output.
What I noticed is that the current code already has the feature,
just that there is no public method like omitNullValues() to enable the omitEmptyValues flag.
Good eye --- we have this exact feature available internally (which is why some of the implementation bits have "leaked" into Guava). I'm not opposed to open-sourcing it, given that "emptiness" seems to be a fairly well-understood (but not officially documented or statically encoded) concept.
I think we'll need to beef up the javadocs on our API a bit --- we may want to explicitly list the current types we check for emptiness, and also give ourselves some wiggle room for expanding (or shrinking) that list in the future.
1. What are you trying to do?
This is similar to #1404 adding support of omitting empty values from toStringHelper output.
What I noticed is that the current code already has the feature,
just that there is no public method like
omitNullValues()
to enable theomitEmptyValues
flag.guava/guava/src/com/google/common/base/MoreObjects.java
Line 155 in 5da71a7
It supports various types detecting empty-ness
guava/guava/src/com/google/common/base/MoreObjects.java
Lines 334 to 356 in 5da71a7
Can
omitEmptyValues()
be added toToStringHelper
methods, so that the implemented feature can be exercised?2. What's the best code you can write to accomplish that without the new feature?
3. What would that same code look like if we added your feature?
(Optional) What would the method signatures for your feature look like?
No response
Concrete Use Cases
Exclude empty Optional, Collection, etc. from toString() output.
Packages
com.google.common.base
Checklist
I agree to follow the code of conduct.
I have read and understood the contribution guidelines.
I have read and understood Guava's philosophy, and I strongly believe that this proposal aligns with it.
I have visited the idea graveyard, and did not see anything similar to this idea.
The text was updated successfully, but these errors were encountered: