Closed chris-dekker closed 11 months ago
Sounds like a good idea for someone with time & interest to work on, and solid improvement to usability. Tagged as such.
Assign it to me please, Also I have a question: how should range without lower or upper bound look like? (,1] or (-INF, 1], in my humble opinion second one looks better
@saydar31 I let you decide. But does Guava's Range.toString()
offer guidance here?
@saydar31 great to hear you're picking this up! Would prefer to stay consistent with the Range.toString()
method indeed, which uses the ∞
symbol (\u221e
)
@saydar31 great to hear you're picking this up! Would prefer to stay consistent with the
Range.toString()
method indeed, which uses the∞
symbol (\u221e
)
@chris-dekker now that you mention it, this needs to go on the doc. I will add notes to the PR that whatever symbol Jackson returns, the returned unicode of symbol would also be documented.
Merged for inclusion in 2.17.0
I find the standard serialization JSON, while flexible, of
Range<T>
to be quite verbose:When manually processing the results, I prefer to shorter notation produced by, among others, the default
toString()
invocation:[12..34)
.Similar to
Instant
, where we can use@JsonFormat(shape = ..)
to control (de)serialization to use the ISO format or unix milis, it would be great if we could control the shape of the range this way. Keep the default as-is and only when@JsonFormat(shape = STRING)
is provided, use the shorter notation.Granted, this will only work for endpoints having scalar values, but that seems to cover the majority of use cases I've seen so far.