/*
 * This file is part of adventure, licensed under the MIT License.
 *
 * Copyright (c) 2017-2021 KyoriPowered
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package net.kyori.adventure.text.serializer.gson;

import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.nbt.api.BinaryTagHolder;
import net.kyori.adventure.text.event.HoverEvent;
import org.jetbrains.annotations.Nullable;

final class ShowItemSerializer extends TypeAdapter<HoverEvent.ShowItem> {

  public static final TypeAdapter<HoverEvent.ShowItem> INSTANCE = new ShowItemSerializer().nullSafe();

  static final String ID = "id";
  static final String COUNT = "count";
  static final String TAG = "tag";

  private ShowItemSerializer() {
  }

  @Override
  public HoverEvent.ShowItem read(final JsonReader in) throws IOException {
    in.beginObject();

    Key key = null;
    int count = 1;
    BinaryTagHolder nbt = null;

    while(in.hasNext()) {
      switch(in.nextName()) {
        case ID:
          key = KeySerializer.INSTANCE.read(in);
          break;
        case COUNT:
          count = in.nextInt();
          break;
        case TAG:
          switch(in.peek()) {
            case STRING:
            case NUMBER:
              nbt = BinaryTagHolder.of(in.nextString());
              break;
            case BOOLEAN:
              nbt = BinaryTagHolder.of(String.valueOf(in.nextBoolean()));
              break;
            case NULL:
              in.nextNull();
              break;
            default:
              throw new JsonParseException("Expected " + TAG + " to be a string");
          }
          break;
        default:
          in.skipValue();
          break;
      }
    }

    if(key == null) {
      throw new JsonParseException("Not sure how to deserialize show_item hover event");
    }
    in.endObject();

    return HoverEvent.ShowItem.of(key, count, nbt);
  }

  @Override
  public void write(final JsonWriter out, final HoverEvent.ShowItem value) throws IOException {
    out.beginObject();

    out.name(ID);
    KeySerializer.INSTANCE.write(out, value.item());

    final int count = value.count();
    if(count != 1) {
      out.name(COUNT).value(count);
    }

    final @Nullable BinaryTagHolder nbt = value.nbt();
    if(nbt != null) {
      out.name(TAG).value(nbt.string());
    }

    out.endObject();
  }
}

@@ -1353,24 +1353,65 @@
 JsonReader;%0A
+import com.google.gson.stream.JsonToken;%0A
 import com.g
@@ -1436,24 +1436,24 @@
 JsonWriter;%0A
-
 import java.
@@ -1724,17 +1724,16 @@
 Item%3E %7B%0A
-%0A
   public
@@ -2189,23 +2189,36 @@
 %7B%0A      
-switch(
+final String name = 
 in.nextN
@@ -2226,31 +2226,38 @@
 me()
-) %7B
+;
 %0A      
-  case ID:%0A  
+if(name.equals(ID)) %7B%0A
     
@@ -2309,41 +2309,40 @@
     
-    break;%0A        case COUNT:%0A  
+%7D else if(name.equals(COUNT)) %7B%0A
     
@@ -2377,54 +2377,69 @@
     
-    break;%0A        case TAG:%0A          switch(
+%7D else if(name.equals(TAG)) %7B%0A        final JsonToken peek = 
 in.p
@@ -2447,21 +2447,18 @@
 ek()
-) %7B%0A 
+;%0A
         
    c
@@ -2457,53 +2457,67 @@
     
-   case STRING:%0A            case NUMBER:%0A    
+if(peek == JsonToken.STRING %7C%7C peek == JsonToken.NUMBER) %7B%0A
     
@@ -2577,51 +2577,47 @@
     
-      break;%0A            case 
+%7D else if(peek == JsonToken.
 BOOLEAN
-:%0A    
+) %7B%0A
     
@@ -2694,119 +2694,86 @@
     
-      break;%0A            case NULL:%0A              in.nextNull();%0A              break;%0A            default:%0A    
+%7D else if(peek == JsonToken.NULL) %7B%0A          in.nextNull();%0A        %7D else %7B%0A
     
@@ -2859,18 +2859,16 @@
     
-  
 %7D%0A      
     
@@ -2867,38 +2867,17 @@
     
-    break;%0A        default:%0A  
+%7D else %7B%0A
     
@@ -2900,25 +2900,8 @@
 ();%0A
-          break;%0A
     

Write kashike-compliant code