2929import java .util .List ;
3030import java .util .Map ;
3131import java .util .Optional ;
32+ import java .util .Properties ;
3233import java .util .UUID ;
3334
3435import io .avaje .json .JsonAdapter ;
3738import io .avaje .json .JsonWriter ;
3839import io .avaje .jsonb .AdapterFactory ;
3940import io .avaje .jsonb .Jsonb ;
41+ import io .avaje .jsonb .Types ;
4042
4143final class BasicTypeAdapters {
4244
@@ -49,14 +51,15 @@ final class BasicTypeAdapters {
4951 if (type == Byte .class ) return new ByteAdapter ().nullSafe ();
5052 if (type == Character .class ) return new CharacterAdapter ().nullSafe ();
5153 if (type == Short .class ) return new ShortAdapter ().nullSafe ();
54+ if (type == Object .class ) return new ObjectJsonAdapter (jsonb ).nullSafe ();
5255 if (type == UUID .class ) return new UuidAdapter ().nullSafe ();
5356 if (type == URL .class ) return new UrlAdapter ().nullSafe ();
5457 if (type == URI .class ) return new UriAdapter ().nullSafe ();
55- if (type == InetAddress .class ) return new InetAddressAdapter ().nullSafe ();
56- if (type == Inet4Address .class ) return new InetAddressAdapter ().nullSafe ();
57- if (type == Inet6Address .class ) return new InetAddressAdapter ().nullSafe ();
58+ if (type == Properties .class ) return new PropertiesAdapter (jsonb ).nullSafe ();
59+ if (type == InetAddress .class || type == Inet4Address .class || type == Inet6Address .class ) {
60+ return new InetAddressAdapter ().nullSafe ();
61+ }
5862 if (type == StackTraceElement .class ) return new StackTraceElementAdapter ().nullSafe ();
59- if (type == Object .class ) return new ObjectJsonAdapter (jsonb ).nullSafe ();
6063 if (type == Throwable .class ) return new ThrowableAdapter (jsonb ).nullSafe ();
6164
6265 final Class <?> rawType = Util .rawType (type );
@@ -121,6 +124,35 @@ public String toString() {
121124 }
122125 }
123126
127+ private static final class PropertiesAdapter implements JsonAdapter <Properties > {
128+ private JsonAdapter <Map <Object , Object >> mapAdapter ;
129+
130+ private PropertiesAdapter (Jsonb jsonb ) {
131+ this .mapAdapter = jsonb .adapter (Types .mapOf (Object .class ));
132+ }
133+
134+ @ Override
135+ public Properties fromJson (JsonReader reader ) {
136+ var map = mapAdapter .fromJson (reader );
137+ if (map == null ) {
138+ return null ;
139+ }
140+ var properties = new Properties ();
141+ properties .putAll (map );
142+ return properties ;
143+ }
144+
145+ @ Override
146+ public void toJson (JsonWriter writer , Properties value ) {
147+ mapAdapter .toJson (writer , value );
148+ }
149+
150+ @ Override
151+ public String toString () {
152+ return "JsonAdapter(Properties)" ;
153+ }
154+ }
155+
124156 private static final class InetAddressAdapter implements JsonAdapter <InetAddress > {
125157 @ Override
126158 public InetAddress fromJson (JsonReader reader ) {
0 commit comments