/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package com.ociweb.jnb.thrift.gen;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.apache.thrift.TBase;
import org.apache.thrift.TException;
import org.apache.thrift.TFieldRequirementType;
import org.apache.thrift.meta_data.FieldMetaData;
import org.apache.thrift.meta_data.FieldValueMetaData;
import org.apache.thrift.protocol.TField;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.protocol.TProtocolUtil;
import org.apache.thrift.protocol.TStruct;
import org.apache.thrift.protocol.TType;

@SuppressWarnings("serial")
public class UnacceptableCourseException extends Exception implements TBase, java.io.Serializable, Cloneable {
    private static final TStruct STRUCT_DESC = new TStruct("UnacceptableCourseException");
    private static final TField MESSAGE_FIELD_DESC = new TField("message", TType.STRING, (short) 1);

    public String message;
    public static final int MESSAGE = 1;

    @SuppressWarnings("unused")
    private final Isset __isset = new Isset();

    private static final class Isset implements java.io.Serializable {
    }

    public static final Map<Integer, FieldMetaData> metaDataMap = Collections
            .unmodifiableMap(new HashMap<Integer, FieldMetaData>() {
                {
                    put(MESSAGE, new FieldMetaData("message", TFieldRequirementType.DEFAULT, new FieldValueMetaData(
                            TType.STRING)));
                }
            });

    static {
        FieldMetaData.addStructMetaDataMap(UnacceptableCourseException.class, metaDataMap);
    }

    public UnacceptableCourseException() {
    }

    public UnacceptableCourseException(String message) {
        this();
        this.message = message;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public UnacceptableCourseException(UnacceptableCourseException other) {
        if (other.isSetMessage()) {
            this.message = other.message;
        }
    }

    @Override
    public UnacceptableCourseException clone() {
        return new UnacceptableCourseException(this);
    }

    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 void setFieldValue(int fieldID, Object value) {
        switch (fieldID) {
        case MESSAGE:
            if (value == null) {
                unsetMessage();
            } else {
                setMessage((String) value);
            }
            break;

        default:
            throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
        }
    }

    public Object getFieldValue(int fieldID) {
        switch (fieldID) {
        case MESSAGE:
            return getMessage();

        default:
            throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
        }
    }

    // Returns true if field corresponding to fieldID is set (has been asigned a
    // value) and false otherwise
    public boolean isSet(int fieldID) {
        switch (fieldID) {
        case MESSAGE:
            return isSetMessage();
        default:
            throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
        }
    }

    @Override
    public boolean equals(Object that) {
        if (that == null)
            return false;
        if (that instanceof UnacceptableCourseException)
            return this.equals((UnacceptableCourseException) that);
        return false;
    }

    public boolean equals(UnacceptableCourseException that) {
        if (that == null)
            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;
        }

        return true;
    }

    @Override
    public int hashCode() {
        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 MESSAGE:
                if (field.type == TType.STRING) {
                    this.message = iprot.readString();
                } else {
                    TProtocolUtil.skip(iprot, field.type);
                }
                break;
            default:
                TProtocolUtil.skip(iprot, field.type);
                break;
            }
            iprot.readFieldEnd();
        }
        iprot.readStructEnd();

        // check for required fields of primitive type, which can't be checked
        // in the validate method
        validate();
    }

    public void write(TProtocol oprot) throws TException {
        validate();

        oprot.writeStructBegin(STRUCT_DESC);
        if (this.message != null) {
            oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
            oprot.writeString(this.message);
            oprot.writeFieldEnd();
        }
        oprot.writeFieldStop();
        oprot.writeStructEnd();
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder("UnacceptableCourseException(");

        sb.append("message:");
        if (this.message == null) {
            sb.append("null");
        } else {
            sb.append(this.message);
        }
        sb.append(")");
        return sb.toString();
    }

    public void validate() throws TException {
        // check for required fields
        // check that fields of type enum have valid values
    }

}
