8181 public final static String DEFAULT_TIMEZONE = "##default" ;
8282
8383 /**
84- * Value that indicates the default radix(numeric base) to use for outputting {@link java.lang.Number} properties
85- * when {@link Shape#STRING} is specified.
84+ * Value that indicates the default radix(numeric base) should be used when outputting
85+ * {@link java.lang.Number} properties when {@link Shape#STRING} is specified.
86+ * This is a marker signaling that {@link JsonFormat.Value} with this radix should
87+ * not override the radix of another {@link JsonFormat.Value}.
88+ * @since 2.21
8689 */
87- public final static byte DEFAULT_RADIX = 10 ;
90+ public final static int DEFAULT_RADIX = - 1 ;
8891
8992 /**
9093 * Datatype-specific additional piece of configuration that may be used
142145 *
143146 * @since 2.21
144147 */
145- public byte radix () default DEFAULT_RADIX ;
148+ public int radix () default DEFAULT_RADIX ;
146149
147150 /**
148151 * Set of {@link JsonFormat.Feature}s to explicitly enable with respect
@@ -539,7 +542,7 @@ public static class Value
539542 /**
540543 * @since 2.21
541544 */
542- private final byte _radix ;
545+ private final int _radix ;
543546
544547 // lazily constructed when created from annotations
545548 private transient TimeZone _timezone ;
@@ -557,7 +560,7 @@ public Value(JsonFormat ann) {
557560 * @since 2.21
558561 */
559562 public Value (String p , Shape sh , String localeStr , String tzStr , Features f ,
560- Boolean lenient , byte radix )
563+ Boolean lenient , int radix )
561564 {
562565 this (p , sh ,
563566 (localeStr == null || localeStr .length () == 0 || DEFAULT_LOCALE .equals (localeStr )) ?
@@ -586,7 +589,7 @@ public Value(String p, Shape sh, String localeStr, String tzStr, Features f,
586589 * @since 2.21
587590 */
588591 public Value (String p , Shape sh , Locale l , TimeZone tz , Features f ,
589- Boolean lenient , byte radix )
592+ Boolean lenient , int radix )
590593 {
591594 _pattern = (p == null ) ? "" : p ;
592595 _shape = (sh == null ) ? Shape .ANY : sh ;
@@ -619,7 +622,7 @@ public Value(String p, Shape sh, Locale l, TimeZone tz, Features f,
619622 * @since 2.21
620623 */
621624 public Value (String p , Shape sh , Locale l , String tzStr , TimeZone tz , Features f ,
622- Boolean lenient , byte radix )
625+ Boolean lenient , int radix )
623626 {
624627 _pattern = (p == null ) ? "" : p ;
625628 _shape = (sh == null ) ? Shape .ANY : sh ;
@@ -718,6 +721,10 @@ public final Value withOverrides(Value overrides) {
718721 if (lenient == null ) {
719722 lenient = _lenient ;
720723 }
724+ int radix = overrides ._radix ;
725+ if (radix == DEFAULT_RADIX ) {
726+ radix = _radix ;
727+ }
721728
722729 // timezone not merged, just choose one
723730 String tzStr = overrides ._timezoneStr ;
@@ -729,7 +736,7 @@ public final Value withOverrides(Value overrides) {
729736 } else {
730737 tz = overrides ._timezone ;
731738 }
732- return new Value (p , sh , l , tzStr , tz , f , lenient , overrides . _radix );
739+ return new Value (p , sh , l , tzStr , tz , f , lenient , radix );
733740 }
734741
735742 /**
@@ -860,9 +867,11 @@ public Boolean getLenient() {
860867 }
861868
862869 /**
870+ * @return radix to use for serializing subclasses of {@link Number} as strings.
871+ * If set to -1, a custom radix has not been specified.
863872 * @since 2.21
864873 */
865- public byte getRadix () { return _radix ; }
874+ public int getRadix () { return _radix ; }
866875
867876 /**
868877 * Convenience method equivalent to
@@ -940,12 +949,12 @@ public boolean hasLenient() {
940949 }
941950
942951 /**
943- * Accessor for checking whether non-default (non- 10) radix has been specified.
952+ * Accessor for checking whether non-default (neither special default marker -1 nor 10) radix has been specified.
944953 *
945954 * @since 2.21
946955 */
947956 public boolean hasNonDefaultRadix () {
948- return _radix != DEFAULT_RADIX ;
957+ return _radix != DEFAULT_RADIX && _radix != 10 ;
949958 }
950959
951960 /**
0 commit comments