/**
 * 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.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.thrift.TApplicationException;
import org.apache.thrift.TBase;
import org.apache.thrift.TException;
import org.apache.thrift.TFieldRequirementType;
import org.apache.thrift.TProcessor;
import org.apache.thrift.meta_data.FieldMetaData;
import org.apache.thrift.meta_data.FieldValueMetaData;
import org.apache.thrift.meta_data.ListMetaData;
import org.apache.thrift.meta_data.StructMetaData;
import org.apache.thrift.protocol.TField;
import org.apache.thrift.protocol.TList;
import org.apache.thrift.protocol.TMessage;
import org.apache.thrift.protocol.TMessageType;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.protocol.TProtocolUtil;
import org.apache.thrift.protocol.TStruct;
import org.apache.thrift.protocol.TType;

public class CourseService {

    public interface Iface {

        public List<String> getCourseInventory() throws TException;

        public Course getCourse(String courseNumber) throws CourseNotFoundException, TException;

        public void addCourse(Course course) throws UnacceptableCourseException, TException;

        public void deleteCourse(String courseNumber) throws CourseNotFoundException, TException;

    }

    public static class Client implements Iface {
        public Client(TProtocol prot) {
            this(prot, prot);
        }

        public Client(TProtocol iprot, TProtocol oprot) {
            iprot_ = iprot;
            oprot_ = oprot;
        }

        protected TProtocol iprot_;
        protected TProtocol oprot_;

        protected int seqid_;

        public TProtocol getInputProtocol() {
            return this.iprot_;
        }

        public TProtocol getOutputProtocol() {
            return this.oprot_;
        }

        public List<String> getCourseInventory() throws TException {
            send_getCourseInventory();
            return recv_getCourseInventory();
        }

        public void send_getCourseInventory() throws TException {
            oprot_.writeMessageBegin(new TMessage("getCourseInventory", TMessageType.CALL, seqid_));
            getCourseInventory_args args = new getCourseInventory_args();
            args.write(oprot_);
            oprot_.writeMessageEnd();
            oprot_.getTransport().flush();
        }

        public List<String> recv_getCourseInventory() throws TException {
            TMessage msg = iprot_.readMessageBegin();
            if (msg.type == TMessageType.EXCEPTION) {
                TApplicationException x = TApplicationException.read(iprot_);
                iprot_.readMessageEnd();
                throw x;
            }
            getCourseInventory_result result = new getCourseInventory_result();
            result.read(iprot_);
            iprot_.readMessageEnd();
            if (result.isSetSuccess()) {
                return result.success;
            }
            throw new TApplicationException(TApplicationException.MISSING_RESULT, "getCourseInventory failed: unknown result");
        }

        public Course getCourse(String courseNumber) throws CourseNotFoundException, TException {
            send_getCourse(courseNumber);
            return recv_getCourse();
        }

        public void send_getCourse(String courseNumber) throws TException {
            oprot_.writeMessageBegin(new TMessage("getCourse", TMessageType.CALL, seqid_));
            getCourse_args args = new getCourse_args();
            args.courseNumber = courseNumber;
            args.write(oprot_);
            oprot_.writeMessageEnd();
            oprot_.getTransport().flush();
        }

        public Course recv_getCourse() throws CourseNotFoundException, TException {
            TMessage msg = iprot_.readMessageBegin();
            if (msg.type == TMessageType.EXCEPTION) {
                TApplicationException x = TApplicationException.read(iprot_);
                iprot_.readMessageEnd();
                throw x;
            }
            getCourse_result result = new getCourse_result();
            result.read(iprot_);
            iprot_.readMessageEnd();
            if (result.isSetSuccess()) {
                return result.success;
            }
            if (result.cnf != null) {
                throw result.cnf;
            }
            throw new TApplicationException(TApplicationException.MISSING_RESULT, "getCourse failed: unknown result");
        }

        public void addCourse(Course course) throws UnacceptableCourseException, TException {
            send_addCourse(course);
            recv_addCourse();
        }

        public void send_addCourse(Course course) throws TException {
            oprot_.writeMessageBegin(new TMessage("addCourse", TMessageType.CALL, seqid_));
            addCourse_args args = new addCourse_args();
            args.course = course;
            args.write(oprot_);
            oprot_.writeMessageEnd();
            oprot_.getTransport().flush();
        }

        public void recv_addCourse() throws UnacceptableCourseException, TException {
            TMessage msg = iprot_.readMessageBegin();
            if (msg.type == TMessageType.EXCEPTION) {
                TApplicationException x = TApplicationException.read(iprot_);
                iprot_.readMessageEnd();
                throw x;
            }
            addCourse_result result = new addCourse_result();
            result.read(iprot_);
            iprot_.readMessageEnd();
            if (result.uc != null) {
                throw result.uc;
            }
            return;
        }

        public void deleteCourse(String courseNumber) throws CourseNotFoundException, TException {
            send_deleteCourse(courseNumber);
            recv_deleteCourse();
        }

        public void send_deleteCourse(String courseNumber) throws TException {
            oprot_.writeMessageBegin(new TMessage("deleteCourse", TMessageType.CALL, seqid_));
            deleteCourse_args args = new deleteCourse_args();
            args.courseNumber = courseNumber;
            args.write(oprot_);
            oprot_.writeMessageEnd();
            oprot_.getTransport().flush();
        }

        public void recv_deleteCourse() throws CourseNotFoundException, TException {
            TMessage msg = iprot_.readMessageBegin();
            if (msg.type == TMessageType.EXCEPTION) {
                TApplicationException x = TApplicationException.read(iprot_);
                iprot_.readMessageEnd();
                throw x;
            }
            deleteCourse_result result = new deleteCourse_result();
            result.read(iprot_);
            iprot_.readMessageEnd();
            if (result.cnf != null) {
                throw result.cnf;
            }
            return;
        }

    }

    public static class Processor implements TProcessor {
        public Processor(Iface iface) {
            iface_ = iface;
            processMap_.put("getCourseInventory", new getCourseInventory());
            processMap_.put("getCourse", new getCourse());
            processMap_.put("addCourse", new addCourse());
            processMap_.put("deleteCourse", new deleteCourse());
        }

        protected static interface ProcessFunction {
            public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;
        }

        private Iface iface_;
        protected final HashMap<String, ProcessFunction> processMap_ = new HashMap<String, ProcessFunction>();

        public boolean process(TProtocol iprot, TProtocol oprot) throws TException {
            TMessage msg = iprot.readMessageBegin();
            ProcessFunction fn = processMap_.get(msg.name);
            if (fn == null) {
                TProtocolUtil.skip(iprot, TType.STRUCT);
                iprot.readMessageEnd();
                TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD,
                        "Invalid method name: '" + msg.name + "'");
                oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
                x.write(oprot);
                oprot.writeMessageEnd();
                oprot.getTransport().flush();
                return true;
            }
            fn.process(msg.seqid, iprot, oprot);
            return true;
        }

        private class getCourseInventory implements ProcessFunction {
            public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException {
                getCourseInventory_args args = new getCourseInventory_args();
                args.read(iprot);
                iprot.readMessageEnd();
                getCourseInventory_result result = new getCourseInventory_result();
                result.success = iface_.getCourseInventory();
                oprot.writeMessageBegin(new TMessage("getCourseInventory", TMessageType.REPLY, seqid));
                result.write(oprot);
                oprot.writeMessageEnd();
                oprot.getTransport().flush();
            }

        }

        private class getCourse implements ProcessFunction {
            public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException {
                getCourse_args args = new getCourse_args();
                args.read(iprot);
                iprot.readMessageEnd();
                getCourse_result result = new getCourse_result();
                try {
                    result.success = iface_.getCourse(args.courseNumber);
                } catch (CourseNotFoundException cnf) {
                    result.cnf = cnf;
                }
                oprot.writeMessageBegin(new TMessage("getCourse", TMessageType.REPLY, seqid));
                result.write(oprot);
                oprot.writeMessageEnd();
                oprot.getTransport().flush();
            }

        }

        private class addCourse implements ProcessFunction {
            public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException {
                addCourse_args args = new addCourse_args();
                args.read(iprot);
                iprot.readMessageEnd();
                addCourse_result result = new addCourse_result();
                try {
                    iface_.addCourse(args.course);
                } catch (UnacceptableCourseException uc) {
                    result.uc = uc;
                }
                oprot.writeMessageBegin(new TMessage("addCourse", TMessageType.REPLY, seqid));
                result.write(oprot);
                oprot.writeMessageEnd();
                oprot.getTransport().flush();
            }

        }

        private class deleteCourse implements ProcessFunction {
            public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException {
                deleteCourse_args args = new deleteCourse_args();
                args.read(iprot);
                iprot.readMessageEnd();
                deleteCourse_result result = new deleteCourse_result();
                try {
                    iface_.deleteCourse(args.courseNumber);
                } catch (CourseNotFoundException cnf) {
                    result.cnf = cnf;
                }
                oprot.writeMessageBegin(new TMessage("deleteCourse", TMessageType.REPLY, seqid));
                result.write(oprot);
                oprot.writeMessageEnd();
                oprot.getTransport().flush();
            }

        }

    }

    public static class getCourseInventory_args implements TBase, java.io.Serializable, Cloneable {
        private static final TStruct STRUCT_DESC = new TStruct("getCourseInventory_args");

        public static final Map<Integer, FieldMetaData> metaDataMap = Collections
                .unmodifiableMap(new HashMap<Integer, FieldMetaData>() {
                    {
                    }
                });

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

        public getCourseInventory_args() {
        }

        /**
         * Performs a deep copy on <i>other</i>.
         */
        public getCourseInventory_args(getCourseInventory_args other) {
        }

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

        public void setFieldValue(int fieldID, Object value) {
            switch (fieldID) {
            default:
                throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
            }
        }

        public Object getFieldValue(int fieldID) {
            switch (fieldID) {
            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) {
            default:
                throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
            }
        }

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

        public boolean equals(getCourseInventory_args that) {
            if (that == null)
                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) {
                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);
            oprot.writeFieldStop();
            oprot.writeStructEnd();
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder("getCourseInventory_args(");
            boolean first = true;

            sb.append(")");
            return sb.toString();
        }

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

    }

    public static class getCourseInventory_result implements TBase, java.io.Serializable, Cloneable {
        private static final TStruct STRUCT_DESC = new TStruct("getCourseInventory_result");
        private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.LIST, (short) 0);

        public List<String> success;
        public static final int SUCCESS = 0;

        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(SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, new ListMetaData(
                                TType.LIST, new FieldValueMetaData(TType.STRING))));
                    }
                });

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

        public getCourseInventory_result() {
        }

        public getCourseInventory_result(List<String> success) {
            this();
            this.success = success;
        }

        /**
         * Performs a deep copy on <i>other</i>.
         */
        public getCourseInventory_result(getCourseInventory_result other) {
            if (other.isSetSuccess()) {
                List<String> __this__success = new ArrayList<String>();
                for (String other_element : other.success) {
                    __this__success.add(other_element);
                }
                this.success = __this__success;
            }
        }

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

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

        public java.util.Iterator<String> getSuccessIterator() {
            return (this.success == null) ? null : this.success.iterator();
        }

        public void addToSuccess(String elem) {
            if (this.success == null) {
                this.success = new ArrayList<String>();
            }
            this.success.add(elem);
        }

        public List<String> getSuccess() {
            return this.success;
        }

        public void setSuccess(List<String> success) {
            this.success = success;
        }

        public void unsetSuccess() {
            this.success = null;
        }

        // Returns true if field success is set (has been asigned a value) and
        // false otherwise
        public boolean isSetSuccess() {
            return this.success != null;
        }

        public void setSuccessIsSet(boolean value) {
            if (!value) {
                this.success = null;
            }
        }

        public void setFieldValue(int fieldID, Object value) {
            switch (fieldID) {
            case SUCCESS:
                if (value == null) {
                    unsetSuccess();
                } else {
                    setSuccess((List<String>) value);
                }
                break;

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

        public Object getFieldValue(int fieldID) {
            switch (fieldID) {
            case SUCCESS:
                return getSuccess();

            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 SUCCESS:
                return isSetSuccess();
            default:
                throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
            }
        }

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

        public boolean equals(getCourseInventory_result that) {
            if (that == null)
                return false;

            boolean this_present_success = true && this.isSetSuccess();
            boolean that_present_success = true && that.isSetSuccess();
            if (this_present_success || that_present_success) {
                if (!(this_present_success && that_present_success))
                    return false;
                if (!this.success.equals(that.success))
                    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 SUCCESS:
                    if (field.type == TType.LIST) {
                        {
                            TList _list8 = iprot.readListBegin();
                            this.success = new ArrayList<String>(_list8.size);
                            for (int _i9 = 0; _i9 < _list8.size; ++_i9) {
                                String _elem10;
                                _elem10 = iprot.readString();
                                this.success.add(_elem10);
                            }
                            iprot.readListEnd();
                        }
                    } 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 {
            oprot.writeStructBegin(STRUCT_DESC);

            if (this.isSetSuccess()) {
                oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
                {
                    oprot.writeListBegin(new TList(TType.STRING, this.success.size()));
                    for (String _iter11 : this.success) {
                        oprot.writeString(_iter11);
                    }
                    oprot.writeListEnd();
                }
                oprot.writeFieldEnd();
            }
            oprot.writeFieldStop();
            oprot.writeStructEnd();
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder("getCourseInventory_result(");
            boolean first = true;

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

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

    }

    public static class getCourse_args implements TBase, java.io.Serializable, Cloneable {
        private static final TStruct STRUCT_DESC = new TStruct("getCourse_args");
        private static final TField COURSE_NUMBER_FIELD_DESC = new TField("courseNumber", TType.STRING, (short) 1);

        public String courseNumber;
        public static final int COURSENUMBER = 1;

        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(COURSENUMBER, new FieldMetaData("courseNumber", TFieldRequirementType.DEFAULT,
                                new FieldValueMetaData(TType.STRING)));
                    }
                });

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

        public getCourse_args() {
        }

        public getCourse_args(String courseNumber) {
            this();
            this.courseNumber = courseNumber;
        }

        /**
         * Performs a deep copy on <i>other</i>.
         */
        public getCourse_args(getCourse_args other) {
            if (other.isSetCourseNumber()) {
                this.courseNumber = other.courseNumber;
            }
        }

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

        public String getCourseNumber() {
            return this.courseNumber;
        }

        public void setCourseNumber(String courseNumber) {
            this.courseNumber = courseNumber;
        }

        public void unsetCourseNumber() {
            this.courseNumber = null;
        }

        // Returns true if field courseNumber is set (has been asigned a value)
        // and false otherwise
        public boolean isSetCourseNumber() {
            return this.courseNumber != null;
        }

        public void setCourseNumberIsSet(boolean value) {
            if (!value) {
                this.courseNumber = null;
            }
        }

        public void setFieldValue(int fieldID, Object value) {
            switch (fieldID) {
            case COURSENUMBER:
                if (value == null) {
                    unsetCourseNumber();
                } else {
                    setCourseNumber((String) value);
                }
                break;

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

        public Object getFieldValue(int fieldID) {
            switch (fieldID) {
            case COURSENUMBER:
                return getCourseNumber();

            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 COURSENUMBER:
                return isSetCourseNumber();
            default:
                throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
            }
        }

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

        public boolean equals(getCourse_args that) {
            if (that == null)
                return false;

            boolean this_present_courseNumber = true && this.isSetCourseNumber();
            boolean that_present_courseNumber = true && that.isSetCourseNumber();
            if (this_present_courseNumber || that_present_courseNumber) {
                if (!(this_present_courseNumber && that_present_courseNumber))
                    return false;
                if (!this.courseNumber.equals(that.courseNumber))
                    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 COURSENUMBER:
                    if (field.type == TType.STRING) {
                        this.courseNumber = 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.courseNumber != null) {
                oprot.writeFieldBegin(COURSE_NUMBER_FIELD_DESC);
                oprot.writeString(this.courseNumber);
                oprot.writeFieldEnd();
            }
            oprot.writeFieldStop();
            oprot.writeStructEnd();
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder("getCourse_args(");
            boolean first = true;

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

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

    }

    public static class getCourse_result implements TBase, java.io.Serializable, Cloneable {
        private static final TStruct STRUCT_DESC = new TStruct("getCourse_result");
        private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short) 0);
        private static final TField CNF_FIELD_DESC = new TField("cnf", TType.STRUCT, (short) 1);

        public Course success;
        public static final int SUCCESS = 0;
        public CourseNotFoundException cnf;
        public static final int CNF = 1;

        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(SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, new StructMetaData(
                                TType.STRUCT, Course.class)));
                        put(CNF, new FieldMetaData("cnf", TFieldRequirementType.DEFAULT, new FieldValueMetaData(
                                TType.STRUCT)));
                    }
                });

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

        public getCourse_result() {
        }

        public getCourse_result(Course success, CourseNotFoundException cnf) {
            this();
            this.success = success;
            this.cnf = cnf;
        }

        /**
         * Performs a deep copy on <i>other</i>.
         */
        public getCourse_result(getCourse_result other) {
            if (other.isSetSuccess()) {
                this.success = new Course(other.success);
            }
            if (other.isSetCnf()) {
                this.cnf = new CourseNotFoundException(other.cnf);
            }
        }

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

        public Course getSuccess() {
            return this.success;
        }

        public void setSuccess(Course success) {
            this.success = success;
        }

        public void unsetSuccess() {
            this.success = null;
        }

        // Returns true if field success is set (has been asigned a value) and
        // false otherwise
        public boolean isSetSuccess() {
            return this.success != null;
        }

        public void setSuccessIsSet(boolean value) {
            if (!value) {
                this.success = null;
            }
        }

        public CourseNotFoundException getCnf() {
            return this.cnf;
        }

        public void setCnf(CourseNotFoundException cnf) {
            this.cnf = cnf;
        }

        public void unsetCnf() {
            this.cnf = null;
        }

        // Returns true if field cnf is set (has been asigned a value) and false
        // otherwise
        public boolean isSetCnf() {
            return this.cnf != null;
        }

        public void setCnfIsSet(boolean value) {
            if (!value) {
                this.cnf = null;
            }
        }

        public void setFieldValue(int fieldID, Object value) {
            switch (fieldID) {
            case SUCCESS:
                if (value == null) {
                    unsetSuccess();
                } else {
                    setSuccess((Course) value);
                }
                break;

            case CNF:
                if (value == null) {
                    unsetCnf();
                } else {
                    setCnf((CourseNotFoundException) value);
                }
                break;

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

        public Object getFieldValue(int fieldID) {
            switch (fieldID) {
            case SUCCESS:
                return getSuccess();

            case CNF:
                return getCnf();

            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 SUCCESS:
                return isSetSuccess();
            case CNF:
                return isSetCnf();
            default:
                throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
            }
        }

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

        public boolean equals(getCourse_result that) {
            if (that == null)
                return false;

            boolean this_present_success = true && this.isSetSuccess();
            boolean that_present_success = true && that.isSetSuccess();
            if (this_present_success || that_present_success) {
                if (!(this_present_success && that_present_success))
                    return false;
                if (!this.success.equals(that.success))
                    return false;
            }

            boolean this_present_cnf = true && this.isSetCnf();
            boolean that_present_cnf = true && that.isSetCnf();
            if (this_present_cnf || that_present_cnf) {
                if (!(this_present_cnf && that_present_cnf))
                    return false;
                if (!this.cnf.equals(that.cnf))
                    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 SUCCESS:
                    if (field.type == TType.STRUCT) {
                        this.success = new Course();
                        this.success.read(iprot);
                    } else {
                        TProtocolUtil.skip(iprot, field.type);
                    }
                    break;
                case CNF:
                    if (field.type == TType.STRUCT) {
                        this.cnf = new CourseNotFoundException();
                        this.cnf.read(iprot);
                    } 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 {
            oprot.writeStructBegin(STRUCT_DESC);

            if (this.isSetSuccess()) {
                oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
                this.success.write(oprot);
                oprot.writeFieldEnd();
            } else if (this.isSetCnf()) {
                oprot.writeFieldBegin(CNF_FIELD_DESC);
                this.cnf.write(oprot);
                oprot.writeFieldEnd();
            }
            oprot.writeFieldStop();
            oprot.writeStructEnd();
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder("getCourse_result(");
            boolean first = true;

            sb.append("success:");
            if (this.success == null) {
                sb.append("null");
            } else {
                sb.append(this.success);
            }
            first = false;
            if (!first)
                sb.append(", ");
            sb.append("cnf:");
            if (this.cnf == null) {
                sb.append("null");
            } else {
                sb.append(this.cnf);
            }
            first = false;
            sb.append(")");
            return sb.toString();
        }

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

    }

    public static class addCourse_args implements TBase, java.io.Serializable, Cloneable {
        private static final TStruct STRUCT_DESC = new TStruct("addCourse_args");
        private static final TField COURSE_FIELD_DESC = new TField("course", TType.STRUCT, (short) 1);

        public Course course;
        public static final int COURSE = 1;

        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(COURSE, new FieldMetaData("course", TFieldRequirementType.DEFAULT, new StructMetaData(
                                TType.STRUCT, Course.class)));
                    }
                });

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

        public addCourse_args() {
        }

        public addCourse_args(Course course) {
            this();
            this.course = course;
        }

        /**
         * Performs a deep copy on <i>other</i>.
         */
        public addCourse_args(addCourse_args other) {
            if (other.isSetCourse()) {
                this.course = new Course(other.course);
            }
        }

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

        public Course getCourse() {
            return this.course;
        }

        public void setCourse(Course course) {
            this.course = course;
        }

        public void unsetCourse() {
            this.course = null;
        }

        // Returns true if field course is set (has been asigned a value) and
        // false otherwise
        public boolean isSetCourse() {
            return this.course != null;
        }

        public void setCourseIsSet(boolean value) {
            if (!value) {
                this.course = null;
            }
        }

        public void setFieldValue(int fieldID, Object value) {
            switch (fieldID) {
            case COURSE:
                if (value == null) {
                    unsetCourse();
                } else {
                    setCourse((Course) value);
                }
                break;

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

        public Object getFieldValue(int fieldID) {
            switch (fieldID) {
            case COURSE:
                return getCourse();

            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 COURSE:
                return isSetCourse();
            default:
                throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
            }
        }

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

        public boolean equals(addCourse_args that) {
            if (that == null)
                return false;

            boolean this_present_course = true && this.isSetCourse();
            boolean that_present_course = true && that.isSetCourse();
            if (this_present_course || that_present_course) {
                if (!(this_present_course && that_present_course))
                    return false;
                if (!this.course.equals(that.course))
                    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 COURSE:
                    if (field.type == TType.STRUCT) {
                        this.course = new Course();
                        this.course.read(iprot);
                    } 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.course != null) {
                oprot.writeFieldBegin(COURSE_FIELD_DESC);
                this.course.write(oprot);
                oprot.writeFieldEnd();
            }
            oprot.writeFieldStop();
            oprot.writeStructEnd();
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder("addCourse_args(");
            boolean first = true;

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

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

    }

    public static class addCourse_result implements TBase, java.io.Serializable, Cloneable {
        private static final TStruct STRUCT_DESC = new TStruct("addCourse_result");
        private static final TField UC_FIELD_DESC = new TField("uc", TType.STRUCT, (short) 1);

        public UnacceptableCourseException uc;
        public static final int UC = 1;

        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(UC, new FieldMetaData("uc", TFieldRequirementType.DEFAULT, new FieldValueMetaData(
                                TType.STRUCT)));
                    }
                });

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

        public addCourse_result() {
        }

        public addCourse_result(UnacceptableCourseException uc) {
            this();
            this.uc = uc;
        }

        /**
         * Performs a deep copy on <i>other</i>.
         */
        public addCourse_result(addCourse_result other) {
            if (other.isSetUc()) {
                this.uc = new UnacceptableCourseException(other.uc);
            }
        }

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

        public UnacceptableCourseException getUc() {
            return this.uc;
        }

        public void setUc(UnacceptableCourseException uc) {
            this.uc = uc;
        }

        public void unsetUc() {
            this.uc = null;
        }

        // Returns true if field uc is set (has been asigned a value) and false
        // otherwise
        public boolean isSetUc() {
            return this.uc != null;
        }

        public void setUcIsSet(boolean value) {
            if (!value) {
                this.uc = null;
            }
        }

        public void setFieldValue(int fieldID, Object value) {
            switch (fieldID) {
            case UC:
                if (value == null) {
                    unsetUc();
                } else {
                    setUc((UnacceptableCourseException) value);
                }
                break;

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

        public Object getFieldValue(int fieldID) {
            switch (fieldID) {
            case UC:
                return getUc();

            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 UC:
                return isSetUc();
            default:
                throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
            }
        }

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

        public boolean equals(addCourse_result that) {
            if (that == null)
                return false;

            boolean this_present_uc = true && this.isSetUc();
            boolean that_present_uc = true && that.isSetUc();
            if (this_present_uc || that_present_uc) {
                if (!(this_present_uc && that_present_uc))
                    return false;
                if (!this.uc.equals(that.uc))
                    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 UC:
                    if (field.type == TType.STRUCT) {
                        this.uc = new UnacceptableCourseException();
                        this.uc.read(iprot);
                    } 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 {
            oprot.writeStructBegin(STRUCT_DESC);

            if (this.isSetUc()) {
                oprot.writeFieldBegin(UC_FIELD_DESC);
                this.uc.write(oprot);
                oprot.writeFieldEnd();
            }
            oprot.writeFieldStop();
            oprot.writeStructEnd();
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder("addCourse_result(");
            boolean first = true;

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

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

    }

    public static class deleteCourse_args implements TBase, java.io.Serializable, Cloneable {
        private static final TStruct STRUCT_DESC = new TStruct("deleteCourse_args");
        private static final TField COURSE_NUMBER_FIELD_DESC = new TField("courseNumber", TType.STRING, (short) 1);

        public String courseNumber;
        public static final int COURSENUMBER = 1;

        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(COURSENUMBER, new FieldMetaData("courseNumber", TFieldRequirementType.DEFAULT,
                                new FieldValueMetaData(TType.STRING)));
                    }
                });

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

        public deleteCourse_args() {
        }

        public deleteCourse_args(String courseNumber) {
            this();
            this.courseNumber = courseNumber;
        }

        /**
         * Performs a deep copy on <i>other</i>.
         */
        public deleteCourse_args(deleteCourse_args other) {
            if (other.isSetCourseNumber()) {
                this.courseNumber = other.courseNumber;
            }
        }

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

        public String getCourseNumber() {
            return this.courseNumber;
        }

        public void setCourseNumber(String courseNumber) {
            this.courseNumber = courseNumber;
        }

        public void unsetCourseNumber() {
            this.courseNumber = null;
        }

        // Returns true if field courseNumber is set (has been asigned a value)
        // and false otherwise
        public boolean isSetCourseNumber() {
            return this.courseNumber != null;
        }

        public void setCourseNumberIsSet(boolean value) {
            if (!value) {
                this.courseNumber = null;
            }
        }

        public void setFieldValue(int fieldID, Object value) {
            switch (fieldID) {
            case COURSENUMBER:
                if (value == null) {
                    unsetCourseNumber();
                } else {
                    setCourseNumber((String) value);
                }
                break;

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

        public Object getFieldValue(int fieldID) {
            switch (fieldID) {
            case COURSENUMBER:
                return getCourseNumber();

            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 COURSENUMBER:
                return isSetCourseNumber();
            default:
                throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
            }
        }

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

        public boolean equals(deleteCourse_args that) {
            if (that == null)
                return false;

            boolean this_present_courseNumber = true && this.isSetCourseNumber();
            boolean that_present_courseNumber = true && that.isSetCourseNumber();
            if (this_present_courseNumber || that_present_courseNumber) {
                if (!(this_present_courseNumber && that_present_courseNumber))
                    return false;
                if (!this.courseNumber.equals(that.courseNumber))
                    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 COURSENUMBER:
                    if (field.type == TType.STRING) {
                        this.courseNumber = 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.courseNumber != null) {
                oprot.writeFieldBegin(COURSE_NUMBER_FIELD_DESC);
                oprot.writeString(this.courseNumber);
                oprot.writeFieldEnd();
            }
            oprot.writeFieldStop();
            oprot.writeStructEnd();
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder("deleteCourse_args(");
            boolean first = true;

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

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

    }

    public static class deleteCourse_result implements TBase, java.io.Serializable, Cloneable {
        private static final TStruct STRUCT_DESC = new TStruct("deleteCourse_result");
        private static final TField CNF_FIELD_DESC = new TField("cnf", TType.STRUCT, (short) 1);

        public CourseNotFoundException cnf;
        public static final int CNF = 1;

        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(CNF, new FieldMetaData("cnf", TFieldRequirementType.DEFAULT, new FieldValueMetaData(
                                TType.STRUCT)));
                    }
                });

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

        public deleteCourse_result() {
        }

        public deleteCourse_result(CourseNotFoundException cnf) {
            this();
            this.cnf = cnf;
        }

        /**
         * Performs a deep copy on <i>other</i>.
         */
        public deleteCourse_result(deleteCourse_result other) {
            if (other.isSetCnf()) {
                this.cnf = new CourseNotFoundException(other.cnf);
            }
        }

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

        public CourseNotFoundException getCnf() {
            return this.cnf;
        }

        public void setCnf(CourseNotFoundException cnf) {
            this.cnf = cnf;
        }

        public void unsetCnf() {
            this.cnf = null;
        }

        // Returns true if field cnf is set (has been asigned a value) and false
        // otherwise
        public boolean isSetCnf() {
            return this.cnf != null;
        }

        public void setCnfIsSet(boolean value) {
            if (!value) {
                this.cnf = null;
            }
        }

        public void setFieldValue(int fieldID, Object value) {
            switch (fieldID) {
            case CNF:
                if (value == null) {
                    unsetCnf();
                } else {
                    setCnf((CourseNotFoundException) value);
                }
                break;

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

        public Object getFieldValue(int fieldID) {
            switch (fieldID) {
            case CNF:
                return getCnf();

            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 CNF:
                return isSetCnf();
            default:
                throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
            }
        }

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

        public boolean equals(deleteCourse_result that) {
            if (that == null)
                return false;

            boolean this_present_cnf = true && this.isSetCnf();
            boolean that_present_cnf = true && that.isSetCnf();
            if (this_present_cnf || that_present_cnf) {
                if (!(this_present_cnf && that_present_cnf))
                    return false;
                if (!this.cnf.equals(that.cnf))
                    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 CNF:
                    if (field.type == TType.STRUCT) {
                        this.cnf = new CourseNotFoundException();
                        this.cnf.read(iprot);
                    } 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 {
            oprot.writeStructBegin(STRUCT_DESC);

            if (this.isSetCnf()) {
                oprot.writeFieldBegin(CNF_FIELD_DESC);
                this.cnf.write(oprot);
                oprot.writeFieldEnd();
            }
            oprot.writeFieldStop();
            oprot.writeStructEnd();
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder("deleteCourse_result(");
            boolean first = true;

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

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

    }

}
