content: package code.inspector.form.module;
  
  import code.inspector.core.Const;
  import com.intellij.uiDesigner.core.GridConstraints;
  import com.intellij.uiDesigner.core.GridLayoutManager;
  
  import javax.swing.*;
  import javax.swing.border.TitledBorder;
  import javax.swing.plaf.FontUIResource;
  import javax.swing.text.StyleContext;
  import java.awt.*;
  import java.util.HashMap;
  import java.util.Locale;
  
  public class DeserializationModule {
      public JPanel parentPanel;
      private JCheckBox jdkReadObjectCheckBox;
      private JTextArea jdkArea;
      private JCheckBox fastjsonParseCheckBox;
      private JTextArea fastjsonArea;
      private JCheckBox snakeyamlLoadCheckBox;
      private JTextArea snakeyamlArea;
      private JCheckBox hessianReadObjectCheckBox;
      private JTextArea hessianArea;
      private JButton saveConfigButton;
      private JCheckBox jacksonReadCheckBox;
      private JTextArea jacksonArea;
      private JCheckBox xmlDecodeCheckBox;
      private JTextArea xmlArea;
  
      public DeserializationModule(HashMap<String, Boolean> option) {
          jdkReadObjectCheckBox.setSelected(option.getOrDefault(
                  Const.DESERIALIZATION_JDK, false));
          fastjsonParseCheckBox.setSelected(option.getOrDefault(
                  Const.DESERIALIZATION_FASTJSON, false));
          jacksonReadCheckBox.setSelected(option.getOrDefault(
                  Const.DESERIALIZATION_JACKSON, false));
          snakeyamlLoadCheckBox.setSelected(option.getOrDefault(
                  Const.DESERIALIZATION_SNAKEYAML, false));
          hessianReadObjectCheckBox.setSelected(option.getOrDefault(
                  Const.DESERIALIZATION_HESSIAN, false));
          xmlDecodeCheckBox.setSelected(option.getOrDefault(
                  Const.DESERIALIZATION_XML_DECODER, false));
          saveConfigButton.addActionListener(e -> {
              option.put(Const.DESERIALIZATION_JDK, jdkReadObjectCheckBox.isSelected());
              option.put(Const.DESERIALIZATION_FASTJSON, fastjsonParseCheckBox.isSelected());
              option.put(Const.DESERIALIZATION_JACKSON, jacksonReadCheckBox.isSelected());
              option.put(Const.DESERIALIZATION_SNAKEYAML, snakeyamlLoadCheckBox.isSelected());
              option.put(Const.DESERIALIZATION_HESSIAN, hessianReadObjectCheckBox.isSelected());
              option.put(Const.DESERIALIZATION_XML_DECODER, xmlDecodeCheckBox.isSelected());
              JOptionPane.showMessageDialog(parentPanel, "success!");
          });
      }
  
      {
  // GUI initializer generated by IntelliJ IDEA GUI Designer
  // >>> IMPORTANT!! <<<
  // DO NOT EDIT OR ADD ANY CODE HERE!
          $$$setupUI$$$();
      }
  
      /**
       * Method generated by IntelliJ IDEA GUI Designer
       * >>> IMPORTANT!! <<<
       * DO NOT edit this method OR call it in your code!
       *
       * @noinspection ALL
       */
      private void $$$setupUI$$$() {
          parentPanel = new JPanel();
          parentPanel.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1));
          parentPanel.setBorder(BorderFactory.createTitledBorder(null, "Deserialization Module", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
          jdkReadObjectCheckBox = new JCheckBox();
          jdkReadObjectCheckBox.setText("jdk read object");
          parentPanel.add(jdkReadObjectCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
          jdkArea = new JTextArea();
          jdkArea.setEditable(false);
          Font jdkAreaFont = this.$$$getFont$$$("Consolas", -1, 12, jdkArea.getFont());
          if (jdkAreaFont != null) jdkArea.setFont(jdkAreaFont);
          jdkArea.setForeground(new Color(-9097));
          jdkArea.setText("ObjectInputStream ois = new ObjectInputStream(\n                    new ByteArrayInputStream(input));\nObject o = ois.readObject();");
          parentPanel.add(jdkArea, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          fastjsonParseCheckBox = new JCheckBox();
          fastjsonParseCheckBox.setText("fastjson parse");
          parentPanel.add(fastjsonParseCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
          fastjsonArea = new JTextArea();
          fastjsonArea.setEditable(false);
          Font fastjsonAreaFont = this.$$$getFont$$$("Consolas", -1, 12, fastjsonArea.getFont());
          if (fastjsonAreaFont != null) fastjsonArea.setFont(fastjsonAreaFont);
          fastjsonArea.setForeground(new Color(-9097));
          fastjsonArea.setText("JSON.parse(input);\nJSON.parseArray(input);\nJSON.parseObject(input);");
          parentPanel.add(fastjsonArea, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          snakeyamlLoadCheckBox = new JCheckBox();
          snakeyamlLoadCheckBox.setText("snakeyaml load");
          parentPanel.add(snakeyamlLoadCheckBox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
          snakeyamlArea = new JTextArea();
          snakeyamlArea.setEditable(false);
          Font snakeyamlAreaFont = this.$$$getFont$$$("Consolas", -1, 12, snakeyamlArea.getFont());
          if (snakeyamlAreaFont != null) snakeyamlArea.setFont(snakeyamlAreaFont);
          snakeyamlArea.setForeground(new Color(-9097));
          snakeyamlArea.setText("Yaml yaml = new Yaml();\nyaml.load(input);");
          parentPanel.add(snakeyamlArea, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          hessianReadObjectCheckBox = new JCheckBox();
          hessianReadObjectCheckBox.setText("hessian read object");
          parentPanel.add(hessianReadObjectCheckBox, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
          hessianArea = new JTextArea();
          hessianArea.setEditable(false);
          Font hessianAreaFont = this.$$$getFont$$$("Consolas", -1, 12, hessianArea.getFont());
          if (hessianAreaFont != null) hessianArea.setFont(hessianAreaFont);
          hessianArea.setForeground(new Color(-9097));
          hessianArea.setText("Hessian2Input in = new Hessian2Input(\n                    new ByteArrayInputStream(input));\nObject obj = in.readObject();");
          parentPanel.add(hessianArea, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          saveConfigButton = new JButton();
          saveConfigButton.setText("Save Config");
          parentPanel.add(saveConfigButton, new GridConstraints(6, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
          jacksonReadCheckBox = new JCheckBox();
          jacksonReadCheckBox.setText("jackson read");
          parentPanel.add(jacksonReadCheckBox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
          jacksonArea = new JTextArea();
          jacksonArea.setEditable(false);
          Font jacksonAreaFont = this.$$$getFont$$$("Consolas", -1, 12, jacksonArea.getFont());
          if (jacksonAreaFont != null) jacksonArea.setFont(jacksonAreaFont);
          jacksonArea.setForeground(new Color(-9097));
          jacksonArea.setText("ObjectMapper mapper = new ObjectMapper();\nmapper.enableDefaultTyping();\nmapper.readValue(input, User.class);");
          parentPanel.add(jacksonArea, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
          xmlDecodeCheckBox = new JCheckBox();
          xmlDecodeCheckBox.setText("xml decoder ");
          parentPanel.add(xmlDecodeCheckBox, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
          xmlArea = new JTextArea();
          xmlArea.setEditable(false);
          Font xmlAreaFont = this.$$$getFont$$$("Consolas", -1, 12, xmlArea.getFont());
          if (xmlAreaFont != null) xmlArea.setFont(xmlAreaFont);
          xmlArea.setForeground(new Color(-9097));
          xmlArea.setText("XMLDecoder xmlDecoder = new XMLDecoder(bis);\nxmlDecoder.readObject();");
          parentPanel.add(xmlArea, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
      }
  
      /**
       * @noinspection ALL
       */
      private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) {
          if (currentFont == null) return null;
          String resultName;
          if (fontName == null) {
              resultName = currentFont.getName();
          } else {
              Font testFont = new Font(fontName, Font.PLAIN, 10);
              if (testFont.canDisplay('a') && testFont.canDisplay('1')) {
                  resultName = fontName;
              } else {
                  resultName = currentFont.getName();
              }
          }
          Font font = new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize());
          boolean isMac = System.getProperty("os.name", "").toLowerCase(Locale.ENGLISH).startsWith("mac");
          Font fontWithFallback = isMac ? new Font(font.getFamily(), font.getStyle(), font.getSize()) : new StyleContext().getFont(font.getFamily(), font.getStyle(), font.getSize());
          return fontWithFallback instanceof FontUIResource ? fontWithFallback : new FontUIResource(fontWithFallback);
      }
  
      /**
       * @noinspection ALL
       */
      public JComponent $$$getRootComponent$$$() {
          return parentPanel;
      }
  
  }
  