/**
 * Autogenerated by Thrift Compiler (0.20.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.jetbrains.cef.remote.thrift_codegen;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
public class MenuItem implements com.jetbrains.cef.remote.thrift.TBase<MenuItem, MenuItem._Fields>, java.io.Serializable, Cloneable, Comparable<MenuItem> {
  private static final com.jetbrains.cef.remote.thrift.protocol.TStruct STRUCT_DESC = new com.jetbrains.cef.remote.thrift.protocol.TStruct("MenuItem");

  private static final com.jetbrains.cef.remote.thrift.protocol.TField COMMAND_ID_FIELD_DESC = new com.jetbrains.cef.remote.thrift.protocol.TField("command_id", com.jetbrains.cef.remote.thrift.protocol.TType.I32, (short)1);
  private static final com.jetbrains.cef.remote.thrift.protocol.TField LABEL_FIELD_DESC = new com.jetbrains.cef.remote.thrift.protocol.TField("label", com.jetbrains.cef.remote.thrift.protocol.TType.STRING, (short)2);
  private static final com.jetbrains.cef.remote.thrift.protocol.TField TYPE_FIELD_DESC = new com.jetbrains.cef.remote.thrift.protocol.TField("type", com.jetbrains.cef.remote.thrift.protocol.TType.I32, (short)3);
  private static final com.jetbrains.cef.remote.thrift.protocol.TField GROUP_ID_FIELD_DESC = new com.jetbrains.cef.remote.thrift.protocol.TField("group_id", com.jetbrains.cef.remote.thrift.protocol.TType.I32, (short)4);
  private static final com.jetbrains.cef.remote.thrift.protocol.TField VISIBLE_FIELD_DESC = new com.jetbrains.cef.remote.thrift.protocol.TField("visible", com.jetbrains.cef.remote.thrift.protocol.TType.BOOL, (short)5);
  private static final com.jetbrains.cef.remote.thrift.protocol.TField ENABLED_FIELD_DESC = new com.jetbrains.cef.remote.thrift.protocol.TField("enabled", com.jetbrains.cef.remote.thrift.protocol.TType.BOOL, (short)6);
  private static final com.jetbrains.cef.remote.thrift.protocol.TField CHECKED_FIELD_DESC = new com.jetbrains.cef.remote.thrift.protocol.TField("checked", com.jetbrains.cef.remote.thrift.protocol.TType.BOOL, (short)7);
  private static final com.jetbrains.cef.remote.thrift.protocol.TField SUB_MENU_FIELD_DESC = new com.jetbrains.cef.remote.thrift.protocol.TField("sub_menu", com.jetbrains.cef.remote.thrift.protocol.TType.LIST, (short)8);

  private static final com.jetbrains.cef.remote.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new MenuItemStandardSchemeFactory();
  private static final com.jetbrains.cef.remote.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new MenuItemTupleSchemeFactory();

  public int command_id; // required
  public @com.jetbrains.cef.remote.thrift.annotation.Nullable java.lang.String label; // required
  /**
   * 
   * @see MenuItemType
   */
  public @com.jetbrains.cef.remote.thrift.annotation.Nullable MenuItemType type; // required
  public int group_id; // required
  public boolean visible; // required
  public boolean enabled; // required
  public boolean checked; // required
  public @com.jetbrains.cef.remote.thrift.annotation.Nullable java.util.List<MenuItem> sub_menu; // required

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements com.jetbrains.cef.remote.thrift.TFieldIdEnum {
    COMMAND_ID((short)1, "command_id"),
    LABEL((short)2, "label"),
    /**
     * 
     * @see MenuItemType
     */
    TYPE((short)3, "type"),
    GROUP_ID((short)4, "group_id"),
    VISIBLE((short)5, "visible"),
    ENABLED((short)6, "enabled"),
    CHECKED((short)7, "checked"),
    SUB_MENU((short)8, "sub_menu");

    private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

    static {
      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    @com.jetbrains.cef.remote.thrift.annotation.Nullable
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // COMMAND_ID
          return COMMAND_ID;
        case 2: // LABEL
          return LABEL;
        case 3: // TYPE
          return TYPE;
        case 4: // GROUP_ID
          return GROUP_ID;
        case 5: // VISIBLE
          return VISIBLE;
        case 6: // ENABLED
          return ENABLED;
        case 7: // CHECKED
          return CHECKED;
        case 8: // SUB_MENU
          return SUB_MENU;
        default:
          return null;
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, throwing an exception
     * if it is not found.
     */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    @com.jetbrains.cef.remote.thrift.annotation.Nullable
    public static _Fields findByName(java.lang.String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final java.lang.String _fieldName;

    _Fields(short thriftId, java.lang.String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    @Override
    public short getThriftFieldId() {
      return _thriftId;
    }

    @Override
    public java.lang.String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __COMMAND_ID_ISSET_ID = 0;
  private static final int __GROUP_ID_ISSET_ID = 1;
  private static final int __VISIBLE_ISSET_ID = 2;
  private static final int __ENABLED_ISSET_ID = 3;
  private static final int __CHECKED_ISSET_ID = 4;
  private byte __isset_bitfield = 0;
  public static final java.util.Map<_Fields, com.jetbrains.cef.remote.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    java.util.Map<_Fields, com.jetbrains.cef.remote.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, com.jetbrains.cef.remote.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.COMMAND_ID, new com.jetbrains.cef.remote.thrift.meta_data.FieldMetaData("command_id", com.jetbrains.cef.remote.thrift.TFieldRequirementType.REQUIRED, 
        new com.jetbrains.cef.remote.thrift.meta_data.FieldValueMetaData(com.jetbrains.cef.remote.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.LABEL, new com.jetbrains.cef.remote.thrift.meta_data.FieldMetaData("label", com.jetbrains.cef.remote.thrift.TFieldRequirementType.REQUIRED, 
        new com.jetbrains.cef.remote.thrift.meta_data.FieldValueMetaData(com.jetbrains.cef.remote.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.TYPE, new com.jetbrains.cef.remote.thrift.meta_data.FieldMetaData("type", com.jetbrains.cef.remote.thrift.TFieldRequirementType.REQUIRED, 
        new com.jetbrains.cef.remote.thrift.meta_data.EnumMetaData(com.jetbrains.cef.remote.thrift.protocol.TType.ENUM, MenuItemType.class)));
    tmpMap.put(_Fields.GROUP_ID, new com.jetbrains.cef.remote.thrift.meta_data.FieldMetaData("group_id", com.jetbrains.cef.remote.thrift.TFieldRequirementType.REQUIRED, 
        new com.jetbrains.cef.remote.thrift.meta_data.FieldValueMetaData(com.jetbrains.cef.remote.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.VISIBLE, new com.jetbrains.cef.remote.thrift.meta_data.FieldMetaData("visible", com.jetbrains.cef.remote.thrift.TFieldRequirementType.REQUIRED, 
        new com.jetbrains.cef.remote.thrift.meta_data.FieldValueMetaData(com.jetbrains.cef.remote.thrift.protocol.TType.BOOL)));
    tmpMap.put(_Fields.ENABLED, new com.jetbrains.cef.remote.thrift.meta_data.FieldMetaData("enabled", com.jetbrains.cef.remote.thrift.TFieldRequirementType.REQUIRED, 
        new com.jetbrains.cef.remote.thrift.meta_data.FieldValueMetaData(com.jetbrains.cef.remote.thrift.protocol.TType.BOOL)));
    tmpMap.put(_Fields.CHECKED, new com.jetbrains.cef.remote.thrift.meta_data.FieldMetaData("checked", com.jetbrains.cef.remote.thrift.TFieldRequirementType.REQUIRED, 
        new com.jetbrains.cef.remote.thrift.meta_data.FieldValueMetaData(com.jetbrains.cef.remote.thrift.protocol.TType.BOOL)));
    tmpMap.put(_Fields.SUB_MENU, new com.jetbrains.cef.remote.thrift.meta_data.FieldMetaData("sub_menu", com.jetbrains.cef.remote.thrift.TFieldRequirementType.REQUIRED, 
        new com.jetbrains.cef.remote.thrift.meta_data.ListMetaData(com.jetbrains.cef.remote.thrift.protocol.TType.LIST, 
            new com.jetbrains.cef.remote.thrift.meta_data.StructMetaData(com.jetbrains.cef.remote.thrift.protocol.TType.STRUCT, MenuItem.class))));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    com.jetbrains.cef.remote.thrift.meta_data.FieldMetaData.addStructMetaDataMap(MenuItem.class, metaDataMap);
  }

  public MenuItem() {
    this.command_id = -1;

    this.label = "";

    this.type = com.jetbrains.cef.remote.thrift_codegen.MenuItemType.MENUITEMTYPE_NONE;

    this.group_id = -1;

    this.visible = true;

    this.enabled = true;

    this.checked = false;

    this.sub_menu = new java.util.ArrayList<MenuItem>();

  }

  public MenuItem(
    int command_id,
    java.lang.String label,
    MenuItemType type,
    int group_id,
    boolean visible,
    boolean enabled,
    boolean checked,
    java.util.List<MenuItem> sub_menu)
  {
    this();
    this.command_id = command_id;
    setCommand_idIsSet(true);
    this.label = label;
    this.type = type;
    this.group_id = group_id;
    setGroup_idIsSet(true);
    this.visible = visible;
    setVisibleIsSet(true);
    this.enabled = enabled;
    setEnabledIsSet(true);
    this.checked = checked;
    setCheckedIsSet(true);
    this.sub_menu = sub_menu;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public MenuItem(MenuItem other) {
    __isset_bitfield = other.__isset_bitfield;
    this.command_id = other.command_id;
    if (other.isSetLabel()) {
      this.label = other.label;
    }
    if (other.isSetType()) {
      this.type = other.type;
    }
    this.group_id = other.group_id;
    this.visible = other.visible;
    this.enabled = other.enabled;
    this.checked = other.checked;
    if (other.isSetSub_menu()) {
      java.util.List<MenuItem> __this__sub_menu = new java.util.ArrayList<MenuItem>(other.sub_menu.size());
      for (MenuItem other_element : other.sub_menu) {
        __this__sub_menu.add(new MenuItem(other_element));
      }
      this.sub_menu = __this__sub_menu;
    }
  }

  @Override
  public MenuItem deepCopy() {
    return new MenuItem(this);
  }

  @Override
  public void clear() {
    this.command_id = -1;

    this.label = "";

    this.type = com.jetbrains.cef.remote.thrift_codegen.MenuItemType.MENUITEMTYPE_NONE;

    this.group_id = -1;

    this.visible = true;

    this.enabled = true;

    this.checked = false;

    this.sub_menu = new java.util.ArrayList<MenuItem>();

  }

  public int getCommand_id() {
    return this.command_id;
  }

  public MenuItem setCommand_id(int command_id) {
    this.command_id = command_id;
    setCommand_idIsSet(true);
    return this;
  }

  public void unsetCommand_id() {
    __isset_bitfield = com.jetbrains.cef.remote.thrift.EncodingUtils.clearBit(__isset_bitfield, __COMMAND_ID_ISSET_ID);
  }

  /** Returns true if field command_id is set (has been assigned a value) and false otherwise */
  public boolean isSetCommand_id() {
    return com.jetbrains.cef.remote.thrift.EncodingUtils.testBit(__isset_bitfield, __COMMAND_ID_ISSET_ID);
  }

  public void setCommand_idIsSet(boolean value) {
    __isset_bitfield = com.jetbrains.cef.remote.thrift.EncodingUtils.setBit(__isset_bitfield, __COMMAND_ID_ISSET_ID, value);
  }

  @com.jetbrains.cef.remote.thrift.annotation.Nullable
  public java.lang.String getLabel() {
    return this.label;
  }

  public MenuItem setLabel(@com.jetbrains.cef.remote.thrift.annotation.Nullable java.lang.String label) {
    this.label = label;
    return this;
  }

  public void unsetLabel() {
    this.label = null;
  }

  /** Returns true if field label is set (has been assigned a value) and false otherwise */
  public boolean isSetLabel() {
    return this.label != null;
  }

  public void setLabelIsSet(boolean value) {
    if (!value) {
      this.label = null;
    }
  }

  /**
   * 
   * @see MenuItemType
   */
  @com.jetbrains.cef.remote.thrift.annotation.Nullable
  public MenuItemType getType() {
    return this.type;
  }

  /**
   * 
   * @see MenuItemType
   */
  public MenuItem setType(@com.jetbrains.cef.remote.thrift.annotation.Nullable MenuItemType type) {
    this.type = type;
    return this;
  }

  public void unsetType() {
    this.type = null;
  }

  /** Returns true if field type is set (has been assigned a value) and false otherwise */
  public boolean isSetType() {
    return this.type != null;
  }

  public void setTypeIsSet(boolean value) {
    if (!value) {
      this.type = null;
    }
  }

  public int getGroup_id() {
    return this.group_id;
  }

  public MenuItem setGroup_id(int group_id) {
    this.group_id = group_id;
    setGroup_idIsSet(true);
    return this;
  }

  public void unsetGroup_id() {
    __isset_bitfield = com.jetbrains.cef.remote.thrift.EncodingUtils.clearBit(__isset_bitfield, __GROUP_ID_ISSET_ID);
  }

  /** Returns true if field group_id is set (has been assigned a value) and false otherwise */
  public boolean isSetGroup_id() {
    return com.jetbrains.cef.remote.thrift.EncodingUtils.testBit(__isset_bitfield, __GROUP_ID_ISSET_ID);
  }

  public void setGroup_idIsSet(boolean value) {
    __isset_bitfield = com.jetbrains.cef.remote.thrift.EncodingUtils.setBit(__isset_bitfield, __GROUP_ID_ISSET_ID, value);
  }

  public boolean isVisible() {
    return this.visible;
  }

  public MenuItem setVisible(boolean visible) {
    this.visible = visible;
    setVisibleIsSet(true);
    return this;
  }

  public void unsetVisible() {
    __isset_bitfield = com.jetbrains.cef.remote.thrift.EncodingUtils.clearBit(__isset_bitfield, __VISIBLE_ISSET_ID);
  }

  /** Returns true if field visible is set (has been assigned a value) and false otherwise */
  public boolean isSetVisible() {
    return com.jetbrains.cef.remote.thrift.EncodingUtils.testBit(__isset_bitfield, __VISIBLE_ISSET_ID);
  }

  public void setVisibleIsSet(boolean value) {
    __isset_bitfield = com.jetbrains.cef.remote.thrift.EncodingUtils.setBit(__isset_bitfield, __VISIBLE_ISSET_ID, value);
  }

  public boolean isEnabled() {
    return this.enabled;
  }

  public MenuItem setEnabled(boolean enabled) {
    this.enabled = enabled;
    setEnabledIsSet(true);
    return this;
  }

  public void unsetEnabled() {
    __isset_bitfield = com.jetbrains.cef.remote.thrift.EncodingUtils.clearBit(__isset_bitfield, __ENABLED_ISSET_ID);
  }

  /** Returns true if field enabled is set (has been assigned a value) and false otherwise */
  public boolean isSetEnabled() {
    return com.jetbrains.cef.remote.thrift.EncodingUtils.testBit(__isset_bitfield, __ENABLED_ISSET_ID);
  }

  public void setEnabledIsSet(boolean value) {
    __isset_bitfield = com.jetbrains.cef.remote.thrift.EncodingUtils.setBit(__isset_bitfield, __ENABLED_ISSET_ID, value);
  }

  public boolean isChecked() {
    return this.checked;
  }

  public MenuItem setChecked(boolean checked) {
    this.checked = checked;
    setCheckedIsSet(true);
    return this;
  }

  public void unsetChecked() {
    __isset_bitfield = com.jetbrains.cef.remote.thrift.EncodingUtils.clearBit(__isset_bitfield, __CHECKED_ISSET_ID);
  }

  /** Returns true if field checked is set (has been assigned a value) and false otherwise */
  public boolean isSetChecked() {
    return com.jetbrains.cef.remote.thrift.EncodingUtils.testBit(__isset_bitfield, __CHECKED_ISSET_ID);
  }

  public void setCheckedIsSet(boolean value) {
    __isset_bitfield = com.jetbrains.cef.remote.thrift.EncodingUtils.setBit(__isset_bitfield, __CHECKED_ISSET_ID, value);
  }

  public int getSub_menuSize() {
    return (this.sub_menu == null) ? 0 : this.sub_menu.size();
  }

  @com.jetbrains.cef.remote.thrift.annotation.Nullable
  public java.util.Iterator<MenuItem> getSub_menuIterator() {
    return (this.sub_menu == null) ? null : this.sub_menu.iterator();
  }

  public void addToSub_menu(MenuItem elem) {
    if (this.sub_menu == null) {
      this.sub_menu = new java.util.ArrayList<MenuItem>();
    }
    this.sub_menu.add(elem);
  }

  @com.jetbrains.cef.remote.thrift.annotation.Nullable
  public java.util.List<MenuItem> getSub_menu() {
    return this.sub_menu;
  }

  public MenuItem setSub_menu(@com.jetbrains.cef.remote.thrift.annotation.Nullable java.util.List<MenuItem> sub_menu) {
    this.sub_menu = sub_menu;
    return this;
  }

  public void unsetSub_menu() {
    this.sub_menu = null;
  }

  /** Returns true if field sub_menu is set (has been assigned a value) and false otherwise */
  public boolean isSetSub_menu() {
    return this.sub_menu != null;
  }

  public void setSub_menuIsSet(boolean value) {
    if (!value) {
      this.sub_menu = null;
    }
  }

  @Override
  public void setFieldValue(_Fields field, @com.jetbrains.cef.remote.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case COMMAND_ID:
      if (value == null) {
        unsetCommand_id();
      } else {
        setCommand_id((java.lang.Integer)value);
      }
      break;

    case LABEL:
      if (value == null) {
        unsetLabel();
      } else {
        setLabel((java.lang.String)value);
      }
      break;

    case TYPE:
      if (value == null) {
        unsetType();
      } else {
        setType((MenuItemType)value);
      }
      break;

    case GROUP_ID:
      if (value == null) {
        unsetGroup_id();
      } else {
        setGroup_id((java.lang.Integer)value);
      }
      break;

    case VISIBLE:
      if (value == null) {
        unsetVisible();
      } else {
        setVisible((java.lang.Boolean)value);
      }
      break;

    case ENABLED:
      if (value == null) {
        unsetEnabled();
      } else {
        setEnabled((java.lang.Boolean)value);
      }
      break;

    case CHECKED:
      if (value == null) {
        unsetChecked();
      } else {
        setChecked((java.lang.Boolean)value);
      }
      break;

    case SUB_MENU:
      if (value == null) {
        unsetSub_menu();
      } else {
        setSub_menu((java.util.List<MenuItem>)value);
      }
      break;

    }
  }

  @com.jetbrains.cef.remote.thrift.annotation.Nullable
  @Override
  public java.lang.Object getFieldValue(_Fields field) {
    switch (field) {
    case COMMAND_ID:
      return getCommand_id();

    case LABEL:
      return getLabel();

    case TYPE:
      return getType();

    case GROUP_ID:
      return getGroup_id();

    case VISIBLE:
      return isVisible();

    case ENABLED:
      return isEnabled();

    case CHECKED:
      return isChecked();

    case SUB_MENU:
      return getSub_menu();

    }
    throw new java.lang.IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  @Override
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new java.lang.IllegalArgumentException();
    }

    switch (field) {
    case COMMAND_ID:
      return isSetCommand_id();
    case LABEL:
      return isSetLabel();
    case TYPE:
      return isSetType();
    case GROUP_ID:
      return isSetGroup_id();
    case VISIBLE:
      return isSetVisible();
    case ENABLED:
      return isSetEnabled();
    case CHECKED:
      return isSetChecked();
    case SUB_MENU:
      return isSetSub_menu();
    }
    throw new java.lang.IllegalStateException();
  }

  @Override
  public boolean equals(java.lang.Object that) {
    if (that instanceof MenuItem)
      return this.equals((MenuItem)that);
    return false;
  }

  public boolean equals(MenuItem that) {
    if (that == null)
      return false;
    if (this == that)
      return true;

    boolean this_present_command_id = true;
    boolean that_present_command_id = true;
    if (this_present_command_id || that_present_command_id) {
      if (!(this_present_command_id && that_present_command_id))
        return false;
      if (this.command_id != that.command_id)
        return false;
    }

    boolean this_present_label = true && this.isSetLabel();
    boolean that_present_label = true && that.isSetLabel();
    if (this_present_label || that_present_label) {
      if (!(this_present_label && that_present_label))
        return false;
      if (!this.label.equals(that.label))
        return false;
    }

    boolean this_present_type = true && this.isSetType();
    boolean that_present_type = true && that.isSetType();
    if (this_present_type || that_present_type) {
      if (!(this_present_type && that_present_type))
        return false;
      if (!this.type.equals(that.type))
        return false;
    }

    boolean this_present_group_id = true;
    boolean that_present_group_id = true;
    if (this_present_group_id || that_present_group_id) {
      if (!(this_present_group_id && that_present_group_id))
        return false;
      if (this.group_id != that.group_id)
        return false;
    }

    boolean this_present_visible = true;
    boolean that_present_visible = true;
    if (this_present_visible || that_present_visible) {
      if (!(this_present_visible && that_present_visible))
        return false;
      if (this.visible != that.visible)
        return false;
    }

    boolean this_present_enabled = true;
    boolean that_present_enabled = true;
    if (this_present_enabled || that_present_enabled) {
      if (!(this_present_enabled && that_present_enabled))
        return false;
      if (this.enabled != that.enabled)
        return false;
    }

    boolean this_present_checked = true;
    boolean that_present_checked = true;
    if (this_present_checked || that_present_checked) {
      if (!(this_present_checked && that_present_checked))
        return false;
      if (this.checked != that.checked)
        return false;
    }

    boolean this_present_sub_menu = true && this.isSetSub_menu();
    boolean that_present_sub_menu = true && that.isSetSub_menu();
    if (this_present_sub_menu || that_present_sub_menu) {
      if (!(this_present_sub_menu && that_present_sub_menu))
        return false;
      if (!this.sub_menu.equals(that.sub_menu))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int hashCode = 1;

    hashCode = hashCode * 8191 + command_id;

    hashCode = hashCode * 8191 + ((isSetLabel()) ? 131071 : 524287);
    if (isSetLabel())
      hashCode = hashCode * 8191 + label.hashCode();

    hashCode = hashCode * 8191 + ((isSetType()) ? 131071 : 524287);
    if (isSetType())
      hashCode = hashCode * 8191 + type.getValue();

    hashCode = hashCode * 8191 + group_id;

    hashCode = hashCode * 8191 + ((visible) ? 131071 : 524287);

    hashCode = hashCode * 8191 + ((enabled) ? 131071 : 524287);

    hashCode = hashCode * 8191 + ((checked) ? 131071 : 524287);

    hashCode = hashCode * 8191 + ((isSetSub_menu()) ? 131071 : 524287);
    if (isSetSub_menu())
      hashCode = hashCode * 8191 + sub_menu.hashCode();

    return hashCode;
  }

  @Override
  public int compareTo(MenuItem other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.compare(isSetCommand_id(), other.isSetCommand_id());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCommand_id()) {
      lastComparison = com.jetbrains.cef.remote.thrift.TBaseHelper.compareTo(this.command_id, other.command_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetLabel(), other.isSetLabel());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetLabel()) {
      lastComparison = com.jetbrains.cef.remote.thrift.TBaseHelper.compareTo(this.label, other.label);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetType(), other.isSetType());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetType()) {
      lastComparison = com.jetbrains.cef.remote.thrift.TBaseHelper.compareTo(this.type, other.type);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetGroup_id(), other.isSetGroup_id());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetGroup_id()) {
      lastComparison = com.jetbrains.cef.remote.thrift.TBaseHelper.compareTo(this.group_id, other.group_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetVisible(), other.isSetVisible());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetVisible()) {
      lastComparison = com.jetbrains.cef.remote.thrift.TBaseHelper.compareTo(this.visible, other.visible);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetEnabled(), other.isSetEnabled());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetEnabled()) {
      lastComparison = com.jetbrains.cef.remote.thrift.TBaseHelper.compareTo(this.enabled, other.enabled);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetChecked(), other.isSetChecked());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetChecked()) {
      lastComparison = com.jetbrains.cef.remote.thrift.TBaseHelper.compareTo(this.checked, other.checked);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.compare(isSetSub_menu(), other.isSetSub_menu());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSub_menu()) {
      lastComparison = com.jetbrains.cef.remote.thrift.TBaseHelper.compareTo(this.sub_menu, other.sub_menu);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  @com.jetbrains.cef.remote.thrift.annotation.Nullable
  @Override
  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  @Override
  public void read(com.jetbrains.cef.remote.thrift.protocol.TProtocol iprot) throws com.jetbrains.cef.remote.thrift.TException {
    scheme(iprot).read(iprot, this);
  }

  @Override
  public void write(com.jetbrains.cef.remote.thrift.protocol.TProtocol oprot) throws com.jetbrains.cef.remote.thrift.TException {
    scheme(oprot).write(oprot, this);
  }

  @Override
  public java.lang.String toString() {
    java.lang.StringBuilder sb = new java.lang.StringBuilder("MenuItem(");
    boolean first = true;

    sb.append("command_id:");
    sb.append(this.command_id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("label:");
    if (this.label == null) {
      sb.append("null");
    } else {
      sb.append(this.label);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("type:");
    if (this.type == null) {
      sb.append("null");
    } else {
      sb.append(this.type);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("group_id:");
    sb.append(this.group_id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("visible:");
    sb.append(this.visible);
    first = false;
    if (!first) sb.append(", ");
    sb.append("enabled:");
    sb.append(this.enabled);
    first = false;
    if (!first) sb.append(", ");
    sb.append("checked:");
    sb.append(this.checked);
    first = false;
    if (!first) sb.append(", ");
    sb.append("sub_menu:");
    if (this.sub_menu == null) {
      sb.append("null");
    } else {
      sb.append(this.sub_menu);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws com.jetbrains.cef.remote.thrift.TException {
    // check for required fields
    // alas, we cannot check 'command_id' because it's a primitive and you chose the non-beans generator.
    if (label == null) {
      throw new com.jetbrains.cef.remote.thrift.protocol.TProtocolException("Required field 'label' was not present! Struct: " + toString());
    }
    if (type == null) {
      throw new com.jetbrains.cef.remote.thrift.protocol.TProtocolException("Required field 'type' was not present! Struct: " + toString());
    }
    // alas, we cannot check 'group_id' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'visible' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'enabled' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'checked' because it's a primitive and you chose the non-beans generator.
    if (sub_menu == null) {
      throw new com.jetbrains.cef.remote.thrift.protocol.TProtocolException("Required field 'sub_menu' was not present! Struct: " + toString());
    }
    // check for sub-struct validity
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new com.jetbrains.cef.remote.thrift.protocol.TCompactProtocol(new com.jetbrains.cef.remote.thrift.transport.TIOStreamTransport(out)));
    } catch (com.jetbrains.cef.remote.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
    try {
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
      __isset_bitfield = 0;
      read(new com.jetbrains.cef.remote.thrift.protocol.TCompactProtocol(new com.jetbrains.cef.remote.thrift.transport.TIOStreamTransport(in)));
    } catch (com.jetbrains.cef.remote.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class MenuItemStandardSchemeFactory implements com.jetbrains.cef.remote.thrift.scheme.SchemeFactory {
    @Override
    public MenuItemStandardScheme getScheme() {
      return new MenuItemStandardScheme();
    }
  }

  private static class MenuItemStandardScheme extends com.jetbrains.cef.remote.thrift.scheme.StandardScheme<MenuItem> {

    @Override
    public void read(com.jetbrains.cef.remote.thrift.protocol.TProtocol iprot, MenuItem struct) throws com.jetbrains.cef.remote.thrift.TException {
      com.jetbrains.cef.remote.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true)
      {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == com.jetbrains.cef.remote.thrift.protocol.TType.STOP) { 
          break;
        }
        switch (schemeField.id) {
          case 1: // COMMAND_ID
            if (schemeField.type == com.jetbrains.cef.remote.thrift.protocol.TType.I32) {
              struct.command_id = iprot.readI32();
              struct.setCommand_idIsSet(true);
            } else { 
              com.jetbrains.cef.remote.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // LABEL
            if (schemeField.type == com.jetbrains.cef.remote.thrift.protocol.TType.STRING) {
              struct.label = iprot.readString();
              struct.setLabelIsSet(true);
            } else { 
              com.jetbrains.cef.remote.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // TYPE
            if (schemeField.type == com.jetbrains.cef.remote.thrift.protocol.TType.I32) {
              struct.type = com.jetbrains.cef.remote.thrift_codegen.MenuItemType.findByValue(iprot.readI32());
              struct.setTypeIsSet(true);
            } else { 
              com.jetbrains.cef.remote.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // GROUP_ID
            if (schemeField.type == com.jetbrains.cef.remote.thrift.protocol.TType.I32) {
              struct.group_id = iprot.readI32();
              struct.setGroup_idIsSet(true);
            } else { 
              com.jetbrains.cef.remote.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // VISIBLE
            if (schemeField.type == com.jetbrains.cef.remote.thrift.protocol.TType.BOOL) {
              struct.visible = iprot.readBool();
              struct.setVisibleIsSet(true);
            } else { 
              com.jetbrains.cef.remote.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // ENABLED
            if (schemeField.type == com.jetbrains.cef.remote.thrift.protocol.TType.BOOL) {
              struct.enabled = iprot.readBool();
              struct.setEnabledIsSet(true);
            } else { 
              com.jetbrains.cef.remote.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // CHECKED
            if (schemeField.type == com.jetbrains.cef.remote.thrift.protocol.TType.BOOL) {
              struct.checked = iprot.readBool();
              struct.setCheckedIsSet(true);
            } else { 
              com.jetbrains.cef.remote.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 8: // SUB_MENU
            if (schemeField.type == com.jetbrains.cef.remote.thrift.protocol.TType.LIST) {
              {
                com.jetbrains.cef.remote.thrift.protocol.TList _list0 = iprot.readListBegin();
                struct.sub_menu = new java.util.ArrayList<MenuItem>(_list0.size);
                @com.jetbrains.cef.remote.thrift.annotation.Nullable MenuItem _elem1;
                for (int _i2 = 0; _i2 < _list0.size; ++_i2)
                {
                  _elem1 = new MenuItem();
                  _elem1.read(iprot);
                  struct.sub_menu.add(_elem1);
                }
                iprot.readListEnd();
              }
              struct.setSub_menuIsSet(true);
            } else { 
              com.jetbrains.cef.remote.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            com.jetbrains.cef.remote.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();

      // check for required fields of primitive type, which can't be checked in the validate method
      if (!struct.isSetCommand_id()) {
        throw new com.jetbrains.cef.remote.thrift.protocol.TProtocolException("Required field 'command_id' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetGroup_id()) {
        throw new com.jetbrains.cef.remote.thrift.protocol.TProtocolException("Required field 'group_id' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetVisible()) {
        throw new com.jetbrains.cef.remote.thrift.protocol.TProtocolException("Required field 'visible' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetEnabled()) {
        throw new com.jetbrains.cef.remote.thrift.protocol.TProtocolException("Required field 'enabled' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetChecked()) {
        throw new com.jetbrains.cef.remote.thrift.protocol.TProtocolException("Required field 'checked' was not found in serialized data! Struct: " + toString());
      }
      struct.validate();
    }

    @Override
    public void write(com.jetbrains.cef.remote.thrift.protocol.TProtocol oprot, MenuItem struct) throws com.jetbrains.cef.remote.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(COMMAND_ID_FIELD_DESC);
      oprot.writeI32(struct.command_id);
      oprot.writeFieldEnd();
      if (struct.label != null) {
        oprot.writeFieldBegin(LABEL_FIELD_DESC);
        oprot.writeString(struct.label);
        oprot.writeFieldEnd();
      }
      if (struct.type != null) {
        oprot.writeFieldBegin(TYPE_FIELD_DESC);
        oprot.writeI32(struct.type.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(GROUP_ID_FIELD_DESC);
      oprot.writeI32(struct.group_id);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(VISIBLE_FIELD_DESC);
      oprot.writeBool(struct.visible);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(ENABLED_FIELD_DESC);
      oprot.writeBool(struct.enabled);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(CHECKED_FIELD_DESC);
      oprot.writeBool(struct.checked);
      oprot.writeFieldEnd();
      if (struct.sub_menu != null) {
        oprot.writeFieldBegin(SUB_MENU_FIELD_DESC);
        {
          oprot.writeListBegin(new com.jetbrains.cef.remote.thrift.protocol.TList(com.jetbrains.cef.remote.thrift.protocol.TType.STRUCT, struct.sub_menu.size()));
          for (MenuItem _iter3 : struct.sub_menu)
          {
            _iter3.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class MenuItemTupleSchemeFactory implements com.jetbrains.cef.remote.thrift.scheme.SchemeFactory {
    @Override
    public MenuItemTupleScheme getScheme() {
      return new MenuItemTupleScheme();
    }
  }

  private static class MenuItemTupleScheme extends com.jetbrains.cef.remote.thrift.scheme.TupleScheme<MenuItem> {

    @Override
    public void write(com.jetbrains.cef.remote.thrift.protocol.TProtocol prot, MenuItem struct) throws com.jetbrains.cef.remote.thrift.TException {
      com.jetbrains.cef.remote.thrift.protocol.TTupleProtocol oprot = (com.jetbrains.cef.remote.thrift.protocol.TTupleProtocol) prot;
      oprot.writeI32(struct.command_id);
      oprot.writeString(struct.label);
      oprot.writeI32(struct.type.getValue());
      oprot.writeI32(struct.group_id);
      oprot.writeBool(struct.visible);
      oprot.writeBool(struct.enabled);
      oprot.writeBool(struct.checked);
      {
        oprot.writeI32(struct.sub_menu.size());
        for (MenuItem _iter4 : struct.sub_menu)
        {
          _iter4.write(oprot);
        }
      }
    }

    @Override
    public void read(com.jetbrains.cef.remote.thrift.protocol.TProtocol prot, MenuItem struct) throws com.jetbrains.cef.remote.thrift.TException {
      com.jetbrains.cef.remote.thrift.protocol.TTupleProtocol iprot = (com.jetbrains.cef.remote.thrift.protocol.TTupleProtocol) prot;
      struct.command_id = iprot.readI32();
      struct.setCommand_idIsSet(true);
      struct.label = iprot.readString();
      struct.setLabelIsSet(true);
      struct.type = com.jetbrains.cef.remote.thrift_codegen.MenuItemType.findByValue(iprot.readI32());
      struct.setTypeIsSet(true);
      struct.group_id = iprot.readI32();
      struct.setGroup_idIsSet(true);
      struct.visible = iprot.readBool();
      struct.setVisibleIsSet(true);
      struct.enabled = iprot.readBool();
      struct.setEnabledIsSet(true);
      struct.checked = iprot.readBool();
      struct.setCheckedIsSet(true);
      {
        com.jetbrains.cef.remote.thrift.protocol.TList _list5 = iprot.readListBegin(com.jetbrains.cef.remote.thrift.protocol.TType.STRUCT);
        struct.sub_menu = new java.util.ArrayList<MenuItem>(_list5.size);
        @com.jetbrains.cef.remote.thrift.annotation.Nullable MenuItem _elem6;
        for (int _i7 = 0; _i7 < _list5.size; ++_i7)
        {
          _elem6 = new MenuItem();
          _elem6.read(iprot);
          struct.sub_menu.add(_elem6);
        }
      }
      struct.setSub_menuIsSet(true);
    }
  }

  private static <S extends com.jetbrains.cef.remote.thrift.scheme.IScheme> S scheme(com.jetbrains.cef.remote.thrift.protocol.TProtocol proto) {
    return (com.jetbrains.cef.remote.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
  }
}

