Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 14, 2023
2 parents bdd864e + bf7bae0 commit b74dcf5
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,30 @@
import tools.jackson.datatype.guava.deser.util.RangeHelper;

/**
* Jackson serializer for a Guava {@link Range}.
* Jackson serializer for Guava Range objects with enhanced serialization capabilities.
* When the range property is annotated with {@code @JsonFormat(JsonFormat.Shape.STRING)},
* it generates bracket notation for a more concise and human-readable representation.
* Otherwise, it defaults to a more verbose standard serialization, explicitly writing out endpoints and bound types.
*
* <p>
* Usage Example for bracket notation:
* <pre>{@code
* @JsonFormat(JsonFormat.Shape.STRING)
* private Range<Integer> r;
* }</pre>
* When the range field is annotated with {@code @JsonFormat(JsonFormat.Shape.STRING)}, the serializer
* will output the range that would look something like: [X..Y] or (X..Y).
* <br><br>
* By default, when the range property lacks the string shape annotation,
* the serializer will output the JSON in following manner:
* <pre>{@code
* {
* "lowerEndpoint": X,
* "lowerBoundType": "CLOSED",
* "upperEndpoint": Y,
* "upperBoundType": "CLOSED"
* }
* }</pre>
*/
public class RangeSerializer extends StdSerializer<Range<?>>
{
Expand Down

0 comments on commit b74dcf5

Please sign in to comment.