com.evernote.edam.error.EDAMSystemException Maven / Gradle / Ivy
/**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package com.evernote.edam.error;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.HashSet;
import com.evernote.thrift.*;
import com.evernote.thrift.protocol.*;
/**
* This exception is thrown by EDAM procedures when a call fails as a result of
* a problem in the service that could not be changed through caller action.
*
* errorCode: The numeric code indicating the type of error that occurred.
* must be one of the values of EDAMErrorCode.
*
* message: This may contain additional information about the error
*
* rateLimitDuration: Indicates the minimum number of seconds that an application should
* expect subsequent API calls for this user to fail. The application should not retry
* API requests for the user until at least this many seconds have passed. Present only
* when errorCode is RATE_LIMIT_REACHED,
*/
public class EDAMSystemException extends Exception implements TBase, java.io.Serializable, Cloneable {
private static final TStruct STRUCT_DESC = new TStruct("EDAMSystemException");
private static final TField ERROR_CODE_FIELD_DESC = new TField("errorCode", TType.I32, (short)1);
private static final TField MESSAGE_FIELD_DESC = new TField("message", TType.STRING, (short)2);
private static final TField RATE_LIMIT_DURATION_FIELD_DESC = new TField("rateLimitDuration", TType.I32, (short)3);
private EDAMErrorCode errorCode;
private String message;
private int rateLimitDuration;
// isset id assignments
private static final int __RATELIMITDURATION_ISSET_ID = 0;
private boolean[] __isset_vector = new boolean[1];
public EDAMSystemException() {
}
public EDAMSystemException(
EDAMErrorCode errorCode)
{
this();
this.errorCode = errorCode;
}
/**
* Performs a deep copy on other.
*/
public EDAMSystemException(EDAMSystemException other) {
System.arraycopy(other.__isset_vector, 0, __isset_vector, 0, other.__isset_vector.length);
if (other.isSetErrorCode()) {
this.errorCode = other.errorCode;
}
if (other.isSetMessage()) {
this.message = other.message;
}
this.rateLimitDuration = other.rateLimitDuration;
}
public EDAMSystemException deepCopy() {
return new EDAMSystemException(this);
}
public void clear() {
this.errorCode = null;
this.message = null;
setRateLimitDurationIsSet(false);
this.rateLimitDuration = 0;
}
/**
*
* @see EDAMErrorCode
*/
public EDAMErrorCode getErrorCode() {
return this.errorCode;
}
/**
*
* @see EDAMErrorCode
*/
public void setErrorCode(EDAMErrorCode errorCode) {
this.errorCode = errorCode;
}
public void unsetErrorCode() {
this.errorCode = null;
}
/** Returns true if field errorCode is set (has been asigned a value) and false otherwise */
public boolean isSetErrorCode() {
return this.errorCode != null;
}
public void setErrorCodeIsSet(boolean value) {
if (!value) {
this.errorCode = null;
}
}
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public void unsetMessage() {
this.message = null;
}
/** Returns true if field message is set (has been asigned a value) and false otherwise */
public boolean isSetMessage() {
return this.message != null;
}
public void setMessageIsSet(boolean value) {
if (!value) {
this.message = null;
}
}
public int getRateLimitDuration() {
return this.rateLimitDuration;
}
public void setRateLimitDuration(int rateLimitDuration) {
this.rateLimitDuration = rateLimitDuration;
setRateLimitDurationIsSet(true);
}
public void unsetRateLimitDuration() {
__isset_vector[__RATELIMITDURATION_ISSET_ID] = false;
}
/** Returns true if field rateLimitDuration is set (has been asigned a value) and false otherwise */
public boolean isSetRateLimitDuration() {
return __isset_vector[__RATELIMITDURATION_ISSET_ID];
}
public void setRateLimitDurationIsSet(boolean value) {
__isset_vector[__RATELIMITDURATION_ISSET_ID] = value;
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof EDAMSystemException)
return this.equals((EDAMSystemException)that);
return false;
}
public boolean equals(EDAMSystemException that) {
if (that == null)
return false;
boolean this_present_errorCode = true && this.isSetErrorCode();
boolean that_present_errorCode = true && that.isSetErrorCode();
if (this_present_errorCode || that_present_errorCode) {
if (!(this_present_errorCode && that_present_errorCode))
return false;
if (!this.errorCode.equals(that.errorCode))
return false;
}
boolean this_present_message = true && this.isSetMessage();
boolean that_present_message = true && that.isSetMessage();
if (this_present_message || that_present_message) {
if (!(this_present_message && that_present_message))
return false;
if (!this.message.equals(that.message))
return false;
}
boolean this_present_rateLimitDuration = true && this.isSetRateLimitDuration();
boolean that_present_rateLimitDuration = true && that.isSetRateLimitDuration();
if (this_present_rateLimitDuration || that_present_rateLimitDuration) {
if (!(this_present_rateLimitDuration && that_present_rateLimitDuration))
return false;
if (this.rateLimitDuration != that.rateLimitDuration)
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(EDAMSystemException other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
EDAMSystemException typedOther = (EDAMSystemException)other;
lastComparison = Boolean.valueOf(isSetErrorCode()).compareTo(typedOther.isSetErrorCode());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetErrorCode()) { lastComparison = TBaseHelper.compareTo(this.errorCode, typedOther.errorCode);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetMessage()).compareTo(typedOther.isSetMessage());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMessage()) { lastComparison = TBaseHelper.compareTo(this.message, typedOther.message);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetRateLimitDuration()).compareTo(typedOther.isSetRateLimitDuration());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetRateLimitDuration()) { lastComparison = TBaseHelper.compareTo(this.rateLimitDuration, typedOther.rateLimitDuration);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public void read(TProtocol iprot) throws TException {
TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == TType.STOP) {
break;
}
switch (field.id) {
case 1: // ERROR_CODE
if (field.type == TType.I32) {
this.errorCode = EDAMErrorCode.findByValue(iprot.readI32());
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // MESSAGE
if (field.type == TType.STRING) {
this.message = iprot.readString();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // RATE_LIMIT_DURATION
if (field.type == TType.I32) {
this.rateLimitDuration = iprot.readI32();
setRateLimitDurationIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
validate();
}
public void write(TProtocol oprot) throws TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.errorCode != null) {
oprot.writeFieldBegin(ERROR_CODE_FIELD_DESC);
oprot.writeI32(this.errorCode.getValue());
oprot.writeFieldEnd();
}
if (this.message != null) {
if (isSetMessage()) {
oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
oprot.writeString(this.message);
oprot.writeFieldEnd();
}
}
if (isSetRateLimitDuration()) {
oprot.writeFieldBegin(RATE_LIMIT_DURATION_FIELD_DESC);
oprot.writeI32(this.rateLimitDuration);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("EDAMSystemException(");
boolean first = true;
sb.append("errorCode:");
if (this.errorCode == null) {
sb.append("null");
} else {
sb.append(this.errorCode);
}
first = false;
if (isSetMessage()) {
if (!first) sb.append(", ");
sb.append("message:");
if (this.message == null) {
sb.append("null");
} else {
sb.append(this.message);
}
first = false;
}
if (isSetRateLimitDuration()) {
if (!first) sb.append(", ");
sb.append("rateLimitDuration:");
sb.append(this.rateLimitDuration);
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
if (!isSetErrorCode()) {
throw new TProtocolException("Required field 'errorCode' is unset! Struct:" + toString());
}
}
}