/**
 * Autogenerated by Thrift Compiler (0.13.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.eclipse.hawk.service.api;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.13.0)", date = "2021-04-18")
public class Value extends org.apache.thrift.TUnion<Value, Value._Fields> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Value");
  private static final org.apache.thrift.protocol.TField V_BOOLEAN_FIELD_DESC = new org.apache.thrift.protocol.TField("vBoolean", org.apache.thrift.protocol.TType.BOOL, (short)1);
  private static final org.apache.thrift.protocol.TField V_BYTE_FIELD_DESC = new org.apache.thrift.protocol.TField("vByte", org.apache.thrift.protocol.TType.BYTE, (short)2);
  private static final org.apache.thrift.protocol.TField V_SHORT_FIELD_DESC = new org.apache.thrift.protocol.TField("vShort", org.apache.thrift.protocol.TType.I16, (short)3);
  private static final org.apache.thrift.protocol.TField V_INTEGER_FIELD_DESC = new org.apache.thrift.protocol.TField("vInteger", org.apache.thrift.protocol.TType.I32, (short)4);
  private static final org.apache.thrift.protocol.TField V_LONG_FIELD_DESC = new org.apache.thrift.protocol.TField("vLong", org.apache.thrift.protocol.TType.I64, (short)5);
  private static final org.apache.thrift.protocol.TField V_DOUBLE_FIELD_DESC = new org.apache.thrift.protocol.TField("vDouble", org.apache.thrift.protocol.TType.DOUBLE, (short)6);
  private static final org.apache.thrift.protocol.TField V_STRING_FIELD_DESC = new org.apache.thrift.protocol.TField("vString", org.apache.thrift.protocol.TType.STRING, (short)7);

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    V_BOOLEAN((short)1, "vBoolean"),
    V_BYTE((short)2, "vByte"),
    V_SHORT((short)3, "vShort"),
    V_INTEGER((short)4, "vInteger"),
    V_LONG((short)5, "vLong"),
    V_DOUBLE((short)6, "vDouble"),
    V_STRING((short)7, "vString");

    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.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // V_BOOLEAN
          return V_BOOLEAN;
        case 2: // V_BYTE
          return V_BYTE;
        case 3: // V_SHORT
          return V_SHORT;
        case 4: // V_INTEGER
          return V_INTEGER;
        case 5: // V_LONG
          return V_LONG;
        case 6: // V_DOUBLE
          return V_DOUBLE;
        case 7: // V_STRING
          return V_STRING;
        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.
     */
    @org.apache.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;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

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

  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.V_BOOLEAN, new org.apache.thrift.meta_data.FieldMetaData("vBoolean", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
    tmpMap.put(_Fields.V_BYTE, new org.apache.thrift.meta_data.FieldMetaData("vByte", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BYTE)));
    tmpMap.put(_Fields.V_SHORT, new org.apache.thrift.meta_data.FieldMetaData("vShort", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16)));
    tmpMap.put(_Fields.V_INTEGER, new org.apache.thrift.meta_data.FieldMetaData("vInteger", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.V_LONG, new org.apache.thrift.meta_data.FieldMetaData("vLong", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.V_DOUBLE, new org.apache.thrift.meta_data.FieldMetaData("vDouble", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
    tmpMap.put(_Fields.V_STRING, new org.apache.thrift.meta_data.FieldMetaData("vString", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Value.class, metaDataMap);
  }

  public Value() {
    super();
  }

  public Value(_Fields setField, java.lang.Object value) {
    super(setField, value);
  }

  public Value(Value other) {
    super(other);
  }
  public Value deepCopy() {
    return new Value(this);
  }

  public static Value vBoolean(boolean value) {
    Value x = new Value();
    x.setVBoolean(value);
    return x;
  }

  public static Value vByte(byte value) {
    Value x = new Value();
    x.setVByte(value);
    return x;
  }

  public static Value vShort(short value) {
    Value x = new Value();
    x.setVShort(value);
    return x;
  }

  public static Value vInteger(int value) {
    Value x = new Value();
    x.setVInteger(value);
    return x;
  }

  public static Value vLong(long value) {
    Value x = new Value();
    x.setVLong(value);
    return x;
  }

  public static Value vDouble(double value) {
    Value x = new Value();
    x.setVDouble(value);
    return x;
  }

  public static Value vString(java.lang.String value) {
    Value x = new Value();
    x.setVString(value);
    return x;
  }


  @Override
  protected void checkType(_Fields setField, java.lang.Object value) throws java.lang.ClassCastException {
    switch (setField) {
      case V_BOOLEAN:
        if (value instanceof java.lang.Boolean) {
          break;
        }
        throw new java.lang.ClassCastException("Was expecting value of type java.lang.Boolean for field 'vBoolean', but got " + value.getClass().getSimpleName());
      case V_BYTE:
        if (value instanceof java.lang.Byte) {
          break;
        }
        throw new java.lang.ClassCastException("Was expecting value of type java.lang.Byte for field 'vByte', but got " + value.getClass().getSimpleName());
      case V_SHORT:
        if (value instanceof java.lang.Short) {
          break;
        }
        throw new java.lang.ClassCastException("Was expecting value of type java.lang.Short for field 'vShort', but got " + value.getClass().getSimpleName());
      case V_INTEGER:
        if (value instanceof java.lang.Integer) {
          break;
        }
        throw new java.lang.ClassCastException("Was expecting value of type java.lang.Integer for field 'vInteger', but got " + value.getClass().getSimpleName());
      case V_LONG:
        if (value instanceof java.lang.Long) {
          break;
        }
        throw new java.lang.ClassCastException("Was expecting value of type java.lang.Long for field 'vLong', but got " + value.getClass().getSimpleName());
      case V_DOUBLE:
        if (value instanceof java.lang.Double) {
          break;
        }
        throw new java.lang.ClassCastException("Was expecting value of type java.lang.Double for field 'vDouble', but got " + value.getClass().getSimpleName());
      case V_STRING:
        if (value instanceof java.lang.String) {
          break;
        }
        throw new java.lang.ClassCastException("Was expecting value of type java.lang.String for field 'vString', but got " + value.getClass().getSimpleName());
      default:
        throw new java.lang.IllegalArgumentException("Unknown field id " + setField);
    }
  }

  @Override
  protected java.lang.Object standardSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TField field) throws org.apache.thrift.TException {
    _Fields setField = _Fields.findByThriftId(field.id);
    if (setField != null) {
      switch (setField) {
        case V_BOOLEAN:
          if (field.type == V_BOOLEAN_FIELD_DESC.type) {
            java.lang.Boolean vBoolean;
            vBoolean = iprot.readBool();
            return vBoolean;
          } else {
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case V_BYTE:
          if (field.type == V_BYTE_FIELD_DESC.type) {
            java.lang.Byte vByte;
            vByte = iprot.readByte();
            return vByte;
          } else {
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case V_SHORT:
          if (field.type == V_SHORT_FIELD_DESC.type) {
            java.lang.Short vShort;
            vShort = iprot.readI16();
            return vShort;
          } else {
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case V_INTEGER:
          if (field.type == V_INTEGER_FIELD_DESC.type) {
            java.lang.Integer vInteger;
            vInteger = iprot.readI32();
            return vInteger;
          } else {
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case V_LONG:
          if (field.type == V_LONG_FIELD_DESC.type) {
            java.lang.Long vLong;
            vLong = iprot.readI64();
            return vLong;
          } else {
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case V_DOUBLE:
          if (field.type == V_DOUBLE_FIELD_DESC.type) {
            java.lang.Double vDouble;
            vDouble = iprot.readDouble();
            return vDouble;
          } else {
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case V_STRING:
          if (field.type == V_STRING_FIELD_DESC.type) {
            java.lang.String vString;
            vString = iprot.readString();
            return vString;
          } else {
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        default:
          throw new java.lang.IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
      }
    } else {
      org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
      return null;
    }
  }

  @Override
  protected void standardSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    switch (setField_) {
      case V_BOOLEAN:
        java.lang.Boolean vBoolean = (java.lang.Boolean)value_;
        oprot.writeBool(vBoolean);
        return;
      case V_BYTE:
        java.lang.Byte vByte = (java.lang.Byte)value_;
        oprot.writeByte(vByte);
        return;
      case V_SHORT:
        java.lang.Short vShort = (java.lang.Short)value_;
        oprot.writeI16(vShort);
        return;
      case V_INTEGER:
        java.lang.Integer vInteger = (java.lang.Integer)value_;
        oprot.writeI32(vInteger);
        return;
      case V_LONG:
        java.lang.Long vLong = (java.lang.Long)value_;
        oprot.writeI64(vLong);
        return;
      case V_DOUBLE:
        java.lang.Double vDouble = (java.lang.Double)value_;
        oprot.writeDouble(vDouble);
        return;
      case V_STRING:
        java.lang.String vString = (java.lang.String)value_;
        oprot.writeString(vString);
        return;
      default:
        throw new java.lang.IllegalStateException("Cannot write union with unknown field " + setField_);
    }
  }

  @Override
  protected java.lang.Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID) throws org.apache.thrift.TException {
    _Fields setField = _Fields.findByThriftId(fieldID);
    if (setField != null) {
      switch (setField) {
        case V_BOOLEAN:
          java.lang.Boolean vBoolean;
          vBoolean = iprot.readBool();
          return vBoolean;
        case V_BYTE:
          java.lang.Byte vByte;
          vByte = iprot.readByte();
          return vByte;
        case V_SHORT:
          java.lang.Short vShort;
          vShort = iprot.readI16();
          return vShort;
        case V_INTEGER:
          java.lang.Integer vInteger;
          vInteger = iprot.readI32();
          return vInteger;
        case V_LONG:
          java.lang.Long vLong;
          vLong = iprot.readI64();
          return vLong;
        case V_DOUBLE:
          java.lang.Double vDouble;
          vDouble = iprot.readDouble();
          return vDouble;
        case V_STRING:
          java.lang.String vString;
          vString = iprot.readString();
          return vString;
        default:
          throw new java.lang.IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
      }
    } else {
      throw new org.apache.thrift.protocol.TProtocolException("Couldn't find a field with field id " + fieldID);
    }
  }

  @Override
  protected void tupleSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    switch (setField_) {
      case V_BOOLEAN:
        java.lang.Boolean vBoolean = (java.lang.Boolean)value_;
        oprot.writeBool(vBoolean);
        return;
      case V_BYTE:
        java.lang.Byte vByte = (java.lang.Byte)value_;
        oprot.writeByte(vByte);
        return;
      case V_SHORT:
        java.lang.Short vShort = (java.lang.Short)value_;
        oprot.writeI16(vShort);
        return;
      case V_INTEGER:
        java.lang.Integer vInteger = (java.lang.Integer)value_;
        oprot.writeI32(vInteger);
        return;
      case V_LONG:
        java.lang.Long vLong = (java.lang.Long)value_;
        oprot.writeI64(vLong);
        return;
      case V_DOUBLE:
        java.lang.Double vDouble = (java.lang.Double)value_;
        oprot.writeDouble(vDouble);
        return;
      case V_STRING:
        java.lang.String vString = (java.lang.String)value_;
        oprot.writeString(vString);
        return;
      default:
        throw new java.lang.IllegalStateException("Cannot write union with unknown field " + setField_);
    }
  }

  @Override
  protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) {
    switch (setField) {
      case V_BOOLEAN:
        return V_BOOLEAN_FIELD_DESC;
      case V_BYTE:
        return V_BYTE_FIELD_DESC;
      case V_SHORT:
        return V_SHORT_FIELD_DESC;
      case V_INTEGER:
        return V_INTEGER_FIELD_DESC;
      case V_LONG:
        return V_LONG_FIELD_DESC;
      case V_DOUBLE:
        return V_DOUBLE_FIELD_DESC;
      case V_STRING:
        return V_STRING_FIELD_DESC;
      default:
        throw new java.lang.IllegalArgumentException("Unknown field id " + setField);
    }
  }

  @Override
  protected org.apache.thrift.protocol.TStruct getStructDesc() {
    return STRUCT_DESC;
  }

  @Override
  protected _Fields enumForId(short id) {
    return _Fields.findByThriftIdOrThrow(id);
  }

  @org.apache.thrift.annotation.Nullable
  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }


  public boolean getVBoolean() {
    if (getSetField() == _Fields.V_BOOLEAN) {
      return (java.lang.Boolean)getFieldValue();
    } else {
      throw new java.lang.RuntimeException("Cannot get field 'vBoolean' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  public void setVBoolean(boolean value) {
    setField_ = _Fields.V_BOOLEAN;
    value_ = value;
  }

  public byte getVByte() {
    if (getSetField() == _Fields.V_BYTE) {
      return (java.lang.Byte)getFieldValue();
    } else {
      throw new java.lang.RuntimeException("Cannot get field 'vByte' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  public void setVByte(byte value) {
    setField_ = _Fields.V_BYTE;
    value_ = value;
  }

  public short getVShort() {
    if (getSetField() == _Fields.V_SHORT) {
      return (java.lang.Short)getFieldValue();
    } else {
      throw new java.lang.RuntimeException("Cannot get field 'vShort' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  public void setVShort(short value) {
    setField_ = _Fields.V_SHORT;
    value_ = value;
  }

  public int getVInteger() {
    if (getSetField() == _Fields.V_INTEGER) {
      return (java.lang.Integer)getFieldValue();
    } else {
      throw new java.lang.RuntimeException("Cannot get field 'vInteger' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  public void setVInteger(int value) {
    setField_ = _Fields.V_INTEGER;
    value_ = value;
  }

  public long getVLong() {
    if (getSetField() == _Fields.V_LONG) {
      return (java.lang.Long)getFieldValue();
    } else {
      throw new java.lang.RuntimeException("Cannot get field 'vLong' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  public void setVLong(long value) {
    setField_ = _Fields.V_LONG;
    value_ = value;
  }

  public double getVDouble() {
    if (getSetField() == _Fields.V_DOUBLE) {
      return (java.lang.Double)getFieldValue();
    } else {
      throw new java.lang.RuntimeException("Cannot get field 'vDouble' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  public void setVDouble(double value) {
    setField_ = _Fields.V_DOUBLE;
    value_ = value;
  }

  public java.lang.String getVString() {
    if (getSetField() == _Fields.V_STRING) {
      return (java.lang.String)getFieldValue();
    } else {
      throw new java.lang.RuntimeException("Cannot get field 'vString' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  public void setVString(java.lang.String value) {
    if (value == null) throw new java.lang.NullPointerException();
    setField_ = _Fields.V_STRING;
    value_ = value;
  }

  public boolean isSetVBoolean() {
    return setField_ == _Fields.V_BOOLEAN;
  }


  public boolean isSetVByte() {
    return setField_ == _Fields.V_BYTE;
  }


  public boolean isSetVShort() {
    return setField_ == _Fields.V_SHORT;
  }


  public boolean isSetVInteger() {
    return setField_ == _Fields.V_INTEGER;
  }


  public boolean isSetVLong() {
    return setField_ == _Fields.V_LONG;
  }


  public boolean isSetVDouble() {
    return setField_ == _Fields.V_DOUBLE;
  }


  public boolean isSetVString() {
    return setField_ == _Fields.V_STRING;
  }


  public boolean equals(java.lang.Object other) {
    if (other instanceof Value) {
      return equals((Value)other);
    } else {
      return false;
    }
  }

  public boolean equals(Value other) {
    return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue());
  }

  @Override
  public int compareTo(Value other) {
    int lastComparison = org.apache.thrift.TBaseHelper.compareTo(getSetField(), other.getSetField());
    if (lastComparison == 0) {
      return org.apache.thrift.TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());
    }
    return lastComparison;
  }


  @Override
  public int hashCode() {
    java.util.List<java.lang.Object> list = new java.util.ArrayList<java.lang.Object>();
    list.add(this.getClass().getName());
    org.apache.thrift.TFieldIdEnum setField = getSetField();
    if (setField != null) {
      list.add(setField.getThriftFieldId());
      java.lang.Object value = getFieldValue();
      if (value instanceof org.apache.thrift.TEnum) {
        list.add(((org.apache.thrift.TEnum)getFieldValue()).getValue());
      } else {
        list.add(value);
      }
    }
    return list.hashCode();
  }
  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }


  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
    try {
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }


}
