@@ -53,16 +53,8 @@ public JsonObject asJsonObject() {
5353 return jsonObject ;
5454 }
5555
56- /* package private */ void write (MessagePacker packer ) throws IOException {
57- if (null == jsonObject ) {
58- // raw is null, so delta is not null
59- packer .packMapHeader (1 );
60- packer .packString (DELTA );
61- delta .write (packer );
62- } else {
63- // raw is not null, so delta can be ignored
56+ /* package private */ void write (MessagePacker packer ) {
6457 Serialisation .gsonToMsgpack (jsonObject , packer );
65- }
6658 }
6759
6860 /* package private */ static MessageExtras read (MessageUnpacker unpacker ) throws IOException {
@@ -112,14 +104,12 @@ public boolean equals(Object o) {
112104 if (this == o ) return true ;
113105 if (o == null || getClass () != o .getClass ()) return false ;
114106 MessageExtras that = (MessageExtras ) o ;
115- return (null == jsonObject ) ?
116- Objects .equals (delta , that .delta ) :
117- Objects .equals (jsonObject , that .jsonObject );
107+ return Objects .equals (jsonObject , that .jsonObject );
118108 }
119109
120110 @ Override
121111 public int hashCode () {
122- return ( null == jsonObject ) ? Objects . hashCode ( delta ) : Objects .hashCode (jsonObject );
112+ return Objects .hashCode (jsonObject );
123113 }
124114
125115 @ Override
@@ -133,17 +123,7 @@ public String toString() {
133123 public static class Serializer implements JsonSerializer <MessageExtras > {
134124 @ Override
135125 public JsonElement serialize (final MessageExtras src , final Type typeOfSrc , final JsonSerializationContext context ) {
136- return (null != src .jsonObject ) ? src .jsonObject : wrapDelta (src .getDelta ());
137- }
138-
139- public static JsonObject wrapDelta (final DeltaExtras delta ) {
140- if (null == delta ) {
141- throw new NullPointerException ("delta cannot be null." );
142- }
143-
144- final JsonObject json = new JsonObject ();
145- json .add (DELTA , Serialisation .gson .toJsonTree (delta ));
146- return json ;
126+ return src .jsonObject ;
147127 }
148128 }
149129}
0 commit comments