Overview
org.springframework.util.ObjectUtils.nullSafeToString(Object) exists for generating a toString() representation of various objects in a "null-safe" manner, including support for object graphs, collections, etc.
However, there are times when we would like to generate a more "concise" null-safe toString() representation that does not include an entire object graph (or potentially a collection of object graphs).
org.springframework.beans.BeanUtils.isSimpleValueType(Class<?>) already provides a check for an opinionated list of "simple types"; however, that resides in spring-beans and therefore cannot be used in spring-core.
We should introduce ObjectUtils.nullSafeConciseToString(Object) that generates a concise, null-safe string representation of the supplied object relying on logic similar to BeanUtils.isSimpleValueType() to decide when to use the standard toString() implementation for the supplied object and when to replace the standard implementation with a more concise format -- for example, something along the lines of what Object#toString generates instead of including the toString() representation of an entire object graph recursively.
Deliverables
Overview
org.springframework.util.ObjectUtils.nullSafeToString(Object)exists for generating atoString()representation of various objects in a "null-safe" manner, including support for object graphs, collections, etc.However, there are times when we would like to generate a more "concise" null-safe
toString()representation that does not include an entire object graph (or potentially a collection of object graphs).org.springframework.beans.BeanUtils.isSimpleValueType(Class<?>)already provides a check for an opinionated list of "simple types"; however, that resides inspring-beansand therefore cannot be used inspring-core.We should introduce
ObjectUtils.nullSafeConciseToString(Object)that generates a concise, null-safe string representation of the supplied object relying on logic similar toBeanUtils.isSimpleValueType()to decide when to use the standardtoString()implementation for the supplied object and when to replace the standard implementation with a more concise format -- for example, something along the lines of whatObject#toStringgenerates instead of including thetoString()representation of an entire object graph recursively.Deliverables
nullSafeConciseToString(Object)inObjectUtils