From bd8489a2c333ba48bce35fccf15696e6ecb6a0ce Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Wed, 26 Aug 2015 13:30:42 +0100 Subject: [PATCH 01/18] first stab at creating the tenfour quiz model as a thrift spec --- generated/gen-java/tenfour/Answer.java | 757 +++++++++++ generated/gen-java/tenfour/Asset.java | 492 +++++++ generated/gen-java/tenfour/Content.java | 1286 ++++++++++++++++++ generated/gen-java/tenfour/ItemContent.java | 309 +++++ generated/gen-java/tenfour/Question.java | 701 ++++++++++ generated/gen-java/tenfour/QuizContent.java | 548 ++++++++ generated/gen-java/tenfour/ResultGroup.java | 592 ++++++++ generated/gen-java/tenfour/ResultGroups.java | 545 ++++++++ generated/gen-nodejs/quiz_types.js | 891 ++++++++++++ generated/gen-nodejs/shared_types.js | 11 + thrift/atoms/quiz.thrift | 61 + thrift/shared.thrift | 1 + 12 files changed, 6194 insertions(+) create mode 100644 generated/gen-java/tenfour/Answer.java create mode 100644 generated/gen-java/tenfour/Asset.java create mode 100644 generated/gen-java/tenfour/Content.java create mode 100644 generated/gen-java/tenfour/ItemContent.java create mode 100644 generated/gen-java/tenfour/Question.java create mode 100644 generated/gen-java/tenfour/QuizContent.java create mode 100644 generated/gen-java/tenfour/ResultGroup.java create mode 100644 generated/gen-java/tenfour/ResultGroups.java create mode 100644 generated/gen-nodejs/quiz_types.js create mode 100644 generated/gen-nodejs/shared_types.js create mode 100644 thrift/atoms/quiz.thrift create mode 100644 thrift/shared.thrift diff --git a/generated/gen-java/tenfour/Answer.java b/generated/gen-java/tenfour/Answer.java new file mode 100644 index 0000000..e60f5d1 --- /dev/null +++ b/generated/gen-java/tenfour/Answer.java @@ -0,0 +1,757 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package tenfour; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +public class Answer implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Answer"); + + private static final org.apache.thrift.protocol.TField ANSWER_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("answerText", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField ASSETS_FIELD_DESC = new org.apache.thrift.protocol.TField("assets", org.apache.thrift.protocol.TType.LIST, (short)2); + private static final org.apache.thrift.protocol.TField CORRECT_FIELD_DESC = new org.apache.thrift.protocol.TField("correct", org.apache.thrift.protocol.TType.BOOL, (short)3); + private static final org.apache.thrift.protocol.TField REVEAL_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("revealText", org.apache.thrift.protocol.TType.STRING, (short)4); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new AnswerStandardSchemeFactory()); + schemes.put(TupleScheme.class, new AnswerTupleSchemeFactory()); + } + + public String answerText; // required + public List assets; // required + public boolean correct; // required + public String revealText; // optional + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + ANSWER_TEXT((short)1, "answerText"), + ASSETS((short)2, "assets"), + CORRECT((short)3, "correct"), + REVEAL_TEXT((short)4, "revealText"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // ANSWER_TEXT + return ANSWER_TEXT; + case 2: // ASSETS + return ASSETS; + case 3: // CORRECT + return CORRECT; + case 4: // REVEAL_TEXT + return REVEAL_TEXT; + 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __CORRECT_ISSET_ID = 0; + private byte __isset_bitfield = 0; + private static final _Fields optionals[] = {_Fields.REVEAL_TEXT}; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.ANSWER_TEXT, new org.apache.thrift.meta_data.FieldMetaData("answerText", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.ASSETS, new org.apache.thrift.meta_data.FieldMetaData("assets", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "Asset")))); + tmpMap.put(_Fields.CORRECT, new org.apache.thrift.meta_data.FieldMetaData("correct", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.REVEAL_TEXT, new org.apache.thrift.meta_data.FieldMetaData("revealText", org.apache.thrift.TFieldRequirementType.OPTIONAL, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Answer.class, metaDataMap); + } + + public Answer() { + } + + public Answer( + String answerText, + List assets, + boolean correct) + { + this(); + this.answerText = answerText; + this.assets = assets; + this.correct = correct; + setCorrectIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public Answer(Answer other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetAnswerText()) { + this.answerText = other.answerText; + } + if (other.isSetAssets()) { + List __this__assets = new ArrayList(other.assets.size()); + for (Asset other_element : other.assets) { + __this__assets.add(other_element); + } + this.assets = __this__assets; + } + this.correct = other.correct; + if (other.isSetRevealText()) { + this.revealText = other.revealText; + } + } + + public Answer deepCopy() { + return new Answer(this); + } + + @Override + public void clear() { + this.answerText = null; + this.assets = null; + setCorrectIsSet(false); + this.correct = false; + this.revealText = null; + } + + public String getAnswerText() { + return this.answerText; + } + + public Answer setAnswerText(String answerText) { + this.answerText = answerText; + return this; + } + + public void unsetAnswerText() { + this.answerText = null; + } + + /** Returns true if field answerText is set (has been assigned a value) and false otherwise */ + public boolean isSetAnswerText() { + return this.answerText != null; + } + + public void setAnswerTextIsSet(boolean value) { + if (!value) { + this.answerText = null; + } + } + + public int getAssetsSize() { + return (this.assets == null) ? 0 : this.assets.size(); + } + + public java.util.Iterator getAssetsIterator() { + return (this.assets == null) ? null : this.assets.iterator(); + } + + public void addToAssets(Asset elem) { + if (this.assets == null) { + this.assets = new ArrayList(); + } + this.assets.add(elem); + } + + public List getAssets() { + return this.assets; + } + + public Answer setAssets(List assets) { + this.assets = assets; + return this; + } + + public void unsetAssets() { + this.assets = null; + } + + /** Returns true if field assets is set (has been assigned a value) and false otherwise */ + public boolean isSetAssets() { + return this.assets != null; + } + + public void setAssetsIsSet(boolean value) { + if (!value) { + this.assets = null; + } + } + + public boolean isCorrect() { + return this.correct; + } + + public Answer setCorrect(boolean correct) { + this.correct = correct; + setCorrectIsSet(true); + return this; + } + + public void unsetCorrect() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __CORRECT_ISSET_ID); + } + + /** Returns true if field correct is set (has been assigned a value) and false otherwise */ + public boolean isSetCorrect() { + return EncodingUtils.testBit(__isset_bitfield, __CORRECT_ISSET_ID); + } + + public void setCorrectIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __CORRECT_ISSET_ID, value); + } + + public String getRevealText() { + return this.revealText; + } + + public Answer setRevealText(String revealText) { + this.revealText = revealText; + return this; + } + + public void unsetRevealText() { + this.revealText = null; + } + + /** Returns true if field revealText is set (has been assigned a value) and false otherwise */ + public boolean isSetRevealText() { + return this.revealText != null; + } + + public void setRevealTextIsSet(boolean value) { + if (!value) { + this.revealText = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case ANSWER_TEXT: + if (value == null) { + unsetAnswerText(); + } else { + setAnswerText((String)value); + } + break; + + case ASSETS: + if (value == null) { + unsetAssets(); + } else { + setAssets((List)value); + } + break; + + case CORRECT: + if (value == null) { + unsetCorrect(); + } else { + setCorrect((Boolean)value); + } + break; + + case REVEAL_TEXT: + if (value == null) { + unsetRevealText(); + } else { + setRevealText((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case ANSWER_TEXT: + return getAnswerText(); + + case ASSETS: + return getAssets(); + + case CORRECT: + return Boolean.valueOf(isCorrect()); + + case REVEAL_TEXT: + return getRevealText(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case ANSWER_TEXT: + return isSetAnswerText(); + case ASSETS: + return isSetAssets(); + case CORRECT: + return isSetCorrect(); + case REVEAL_TEXT: + return isSetRevealText(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof Answer) + return this.equals((Answer)that); + return false; + } + + public boolean equals(Answer that) { + if (that == null) + return false; + + boolean this_present_answerText = true && this.isSetAnswerText(); + boolean that_present_answerText = true && that.isSetAnswerText(); + if (this_present_answerText || that_present_answerText) { + if (!(this_present_answerText && that_present_answerText)) + return false; + if (!this.answerText.equals(that.answerText)) + return false; + } + + boolean this_present_assets = true && this.isSetAssets(); + boolean that_present_assets = true && that.isSetAssets(); + if (this_present_assets || that_present_assets) { + if (!(this_present_assets && that_present_assets)) + return false; + if (!this.assets.equals(that.assets)) + return false; + } + + boolean this_present_correct = true; + boolean that_present_correct = true; + if (this_present_correct || that_present_correct) { + if (!(this_present_correct && that_present_correct)) + return false; + if (this.correct != that.correct) + return false; + } + + boolean this_present_revealText = true && this.isSetRevealText(); + boolean that_present_revealText = true && that.isSetRevealText(); + if (this_present_revealText || that_present_revealText) { + if (!(this_present_revealText && that_present_revealText)) + return false; + if (!this.revealText.equals(that.revealText)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_answerText = true && (isSetAnswerText()); + list.add(present_answerText); + if (present_answerText) + list.add(answerText); + + boolean present_assets = true && (isSetAssets()); + list.add(present_assets); + if (present_assets) + list.add(assets); + + boolean present_correct = true; + list.add(present_correct); + if (present_correct) + list.add(correct); + + boolean present_revealText = true && (isSetRevealText()); + list.add(present_revealText); + if (present_revealText) + list.add(revealText); + + return list.hashCode(); + } + + @Override + public int compareTo(Answer other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetAnswerText()).compareTo(other.isSetAnswerText()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetAnswerText()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.answerText, other.answerText); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetAssets()).compareTo(other.isSetAssets()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetAssets()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.assets, other.assets); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCorrect()).compareTo(other.isSetCorrect()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCorrect()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.correct, other.correct); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetRevealText()).compareTo(other.isSetRevealText()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetRevealText()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.revealText, other.revealText); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("Answer("); + boolean first = true; + + sb.append("answerText:"); + if (this.answerText == null) { + sb.append("null"); + } else { + sb.append(this.answerText); + } + first = false; + if (!first) sb.append(", "); + sb.append("assets:"); + if (this.assets == null) { + sb.append("null"); + } else { + sb.append(this.assets); + } + first = false; + if (!first) sb.append(", "); + sb.append("correct:"); + sb.append(this.correct); + first = false; + if (isSetRevealText()) { + if (!first) sb.append(", "); + sb.append("revealText:"); + if (this.revealText == null) { + sb.append("null"); + } else { + sb.append(this.revealText); + } + first = false; + } + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (answerText == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'answerText' was not present! Struct: " + toString()); + } + if (assets == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'assets' was not present! Struct: " + toString()); + } + // alas, we cannot check 'correct' because it's a primitive and you chose the non-beans generator. + // check for sub-struct validity + } + + 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, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class AnswerStandardSchemeFactory implements SchemeFactory { + public AnswerStandardScheme getScheme() { + return new AnswerStandardScheme(); + } + } + + private static class AnswerStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, Answer struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // ANSWER_TEXT + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.answerText = iprot.readString(); + struct.setAnswerTextIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // ASSETS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list32 = iprot.readListBegin(); + struct.assets = new ArrayList(_list32.size); + Asset _elem33; + for (int _i34 = 0; _i34 < _list32.size; ++_i34) + { + _elem33 = new Asset(); + _elem33.read(iprot); + struct.assets.add(_elem33); + } + iprot.readListEnd(); + } + struct.setAssetsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // CORRECT + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.correct = iprot.readBool(); + struct.setCorrectIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // REVEAL_TEXT + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.revealText = iprot.readString(); + struct.setRevealTextIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + if (!struct.isSetCorrect()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'correct' was not found in serialized data! Struct: " + toString()); + } + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, Answer struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.answerText != null) { + oprot.writeFieldBegin(ANSWER_TEXT_FIELD_DESC); + oprot.writeString(struct.answerText); + oprot.writeFieldEnd(); + } + if (struct.assets != null) { + oprot.writeFieldBegin(ASSETS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.assets.size())); + for (Asset _iter35 : struct.assets) + { + _iter35.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(CORRECT_FIELD_DESC); + oprot.writeBool(struct.correct); + oprot.writeFieldEnd(); + if (struct.revealText != null) { + if (struct.isSetRevealText()) { + oprot.writeFieldBegin(REVEAL_TEXT_FIELD_DESC); + oprot.writeString(struct.revealText); + oprot.writeFieldEnd(); + } + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class AnswerTupleSchemeFactory implements SchemeFactory { + public AnswerTupleScheme getScheme() { + return new AnswerTupleScheme(); + } + } + + private static class AnswerTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, Answer struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.answerText); + { + oprot.writeI32(struct.assets.size()); + for (Asset _iter36 : struct.assets) + { + _iter36.write(oprot); + } + } + oprot.writeBool(struct.correct); + BitSet optionals = new BitSet(); + if (struct.isSetRevealText()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetRevealText()) { + oprot.writeString(struct.revealText); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, Answer struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.answerText = iprot.readString(); + struct.setAnswerTextIsSet(true); + { + org.apache.thrift.protocol.TList _list37 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.assets = new ArrayList(_list37.size); + Asset _elem38; + for (int _i39 = 0; _i39 < _list37.size; ++_i39) + { + _elem38 = new Asset(); + _elem38.read(iprot); + struct.assets.add(_elem38); + } + } + struct.setAssetsIsSet(true); + struct.correct = iprot.readBool(); + struct.setCorrectIsSet(true); + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.revealText = iprot.readString(); + struct.setRevealTextIsSet(true); + } + } + } + +} + diff --git a/generated/gen-java/tenfour/Asset.java b/generated/gen-java/tenfour/Asset.java new file mode 100644 index 0000000..1994139 --- /dev/null +++ b/generated/gen-java/tenfour/Asset.java @@ -0,0 +1,492 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package tenfour; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +public class Asset implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Asset"); + + private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField DATA_FIELD_DESC = new org.apache.thrift.protocol.TField("data", org.apache.thrift.protocol.TType.STRING, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new AssetStandardSchemeFactory()); + schemes.put(TupleScheme.class, new AssetTupleSchemeFactory()); + } + + public String type; // required + public String data; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + TYPE((short)1, "type"), + DATA((short)2, "data"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // TYPE + return TYPE; + case 2: // DATA + return DATA; + 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.DATA, new org.apache.thrift.meta_data.FieldMetaData("data", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , "OpaqueJson"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Asset.class, metaDataMap); + } + + public Asset() { + } + + public Asset( + String type, + String data) + { + this(); + this.type = type; + this.data = data; + } + + /** + * Performs a deep copy on other. + */ + public Asset(Asset other) { + if (other.isSetType()) { + this.type = other.type; + } + if (other.isSetData()) { + this.data = other.data; + } + } + + public Asset deepCopy() { + return new Asset(this); + } + + @Override + public void clear() { + this.type = null; + this.data = null; + } + + public String getType() { + return this.type; + } + + public Asset setType(String type) { + this.type = type; + return this; + } + + public void unsetType() { + this.type = null; + } + + /** Returns true if field type is set (has been assigned a value) and false otherwise */ + public boolean isSetType() { + return this.type != null; + } + + public void setTypeIsSet(boolean value) { + if (!value) { + this.type = null; + } + } + + public String getData() { + return this.data; + } + + public Asset setData(String data) { + this.data = data; + return this; + } + + public void unsetData() { + this.data = null; + } + + /** Returns true if field data is set (has been assigned a value) and false otherwise */ + public boolean isSetData() { + return this.data != null; + } + + public void setDataIsSet(boolean value) { + if (!value) { + this.data = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case TYPE: + if (value == null) { + unsetType(); + } else { + setType((String)value); + } + break; + + case DATA: + if (value == null) { + unsetData(); + } else { + setData((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case TYPE: + return getType(); + + case DATA: + return getData(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case TYPE: + return isSetType(); + case DATA: + return isSetData(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof Asset) + return this.equals((Asset)that); + return false; + } + + public boolean equals(Asset that) { + if (that == null) + return false; + + boolean this_present_type = true && this.isSetType(); + boolean that_present_type = true && that.isSetType(); + if (this_present_type || that_present_type) { + if (!(this_present_type && that_present_type)) + return false; + if (!this.type.equals(that.type)) + return false; + } + + boolean this_present_data = true && this.isSetData(); + boolean that_present_data = true && that.isSetData(); + if (this_present_data || that_present_data) { + if (!(this_present_data && that_present_data)) + return false; + if (!this.data.equals(that.data)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_type = true && (isSetType()); + list.add(present_type); + if (present_type) + list.add(type); + + boolean present_data = true && (isSetData()); + list.add(present_data); + if (present_data) + list.add(data); + + return list.hashCode(); + } + + @Override + public int compareTo(Asset other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetData()).compareTo(other.isSetData()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetData()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.data, other.data); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("Asset("); + boolean first = true; + + sb.append("type:"); + if (this.type == null) { + sb.append("null"); + } else { + sb.append(this.type); + } + first = false; + if (!first) sb.append(", "); + sb.append("data:"); + if (this.data == null) { + sb.append("null"); + } else { + sb.append(this.data); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (type == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' was not present! Struct: " + toString()); + } + if (data == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'data' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + 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, 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); + } + } + + private static class AssetStandardSchemeFactory implements SchemeFactory { + public AssetStandardScheme getScheme() { + return new AssetStandardScheme(); + } + } + + private static class AssetStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, Asset struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.type = iprot.readString(); + struct.setTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // DATA + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.data = iprot.readString(); + struct.setDataIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, Asset struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.type != null) { + oprot.writeFieldBegin(TYPE_FIELD_DESC); + oprot.writeString(struct.type); + oprot.writeFieldEnd(); + } + if (struct.data != null) { + oprot.writeFieldBegin(DATA_FIELD_DESC); + oprot.writeString(struct.data); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class AssetTupleSchemeFactory implements SchemeFactory { + public AssetTupleScheme getScheme() { + return new AssetTupleScheme(); + } + } + + private static class AssetTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, Asset struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.type); + oprot.writeString(struct.data); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, Asset struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.type = iprot.readString(); + struct.setTypeIsSet(true); + struct.data = iprot.readString(); + struct.setDataIsSet(true); + } + } + +} + diff --git a/generated/gen-java/tenfour/Content.java b/generated/gen-java/tenfour/Content.java new file mode 100644 index 0000000..4546cb0 --- /dev/null +++ b/generated/gen-java/tenfour/Content.java @@ -0,0 +1,1286 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package tenfour; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +public class Content implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Content"); + + private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField TITLE_FIELD_DESC = new org.apache.thrift.protocol.TField("title", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField UPDATED_BY_FIELD_DESC = new org.apache.thrift.protocol.TField("updatedBy", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField UPDATED_AT_FIELD_DESC = new org.apache.thrift.protocol.TField("updatedAt", org.apache.thrift.protocol.TType.I64, (short)4); + private static final org.apache.thrift.protocol.TField CREATED_AT_FIELD_DESC = new org.apache.thrift.protocol.TField("createdAt", org.apache.thrift.protocol.TType.I64, (short)5); + private static final org.apache.thrift.protocol.TField CREATED_BY_FIELD_DESC = new org.apache.thrift.protocol.TField("createdBy", org.apache.thrift.protocol.TType.STRING, (short)6); + private static final org.apache.thrift.protocol.TField PUBLISHED_FIELD_DESC = new org.apache.thrift.protocol.TField("published", org.apache.thrift.protocol.TType.BOOL, (short)7); + private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.STRING, (short)8); + private static final org.apache.thrift.protocol.TField DEFAULT_COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("defaultColumns", org.apache.thrift.protocol.TType.I16, (short)9); + private static final org.apache.thrift.protocol.TField CONTENT_FIELD_DESC = new org.apache.thrift.protocol.TField("content", org.apache.thrift.protocol.TType.STRUCT, (short)10); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new ContentStandardSchemeFactory()); + schemes.put(TupleScheme.class, new ContentTupleSchemeFactory()); + } + + public String id; // required + public String title; // required + public String updatedBy; // required + public long updatedAt; // required + public long createdAt; // required + public String createdBy; // required + public boolean published; // required + public String type; // required + public short defaultColumns; // required + public ItemContent content; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + ID((short)1, "id"), + TITLE((short)2, "title"), + UPDATED_BY((short)3, "updatedBy"), + UPDATED_AT((short)4, "updatedAt"), + CREATED_AT((short)5, "createdAt"), + CREATED_BY((short)6, "createdBy"), + PUBLISHED((short)7, "published"), + TYPE((short)8, "type"), + DEFAULT_COLUMNS((short)9, "defaultColumns"), + CONTENT((short)10, "content"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // ID + return ID; + case 2: // TITLE + return TITLE; + case 3: // UPDATED_BY + return UPDATED_BY; + case 4: // UPDATED_AT + return UPDATED_AT; + case 5: // CREATED_AT + return CREATED_AT; + case 6: // CREATED_BY + return CREATED_BY; + case 7: // PUBLISHED + return PUBLISHED; + case 8: // TYPE + return TYPE; + case 9: // DEFAULT_COLUMNS + return DEFAULT_COLUMNS; + case 10: // CONTENT + return CONTENT; + 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __UPDATEDAT_ISSET_ID = 0; + private static final int __CREATEDAT_ISSET_ID = 1; + private static final int __PUBLISHED_ISSET_ID = 2; + private static final int __DEFAULTCOLUMNS_ISSET_ID = 3; + private byte __isset_bitfield = 0; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.TITLE, new org.apache.thrift.meta_data.FieldMetaData("title", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.UPDATED_BY, new org.apache.thrift.meta_data.FieldMetaData("updatedBy", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.UPDATED_AT, new org.apache.thrift.meta_data.FieldMetaData("updatedAt", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64 , "DateTime"))); + tmpMap.put(_Fields.CREATED_AT, new org.apache.thrift.meta_data.FieldMetaData("createdAt", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64 , "DateTime"))); + tmpMap.put(_Fields.CREATED_BY, new org.apache.thrift.meta_data.FieldMetaData("createdBy", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.PUBLISHED, new org.apache.thrift.meta_data.FieldMetaData("published", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.DEFAULT_COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("defaultColumns", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); + tmpMap.put(_Fields.CONTENT, new org.apache.thrift.meta_data.FieldMetaData("content", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "ItemContent"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Content.class, metaDataMap); + } + + public Content() { + } + + public Content( + String id, + String title, + String updatedBy, + long updatedAt, + long createdAt, + String createdBy, + boolean published, + String type, + short defaultColumns, + ItemContent content) + { + this(); + this.id = id; + this.title = title; + this.updatedBy = updatedBy; + this.updatedAt = updatedAt; + setUpdatedAtIsSet(true); + this.createdAt = createdAt; + setCreatedAtIsSet(true); + this.createdBy = createdBy; + this.published = published; + setPublishedIsSet(true); + this.type = type; + this.defaultColumns = defaultColumns; + setDefaultColumnsIsSet(true); + this.content = content; + } + + /** + * Performs a deep copy on other. + */ + public Content(Content other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetId()) { + this.id = other.id; + } + if (other.isSetTitle()) { + this.title = other.title; + } + if (other.isSetUpdatedBy()) { + this.updatedBy = other.updatedBy; + } + this.updatedAt = other.updatedAt; + this.createdAt = other.createdAt; + if (other.isSetCreatedBy()) { + this.createdBy = other.createdBy; + } + this.published = other.published; + if (other.isSetType()) { + this.type = other.type; + } + this.defaultColumns = other.defaultColumns; + if (other.isSetContent()) { + this.content = other.content; + } + } + + public Content deepCopy() { + return new Content(this); + } + + @Override + public void clear() { + this.id = null; + this.title = null; + this.updatedBy = null; + setUpdatedAtIsSet(false); + this.updatedAt = 0; + setCreatedAtIsSet(false); + this.createdAt = 0; + this.createdBy = null; + setPublishedIsSet(false); + this.published = false; + this.type = null; + setDefaultColumnsIsSet(false); + this.defaultColumns = 0; + this.content = null; + } + + public String getId() { + return this.id; + } + + public Content setId(String id) { + this.id = id; + return this; + } + + public void unsetId() { + this.id = null; + } + + /** Returns true if field id is set (has been assigned a value) and false otherwise */ + public boolean isSetId() { + return this.id != null; + } + + public void setIdIsSet(boolean value) { + if (!value) { + this.id = null; + } + } + + public String getTitle() { + return this.title; + } + + public Content setTitle(String title) { + this.title = title; + return this; + } + + public void unsetTitle() { + this.title = null; + } + + /** Returns true if field title is set (has been assigned a value) and false otherwise */ + public boolean isSetTitle() { + return this.title != null; + } + + public void setTitleIsSet(boolean value) { + if (!value) { + this.title = null; + } + } + + public String getUpdatedBy() { + return this.updatedBy; + } + + public Content setUpdatedBy(String updatedBy) { + this.updatedBy = updatedBy; + return this; + } + + public void unsetUpdatedBy() { + this.updatedBy = null; + } + + /** Returns true if field updatedBy is set (has been assigned a value) and false otherwise */ + public boolean isSetUpdatedBy() { + return this.updatedBy != null; + } + + public void setUpdatedByIsSet(boolean value) { + if (!value) { + this.updatedBy = null; + } + } + + public long getUpdatedAt() { + return this.updatedAt; + } + + public Content setUpdatedAt(long updatedAt) { + this.updatedAt = updatedAt; + setUpdatedAtIsSet(true); + return this; + } + + public void unsetUpdatedAt() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __UPDATEDAT_ISSET_ID); + } + + /** Returns true if field updatedAt is set (has been assigned a value) and false otherwise */ + public boolean isSetUpdatedAt() { + return EncodingUtils.testBit(__isset_bitfield, __UPDATEDAT_ISSET_ID); + } + + public void setUpdatedAtIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __UPDATEDAT_ISSET_ID, value); + } + + public long getCreatedAt() { + return this.createdAt; + } + + public Content setCreatedAt(long createdAt) { + this.createdAt = createdAt; + setCreatedAtIsSet(true); + return this; + } + + public void unsetCreatedAt() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __CREATEDAT_ISSET_ID); + } + + /** Returns true if field createdAt is set (has been assigned a value) and false otherwise */ + public boolean isSetCreatedAt() { + return EncodingUtils.testBit(__isset_bitfield, __CREATEDAT_ISSET_ID); + } + + public void setCreatedAtIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __CREATEDAT_ISSET_ID, value); + } + + public String getCreatedBy() { + return this.createdBy; + } + + public Content setCreatedBy(String createdBy) { + this.createdBy = createdBy; + return this; + } + + public void unsetCreatedBy() { + this.createdBy = null; + } + + /** Returns true if field createdBy is set (has been assigned a value) and false otherwise */ + public boolean isSetCreatedBy() { + return this.createdBy != null; + } + + public void setCreatedByIsSet(boolean value) { + if (!value) { + this.createdBy = null; + } + } + + public boolean isPublished() { + return this.published; + } + + public Content setPublished(boolean published) { + this.published = published; + setPublishedIsSet(true); + return this; + } + + public void unsetPublished() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PUBLISHED_ISSET_ID); + } + + /** Returns true if field published is set (has been assigned a value) and false otherwise */ + public boolean isSetPublished() { + return EncodingUtils.testBit(__isset_bitfield, __PUBLISHED_ISSET_ID); + } + + public void setPublishedIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PUBLISHED_ISSET_ID, value); + } + + public String getType() { + return this.type; + } + + public Content setType(String type) { + this.type = type; + return this; + } + + public void unsetType() { + this.type = null; + } + + /** Returns true if field type is set (has been assigned a value) and false otherwise */ + public boolean isSetType() { + return this.type != null; + } + + public void setTypeIsSet(boolean value) { + if (!value) { + this.type = null; + } + } + + public short getDefaultColumns() { + return this.defaultColumns; + } + + public Content setDefaultColumns(short defaultColumns) { + this.defaultColumns = defaultColumns; + setDefaultColumnsIsSet(true); + return this; + } + + public void unsetDefaultColumns() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __DEFAULTCOLUMNS_ISSET_ID); + } + + /** Returns true if field defaultColumns is set (has been assigned a value) and false otherwise */ + public boolean isSetDefaultColumns() { + return EncodingUtils.testBit(__isset_bitfield, __DEFAULTCOLUMNS_ISSET_ID); + } + + public void setDefaultColumnsIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __DEFAULTCOLUMNS_ISSET_ID, value); + } + + public ItemContent getContent() { + return this.content; + } + + public Content setContent(ItemContent content) { + this.content = content; + return this; + } + + public void unsetContent() { + this.content = null; + } + + /** Returns true if field content is set (has been assigned a value) and false otherwise */ + public boolean isSetContent() { + return this.content != null; + } + + public void setContentIsSet(boolean value) { + if (!value) { + this.content = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case ID: + if (value == null) { + unsetId(); + } else { + setId((String)value); + } + break; + + case TITLE: + if (value == null) { + unsetTitle(); + } else { + setTitle((String)value); + } + break; + + case UPDATED_BY: + if (value == null) { + unsetUpdatedBy(); + } else { + setUpdatedBy((String)value); + } + break; + + case UPDATED_AT: + if (value == null) { + unsetUpdatedAt(); + } else { + setUpdatedAt((Long)value); + } + break; + + case CREATED_AT: + if (value == null) { + unsetCreatedAt(); + } else { + setCreatedAt((Long)value); + } + break; + + case CREATED_BY: + if (value == null) { + unsetCreatedBy(); + } else { + setCreatedBy((String)value); + } + break; + + case PUBLISHED: + if (value == null) { + unsetPublished(); + } else { + setPublished((Boolean)value); + } + break; + + case TYPE: + if (value == null) { + unsetType(); + } else { + setType((String)value); + } + break; + + case DEFAULT_COLUMNS: + if (value == null) { + unsetDefaultColumns(); + } else { + setDefaultColumns((Short)value); + } + break; + + case CONTENT: + if (value == null) { + unsetContent(); + } else { + setContent((ItemContent)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case ID: + return getId(); + + case TITLE: + return getTitle(); + + case UPDATED_BY: + return getUpdatedBy(); + + case UPDATED_AT: + return Long.valueOf(getUpdatedAt()); + + case CREATED_AT: + return Long.valueOf(getCreatedAt()); + + case CREATED_BY: + return getCreatedBy(); + + case PUBLISHED: + return Boolean.valueOf(isPublished()); + + case TYPE: + return getType(); + + case DEFAULT_COLUMNS: + return Short.valueOf(getDefaultColumns()); + + case CONTENT: + return getContent(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case ID: + return isSetId(); + case TITLE: + return isSetTitle(); + case UPDATED_BY: + return isSetUpdatedBy(); + case UPDATED_AT: + return isSetUpdatedAt(); + case CREATED_AT: + return isSetCreatedAt(); + case CREATED_BY: + return isSetCreatedBy(); + case PUBLISHED: + return isSetPublished(); + case TYPE: + return isSetType(); + case DEFAULT_COLUMNS: + return isSetDefaultColumns(); + case CONTENT: + return isSetContent(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof Content) + return this.equals((Content)that); + return false; + } + + public boolean equals(Content that) { + if (that == null) + return false; + + boolean this_present_id = true && this.isSetId(); + boolean that_present_id = true && that.isSetId(); + if (this_present_id || that_present_id) { + if (!(this_present_id && that_present_id)) + return false; + if (!this.id.equals(that.id)) + return false; + } + + boolean this_present_title = true && this.isSetTitle(); + boolean that_present_title = true && that.isSetTitle(); + if (this_present_title || that_present_title) { + if (!(this_present_title && that_present_title)) + return false; + if (!this.title.equals(that.title)) + return false; + } + + boolean this_present_updatedBy = true && this.isSetUpdatedBy(); + boolean that_present_updatedBy = true && that.isSetUpdatedBy(); + if (this_present_updatedBy || that_present_updatedBy) { + if (!(this_present_updatedBy && that_present_updatedBy)) + return false; + if (!this.updatedBy.equals(that.updatedBy)) + return false; + } + + boolean this_present_updatedAt = true; + boolean that_present_updatedAt = true; + if (this_present_updatedAt || that_present_updatedAt) { + if (!(this_present_updatedAt && that_present_updatedAt)) + return false; + if (this.updatedAt != that.updatedAt) + return false; + } + + boolean this_present_createdAt = true; + boolean that_present_createdAt = true; + if (this_present_createdAt || that_present_createdAt) { + if (!(this_present_createdAt && that_present_createdAt)) + return false; + if (this.createdAt != that.createdAt) + return false; + } + + boolean this_present_createdBy = true && this.isSetCreatedBy(); + boolean that_present_createdBy = true && that.isSetCreatedBy(); + if (this_present_createdBy || that_present_createdBy) { + if (!(this_present_createdBy && that_present_createdBy)) + return false; + if (!this.createdBy.equals(that.createdBy)) + return false; + } + + boolean this_present_published = true; + boolean that_present_published = true; + if (this_present_published || that_present_published) { + if (!(this_present_published && that_present_published)) + return false; + if (this.published != that.published) + return false; + } + + boolean this_present_type = true && this.isSetType(); + boolean that_present_type = true && that.isSetType(); + if (this_present_type || that_present_type) { + if (!(this_present_type && that_present_type)) + return false; + if (!this.type.equals(that.type)) + return false; + } + + boolean this_present_defaultColumns = true; + boolean that_present_defaultColumns = true; + if (this_present_defaultColumns || that_present_defaultColumns) { + if (!(this_present_defaultColumns && that_present_defaultColumns)) + return false; + if (this.defaultColumns != that.defaultColumns) + return false; + } + + boolean this_present_content = true && this.isSetContent(); + boolean that_present_content = true && that.isSetContent(); + if (this_present_content || that_present_content) { + if (!(this_present_content && that_present_content)) + return false; + if (!this.content.equals(that.content)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_id = true && (isSetId()); + list.add(present_id); + if (present_id) + list.add(id); + + boolean present_title = true && (isSetTitle()); + list.add(present_title); + if (present_title) + list.add(title); + + boolean present_updatedBy = true && (isSetUpdatedBy()); + list.add(present_updatedBy); + if (present_updatedBy) + list.add(updatedBy); + + boolean present_updatedAt = true; + list.add(present_updatedAt); + if (present_updatedAt) + list.add(updatedAt); + + boolean present_createdAt = true; + list.add(present_createdAt); + if (present_createdAt) + list.add(createdAt); + + boolean present_createdBy = true && (isSetCreatedBy()); + list.add(present_createdBy); + if (present_createdBy) + list.add(createdBy); + + boolean present_published = true; + list.add(present_published); + if (present_published) + list.add(published); + + boolean present_type = true && (isSetType()); + list.add(present_type); + if (present_type) + list.add(type); + + boolean present_defaultColumns = true; + list.add(present_defaultColumns); + if (present_defaultColumns) + list.add(defaultColumns); + + boolean present_content = true && (isSetContent()); + list.add(present_content); + if (present_content) + list.add(content); + + return list.hashCode(); + } + + @Override + public int compareTo(Content other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetId()).compareTo(other.isSetId()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetId()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetTitle()).compareTo(other.isSetTitle()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTitle()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.title, other.title); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetUpdatedBy()).compareTo(other.isSetUpdatedBy()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUpdatedBy()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updatedBy, other.updatedBy); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetUpdatedAt()).compareTo(other.isSetUpdatedAt()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUpdatedAt()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updatedAt, other.updatedAt); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCreatedAt()).compareTo(other.isSetCreatedAt()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCreatedAt()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createdAt, other.createdAt); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCreatedBy()).compareTo(other.isSetCreatedBy()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCreatedBy()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createdBy, other.createdBy); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetPublished()).compareTo(other.isSetPublished()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetPublished()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.published, other.published); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetDefaultColumns()).compareTo(other.isSetDefaultColumns()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetDefaultColumns()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.defaultColumns, other.defaultColumns); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetContent()).compareTo(other.isSetContent()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetContent()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.content, other.content); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("Content("); + boolean first = true; + + sb.append("id:"); + if (this.id == null) { + sb.append("null"); + } else { + sb.append(this.id); + } + first = false; + if (!first) sb.append(", "); + sb.append("title:"); + if (this.title == null) { + sb.append("null"); + } else { + sb.append(this.title); + } + first = false; + if (!first) sb.append(", "); + sb.append("updatedBy:"); + if (this.updatedBy == null) { + sb.append("null"); + } else { + sb.append(this.updatedBy); + } + first = false; + if (!first) sb.append(", "); + sb.append("updatedAt:"); + sb.append(this.updatedAt); + first = false; + if (!first) sb.append(", "); + sb.append("createdAt:"); + sb.append(this.createdAt); + first = false; + if (!first) sb.append(", "); + sb.append("createdBy:"); + if (this.createdBy == null) { + sb.append("null"); + } else { + sb.append(this.createdBy); + } + first = false; + if (!first) sb.append(", "); + sb.append("published:"); + sb.append(this.published); + first = false; + if (!first) sb.append(", "); + sb.append("type:"); + if (this.type == null) { + sb.append("null"); + } else { + sb.append(this.type); + } + first = false; + if (!first) sb.append(", "); + sb.append("defaultColumns:"); + sb.append(this.defaultColumns); + first = false; + if (!first) sb.append(", "); + sb.append("content:"); + if (this.content == null) { + sb.append("null"); + } else { + sb.append(this.content); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (id == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'id' was not present! Struct: " + toString()); + } + if (title == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'title' was not present! Struct: " + toString()); + } + if (updatedBy == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'updatedBy' was not present! Struct: " + toString()); + } + // alas, we cannot check 'updatedAt' because it's a primitive and you chose the non-beans generator. + // alas, we cannot check 'createdAt' because it's a primitive and you chose the non-beans generator. + if (createdBy == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'createdBy' was not present! Struct: " + toString()); + } + // alas, we cannot check 'published' because it's a primitive and you chose the non-beans generator. + if (type == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' was not present! Struct: " + toString()); + } + // alas, we cannot check 'defaultColumns' because it's a primitive and you chose the non-beans generator. + if (content == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'content' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + 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, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class ContentStandardSchemeFactory implements SchemeFactory { + public ContentStandardScheme getScheme() { + return new ContentStandardScheme(); + } + } + + private static class ContentStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, Content struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // ID + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.id = iprot.readString(); + struct.setIdIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // TITLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.title = iprot.readString(); + struct.setTitleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // UPDATED_BY + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.updatedBy = iprot.readString(); + struct.setUpdatedByIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // UPDATED_AT + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.updatedAt = iprot.readI64(); + struct.setUpdatedAtIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 5: // CREATED_AT + if (schemeField.type == org.apache.thrift.protocol.TType.I64) { + struct.createdAt = iprot.readI64(); + struct.setCreatedAtIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 6: // CREATED_BY + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.createdBy = iprot.readString(); + struct.setCreatedByIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 7: // PUBLISHED + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.published = iprot.readBool(); + struct.setPublishedIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 8: // TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.type = iprot.readString(); + struct.setTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 9: // DEFAULT_COLUMNS + if (schemeField.type == org.apache.thrift.protocol.TType.I16) { + struct.defaultColumns = iprot.readI16(); + struct.setDefaultColumnsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 10: // CONTENT + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.content = new ItemContent(); + struct.content.read(iprot); + struct.setContentIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + if (!struct.isSetUpdatedAt()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'updatedAt' was not found in serialized data! Struct: " + toString()); + } + if (!struct.isSetCreatedAt()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'createdAt' was not found in serialized data! Struct: " + toString()); + } + if (!struct.isSetPublished()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'published' was not found in serialized data! Struct: " + toString()); + } + if (!struct.isSetDefaultColumns()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'defaultColumns' was not found in serialized data! Struct: " + toString()); + } + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, Content struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.id != null) { + oprot.writeFieldBegin(ID_FIELD_DESC); + oprot.writeString(struct.id); + oprot.writeFieldEnd(); + } + if (struct.title != null) { + oprot.writeFieldBegin(TITLE_FIELD_DESC); + oprot.writeString(struct.title); + oprot.writeFieldEnd(); + } + if (struct.updatedBy != null) { + oprot.writeFieldBegin(UPDATED_BY_FIELD_DESC); + oprot.writeString(struct.updatedBy); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(UPDATED_AT_FIELD_DESC); + oprot.writeI64(struct.updatedAt); + oprot.writeFieldEnd(); + oprot.writeFieldBegin(CREATED_AT_FIELD_DESC); + oprot.writeI64(struct.createdAt); + oprot.writeFieldEnd(); + if (struct.createdBy != null) { + oprot.writeFieldBegin(CREATED_BY_FIELD_DESC); + oprot.writeString(struct.createdBy); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(PUBLISHED_FIELD_DESC); + oprot.writeBool(struct.published); + oprot.writeFieldEnd(); + if (struct.type != null) { + oprot.writeFieldBegin(TYPE_FIELD_DESC); + oprot.writeString(struct.type); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(DEFAULT_COLUMNS_FIELD_DESC); + oprot.writeI16(struct.defaultColumns); + oprot.writeFieldEnd(); + if (struct.content != null) { + oprot.writeFieldBegin(CONTENT_FIELD_DESC); + struct.content.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class ContentTupleSchemeFactory implements SchemeFactory { + public ContentTupleScheme getScheme() { + return new ContentTupleScheme(); + } + } + + private static class ContentTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, Content struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.id); + oprot.writeString(struct.title); + oprot.writeString(struct.updatedBy); + oprot.writeI64(struct.updatedAt); + oprot.writeI64(struct.createdAt); + oprot.writeString(struct.createdBy); + oprot.writeBool(struct.published); + oprot.writeString(struct.type); + oprot.writeI16(struct.defaultColumns); + struct.content.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, Content struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.id = iprot.readString(); + struct.setIdIsSet(true); + struct.title = iprot.readString(); + struct.setTitleIsSet(true); + struct.updatedBy = iprot.readString(); + struct.setUpdatedByIsSet(true); + struct.updatedAt = iprot.readI64(); + struct.setUpdatedAtIsSet(true); + struct.createdAt = iprot.readI64(); + struct.setCreatedAtIsSet(true); + struct.createdBy = iprot.readString(); + struct.setCreatedByIsSet(true); + struct.published = iprot.readBool(); + struct.setPublishedIsSet(true); + struct.type = iprot.readString(); + struct.setTypeIsSet(true); + struct.defaultColumns = iprot.readI16(); + struct.setDefaultColumnsIsSet(true); + struct.content = new ItemContent(); + struct.content.read(iprot); + struct.setContentIsSet(true); + } + } + +} + diff --git a/generated/gen-java/tenfour/ItemContent.java b/generated/gen-java/tenfour/ItemContent.java new file mode 100644 index 0000000..6400dd5 --- /dev/null +++ b/generated/gen-java/tenfour/ItemContent.java @@ -0,0 +1,309 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package tenfour; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +public class ItemContent extends org.apache.thrift.TUnion { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ItemContent"); + private static final org.apache.thrift.protocol.TField QUIZ_FIELD_DESC = new org.apache.thrift.protocol.TField("quiz", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + QUIZ((short)1, "quiz"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // QUIZ + return QUIZ; + 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.QUIZ, new org.apache.thrift.meta_data.FieldMetaData("quiz", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "QuizContent"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ItemContent.class, metaDataMap); + } + + public ItemContent() { + super(); + } + + public ItemContent(_Fields setField, Object value) { + super(setField, value); + } + + public ItemContent(ItemContent other) { + super(other); + } + public ItemContent deepCopy() { + return new ItemContent(this); + } + + public static ItemContent quiz(QuizContent value) { + ItemContent x = new ItemContent(); + x.setQuiz(value); + return x; + } + + + @Override + protected void checkType(_Fields setField, Object value) throws ClassCastException { + switch (setField) { + case QUIZ: + if (value instanceof QuizContent) { + break; + } + throw new ClassCastException("Was expecting value of type QuizContent for field 'quiz', but got " + value.getClass().getSimpleName()); + default: + throw new IllegalArgumentException("Unknown field id " + setField); + } + } + + @Override + protected 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 QUIZ: + if (field.type == QUIZ_FIELD_DESC.type) { + QuizContent quiz; + quiz = new QuizContent(); + quiz.read(iprot); + return quiz; + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + return null; + } + default: + throw new 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 QUIZ: + QuizContent quiz = (QuizContent)value_; + quiz.write(oprot); + return; + default: + throw new IllegalStateException("Cannot write union with unknown field " + setField_); + } + } + + @Override + protected 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 QUIZ: + QuizContent quiz; + quiz = new QuizContent(); + quiz.read(iprot); + return quiz; + default: + throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!"); + } + } else { + throw new 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 QUIZ: + QuizContent quiz = (QuizContent)value_; + quiz.write(oprot); + return; + default: + throw new IllegalStateException("Cannot write union with unknown field " + setField_); + } + } + + @Override + protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) { + switch (setField) { + case QUIZ: + return QUIZ_FIELD_DESC; + default: + throw new 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); + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + + public QuizContent getQuiz() { + if (getSetField() == _Fields.QUIZ) { + return (QuizContent)getFieldValue(); + } else { + throw new RuntimeException("Cannot get field 'quiz' because union is currently set to " + getFieldDesc(getSetField()).name); + } + } + + public void setQuiz(QuizContent value) { + if (value == null) throw new NullPointerException(); + setField_ = _Fields.QUIZ; + value_ = value; + } + + public boolean isSetQuiz() { + return setField_ == _Fields.QUIZ; + } + + + public boolean equals(Object other) { + if (other instanceof ItemContent) { + return equals((ItemContent)other); + } else { + return false; + } + } + + public boolean equals(ItemContent other) { + return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue()); + } + + @Override + public int compareTo(ItemContent 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() { + List list = new ArrayList(); + list.add(this.getClass().getName()); + org.apache.thrift.TFieldIdEnum setField = getSetField(); + if (setField != null) { + list.add(setField.getThriftFieldId()); + 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, 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); + } + } + + +} diff --git a/generated/gen-java/tenfour/Question.java b/generated/gen-java/tenfour/Question.java new file mode 100644 index 0000000..99ec7fb --- /dev/null +++ b/generated/gen-java/tenfour/Question.java @@ -0,0 +1,701 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package tenfour; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +public class Question implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Question"); + + private static final org.apache.thrift.protocol.TField QUESTION_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("questionText", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField ASSETS_FIELD_DESC = new org.apache.thrift.protocol.TField("assets", org.apache.thrift.protocol.TType.LIST, (short)2); + private static final org.apache.thrift.protocol.TField ANSWERS_FIELD_DESC = new org.apache.thrift.protocol.TField("answers", org.apache.thrift.protocol.TType.LIST, (short)3); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new QuestionStandardSchemeFactory()); + schemes.put(TupleScheme.class, new QuestionTupleSchemeFactory()); + } + + public String questionText; // required + public List assets; // required + public List answers; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + QUESTION_TEXT((short)1, "questionText"), + ASSETS((short)2, "assets"), + ANSWERS((short)3, "answers"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // QUESTION_TEXT + return QUESTION_TEXT; + case 2: // ASSETS + return ASSETS; + case 3: // ANSWERS + return ANSWERS; + 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.QUESTION_TEXT, new org.apache.thrift.meta_data.FieldMetaData("questionText", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.ASSETS, new org.apache.thrift.meta_data.FieldMetaData("assets", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "Asset")))); + tmpMap.put(_Fields.ANSWERS, new org.apache.thrift.meta_data.FieldMetaData("answers", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "Answer")))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Question.class, metaDataMap); + } + + public Question() { + } + + public Question( + String questionText, + List assets, + List answers) + { + this(); + this.questionText = questionText; + this.assets = assets; + this.answers = answers; + } + + /** + * Performs a deep copy on other. + */ + public Question(Question other) { + if (other.isSetQuestionText()) { + this.questionText = other.questionText; + } + if (other.isSetAssets()) { + List __this__assets = new ArrayList(other.assets.size()); + for (Asset other_element : other.assets) { + __this__assets.add(other_element); + } + this.assets = __this__assets; + } + if (other.isSetAnswers()) { + List __this__answers = new ArrayList(other.answers.size()); + for (Answer other_element : other.answers) { + __this__answers.add(other_element); + } + this.answers = __this__answers; + } + } + + public Question deepCopy() { + return new Question(this); + } + + @Override + public void clear() { + this.questionText = null; + this.assets = null; + this.answers = null; + } + + public String getQuestionText() { + return this.questionText; + } + + public Question setQuestionText(String questionText) { + this.questionText = questionText; + return this; + } + + public void unsetQuestionText() { + this.questionText = null; + } + + /** Returns true if field questionText is set (has been assigned a value) and false otherwise */ + public boolean isSetQuestionText() { + return this.questionText != null; + } + + public void setQuestionTextIsSet(boolean value) { + if (!value) { + this.questionText = null; + } + } + + public int getAssetsSize() { + return (this.assets == null) ? 0 : this.assets.size(); + } + + public java.util.Iterator getAssetsIterator() { + return (this.assets == null) ? null : this.assets.iterator(); + } + + public void addToAssets(Asset elem) { + if (this.assets == null) { + this.assets = new ArrayList(); + } + this.assets.add(elem); + } + + public List getAssets() { + return this.assets; + } + + public Question setAssets(List assets) { + this.assets = assets; + return this; + } + + public void unsetAssets() { + this.assets = null; + } + + /** Returns true if field assets is set (has been assigned a value) and false otherwise */ + public boolean isSetAssets() { + return this.assets != null; + } + + public void setAssetsIsSet(boolean value) { + if (!value) { + this.assets = null; + } + } + + public int getAnswersSize() { + return (this.answers == null) ? 0 : this.answers.size(); + } + + public java.util.Iterator getAnswersIterator() { + return (this.answers == null) ? null : this.answers.iterator(); + } + + public void addToAnswers(Answer elem) { + if (this.answers == null) { + this.answers = new ArrayList(); + } + this.answers.add(elem); + } + + public List getAnswers() { + return this.answers; + } + + public Question setAnswers(List answers) { + this.answers = answers; + return this; + } + + public void unsetAnswers() { + this.answers = null; + } + + /** Returns true if field answers is set (has been assigned a value) and false otherwise */ + public boolean isSetAnswers() { + return this.answers != null; + } + + public void setAnswersIsSet(boolean value) { + if (!value) { + this.answers = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case QUESTION_TEXT: + if (value == null) { + unsetQuestionText(); + } else { + setQuestionText((String)value); + } + break; + + case ASSETS: + if (value == null) { + unsetAssets(); + } else { + setAssets((List)value); + } + break; + + case ANSWERS: + if (value == null) { + unsetAnswers(); + } else { + setAnswers((List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case QUESTION_TEXT: + return getQuestionText(); + + case ASSETS: + return getAssets(); + + case ANSWERS: + return getAnswers(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case QUESTION_TEXT: + return isSetQuestionText(); + case ASSETS: + return isSetAssets(); + case ANSWERS: + return isSetAnswers(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof Question) + return this.equals((Question)that); + return false; + } + + public boolean equals(Question that) { + if (that == null) + return false; + + boolean this_present_questionText = true && this.isSetQuestionText(); + boolean that_present_questionText = true && that.isSetQuestionText(); + if (this_present_questionText || that_present_questionText) { + if (!(this_present_questionText && that_present_questionText)) + return false; + if (!this.questionText.equals(that.questionText)) + return false; + } + + boolean this_present_assets = true && this.isSetAssets(); + boolean that_present_assets = true && that.isSetAssets(); + if (this_present_assets || that_present_assets) { + if (!(this_present_assets && that_present_assets)) + return false; + if (!this.assets.equals(that.assets)) + return false; + } + + boolean this_present_answers = true && this.isSetAnswers(); + boolean that_present_answers = true && that.isSetAnswers(); + if (this_present_answers || that_present_answers) { + if (!(this_present_answers && that_present_answers)) + return false; + if (!this.answers.equals(that.answers)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_questionText = true && (isSetQuestionText()); + list.add(present_questionText); + if (present_questionText) + list.add(questionText); + + boolean present_assets = true && (isSetAssets()); + list.add(present_assets); + if (present_assets) + list.add(assets); + + boolean present_answers = true && (isSetAnswers()); + list.add(present_answers); + if (present_answers) + list.add(answers); + + return list.hashCode(); + } + + @Override + public int compareTo(Question other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetQuestionText()).compareTo(other.isSetQuestionText()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetQuestionText()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.questionText, other.questionText); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetAssets()).compareTo(other.isSetAssets()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetAssets()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.assets, other.assets); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetAnswers()).compareTo(other.isSetAnswers()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetAnswers()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.answers, other.answers); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("Question("); + boolean first = true; + + sb.append("questionText:"); + if (this.questionText == null) { + sb.append("null"); + } else { + sb.append(this.questionText); + } + first = false; + if (!first) sb.append(", "); + sb.append("assets:"); + if (this.assets == null) { + sb.append("null"); + } else { + sb.append(this.assets); + } + first = false; + if (!first) sb.append(", "); + sb.append("answers:"); + if (this.answers == null) { + sb.append("null"); + } else { + sb.append(this.answers); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (questionText == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'questionText' was not present! Struct: " + toString()); + } + if (assets == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'assets' was not present! Struct: " + toString()); + } + if (answers == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'answers' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + 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, 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); + } + } + + private static class QuestionStandardSchemeFactory implements SchemeFactory { + public QuestionStandardScheme getScheme() { + return new QuestionStandardScheme(); + } + } + + private static class QuestionStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, Question struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // QUESTION_TEXT + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.questionText = iprot.readString(); + struct.setQuestionTextIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // ASSETS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list16 = iprot.readListBegin(); + struct.assets = new ArrayList(_list16.size); + Asset _elem17; + for (int _i18 = 0; _i18 < _list16.size; ++_i18) + { + _elem17 = new Asset(); + _elem17.read(iprot); + struct.assets.add(_elem17); + } + iprot.readListEnd(); + } + struct.setAssetsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // ANSWERS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list19 = iprot.readListBegin(); + struct.answers = new ArrayList(_list19.size); + Answer _elem20; + for (int _i21 = 0; _i21 < _list19.size; ++_i21) + { + _elem20 = new Answer(); + _elem20.read(iprot); + struct.answers.add(_elem20); + } + iprot.readListEnd(); + } + struct.setAnswersIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, Question struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.questionText != null) { + oprot.writeFieldBegin(QUESTION_TEXT_FIELD_DESC); + oprot.writeString(struct.questionText); + oprot.writeFieldEnd(); + } + if (struct.assets != null) { + oprot.writeFieldBegin(ASSETS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.assets.size())); + for (Asset _iter22 : struct.assets) + { + _iter22.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.answers != null) { + oprot.writeFieldBegin(ANSWERS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.answers.size())); + for (Answer _iter23 : struct.answers) + { + _iter23.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class QuestionTupleSchemeFactory implements SchemeFactory { + public QuestionTupleScheme getScheme() { + return new QuestionTupleScheme(); + } + } + + private static class QuestionTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, Question struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.questionText); + { + oprot.writeI32(struct.assets.size()); + for (Asset _iter24 : struct.assets) + { + _iter24.write(oprot); + } + } + { + oprot.writeI32(struct.answers.size()); + for (Answer _iter25 : struct.answers) + { + _iter25.write(oprot); + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, Question struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.questionText = iprot.readString(); + struct.setQuestionTextIsSet(true); + { + org.apache.thrift.protocol.TList _list26 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.assets = new ArrayList(_list26.size); + Asset _elem27; + for (int _i28 = 0; _i28 < _list26.size; ++_i28) + { + _elem27 = new Asset(); + _elem27.read(iprot); + struct.assets.add(_elem27); + } + } + struct.setAssetsIsSet(true); + { + org.apache.thrift.protocol.TList _list29 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.answers = new ArrayList(_list29.size); + Answer _elem30; + for (int _i31 = 0; _i31 < _list29.size; ++_i31) + { + _elem30 = new Answer(); + _elem30.read(iprot); + struct.answers.add(_elem30); + } + } + struct.setAnswersIsSet(true); + } + } + +} + diff --git a/generated/gen-java/tenfour/QuizContent.java b/generated/gen-java/tenfour/QuizContent.java new file mode 100644 index 0000000..d92fc7f --- /dev/null +++ b/generated/gen-java/tenfour/QuizContent.java @@ -0,0 +1,548 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package tenfour; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +public class QuizContent implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("QuizContent"); + + private static final org.apache.thrift.protocol.TField QUESTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("questions", org.apache.thrift.protocol.TType.LIST, (short)1); + private static final org.apache.thrift.protocol.TField RESULT_GROUPS_FIELD_DESC = new org.apache.thrift.protocol.TField("resultGroups", org.apache.thrift.protocol.TType.STRUCT, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new QuizContentStandardSchemeFactory()); + schemes.put(TupleScheme.class, new QuizContentTupleSchemeFactory()); + } + + public List questions; // required + public ResultGroups resultGroups; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + QUESTIONS((short)1, "questions"), + RESULT_GROUPS((short)2, "resultGroups"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // QUESTIONS + return QUESTIONS; + case 2: // RESULT_GROUPS + return RESULT_GROUPS; + 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.QUESTIONS, new org.apache.thrift.meta_data.FieldMetaData("questions", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "Question")))); + tmpMap.put(_Fields.RESULT_GROUPS, new org.apache.thrift.meta_data.FieldMetaData("resultGroups", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "ResultGroups"))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(QuizContent.class, metaDataMap); + } + + public QuizContent() { + } + + public QuizContent( + List questions, + ResultGroups resultGroups) + { + this(); + this.questions = questions; + this.resultGroups = resultGroups; + } + + /** + * Performs a deep copy on other. + */ + public QuizContent(QuizContent other) { + if (other.isSetQuestions()) { + List __this__questions = new ArrayList(other.questions.size()); + for (Question other_element : other.questions) { + __this__questions.add(other_element); + } + this.questions = __this__questions; + } + if (other.isSetResultGroups()) { + this.resultGroups = other.resultGroups; + } + } + + public QuizContent deepCopy() { + return new QuizContent(this); + } + + @Override + public void clear() { + this.questions = null; + this.resultGroups = null; + } + + public int getQuestionsSize() { + return (this.questions == null) ? 0 : this.questions.size(); + } + + public java.util.Iterator getQuestionsIterator() { + return (this.questions == null) ? null : this.questions.iterator(); + } + + public void addToQuestions(Question elem) { + if (this.questions == null) { + this.questions = new ArrayList(); + } + this.questions.add(elem); + } + + public List getQuestions() { + return this.questions; + } + + public QuizContent setQuestions(List questions) { + this.questions = questions; + return this; + } + + public void unsetQuestions() { + this.questions = null; + } + + /** Returns true if field questions is set (has been assigned a value) and false otherwise */ + public boolean isSetQuestions() { + return this.questions != null; + } + + public void setQuestionsIsSet(boolean value) { + if (!value) { + this.questions = null; + } + } + + public ResultGroups getResultGroups() { + return this.resultGroups; + } + + public QuizContent setResultGroups(ResultGroups resultGroups) { + this.resultGroups = resultGroups; + return this; + } + + public void unsetResultGroups() { + this.resultGroups = null; + } + + /** Returns true if field resultGroups is set (has been assigned a value) and false otherwise */ + public boolean isSetResultGroups() { + return this.resultGroups != null; + } + + public void setResultGroupsIsSet(boolean value) { + if (!value) { + this.resultGroups = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case QUESTIONS: + if (value == null) { + unsetQuestions(); + } else { + setQuestions((List)value); + } + break; + + case RESULT_GROUPS: + if (value == null) { + unsetResultGroups(); + } else { + setResultGroups((ResultGroups)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case QUESTIONS: + return getQuestions(); + + case RESULT_GROUPS: + return getResultGroups(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case QUESTIONS: + return isSetQuestions(); + case RESULT_GROUPS: + return isSetResultGroups(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof QuizContent) + return this.equals((QuizContent)that); + return false; + } + + public boolean equals(QuizContent that) { + if (that == null) + return false; + + boolean this_present_questions = true && this.isSetQuestions(); + boolean that_present_questions = true && that.isSetQuestions(); + if (this_present_questions || that_present_questions) { + if (!(this_present_questions && that_present_questions)) + return false; + if (!this.questions.equals(that.questions)) + return false; + } + + boolean this_present_resultGroups = true && this.isSetResultGroups(); + boolean that_present_resultGroups = true && that.isSetResultGroups(); + if (this_present_resultGroups || that_present_resultGroups) { + if (!(this_present_resultGroups && that_present_resultGroups)) + return false; + if (!this.resultGroups.equals(that.resultGroups)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_questions = true && (isSetQuestions()); + list.add(present_questions); + if (present_questions) + list.add(questions); + + boolean present_resultGroups = true && (isSetResultGroups()); + list.add(present_resultGroups); + if (present_resultGroups) + list.add(resultGroups); + + return list.hashCode(); + } + + @Override + public int compareTo(QuizContent other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetQuestions()).compareTo(other.isSetQuestions()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetQuestions()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.questions, other.questions); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetResultGroups()).compareTo(other.isSetResultGroups()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetResultGroups()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.resultGroups, other.resultGroups); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("QuizContent("); + boolean first = true; + + sb.append("questions:"); + if (this.questions == null) { + sb.append("null"); + } else { + sb.append(this.questions); + } + first = false; + if (!first) sb.append(", "); + sb.append("resultGroups:"); + if (this.resultGroups == null) { + sb.append("null"); + } else { + sb.append(this.resultGroups); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (questions == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'questions' was not present! Struct: " + toString()); + } + if (resultGroups == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'resultGroups' was not present! Struct: " + toString()); + } + // check for sub-struct validity + } + + 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, 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); + } + } + + private static class QuizContentStandardSchemeFactory implements SchemeFactory { + public QuizContentStandardScheme getScheme() { + return new QuizContentStandardScheme(); + } + } + + private static class QuizContentStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, QuizContent struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // QUESTIONS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); + struct.questions = new ArrayList(_list0.size); + Question _elem1; + for (int _i2 = 0; _i2 < _list0.size; ++_i2) + { + _elem1 = new Question(); + _elem1.read(iprot); + struct.questions.add(_elem1); + } + iprot.readListEnd(); + } + struct.setQuestionsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // RESULT_GROUPS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.resultGroups = new ResultGroups(); + struct.resultGroups.read(iprot); + struct.setResultGroupsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, QuizContent struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.questions != null) { + oprot.writeFieldBegin(QUESTIONS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.questions.size())); + for (Question _iter3 : struct.questions) + { + _iter3.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.resultGroups != null) { + oprot.writeFieldBegin(RESULT_GROUPS_FIELD_DESC); + struct.resultGroups.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class QuizContentTupleSchemeFactory implements SchemeFactory { + public QuizContentTupleScheme getScheme() { + return new QuizContentTupleScheme(); + } + } + + private static class QuizContentTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, QuizContent struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + { + oprot.writeI32(struct.questions.size()); + for (Question _iter4 : struct.questions) + { + _iter4.write(oprot); + } + } + struct.resultGroups.write(oprot); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, QuizContent struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + { + org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.questions = new ArrayList(_list5.size); + Question _elem6; + for (int _i7 = 0; _i7 < _list5.size; ++_i7) + { + _elem6 = new Question(); + _elem6.read(iprot); + struct.questions.add(_elem6); + } + } + struct.setQuestionsIsSet(true); + struct.resultGroups = new ResultGroups(); + struct.resultGroups.read(iprot); + struct.setResultGroupsIsSet(true); + } + } + +} + diff --git a/generated/gen-java/tenfour/ResultGroup.java b/generated/gen-java/tenfour/ResultGroup.java new file mode 100644 index 0000000..65256f4 --- /dev/null +++ b/generated/gen-java/tenfour/ResultGroup.java @@ -0,0 +1,592 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package tenfour; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +public class ResultGroup implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ResultGroup"); + + private static final org.apache.thrift.protocol.TField TITLE_FIELD_DESC = new org.apache.thrift.protocol.TField("title", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField SHARE_FIELD_DESC = new org.apache.thrift.protocol.TField("share", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField MIN_SCORE_FIELD_DESC = new org.apache.thrift.protocol.TField("minScore", org.apache.thrift.protocol.TType.I16, (short)3); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new ResultGroupStandardSchemeFactory()); + schemes.put(TupleScheme.class, new ResultGroupTupleSchemeFactory()); + } + + public String title; // required + public String share; // required + public short minScore; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + TITLE((short)1, "title"), + SHARE((short)2, "share"), + MIN_SCORE((short)3, "minScore"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // TITLE + return TITLE; + case 2: // SHARE + return SHARE; + case 3: // MIN_SCORE + return MIN_SCORE; + 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __MINSCORE_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.TITLE, new org.apache.thrift.meta_data.FieldMetaData("title", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.SHARE, new org.apache.thrift.meta_data.FieldMetaData("share", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.MIN_SCORE, new org.apache.thrift.meta_data.FieldMetaData("minScore", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ResultGroup.class, metaDataMap); + } + + public ResultGroup() { + } + + public ResultGroup( + String title, + String share, + short minScore) + { + this(); + this.title = title; + this.share = share; + this.minScore = minScore; + setMinScoreIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public ResultGroup(ResultGroup other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetTitle()) { + this.title = other.title; + } + if (other.isSetShare()) { + this.share = other.share; + } + this.minScore = other.minScore; + } + + public ResultGroup deepCopy() { + return new ResultGroup(this); + } + + @Override + public void clear() { + this.title = null; + this.share = null; + setMinScoreIsSet(false); + this.minScore = 0; + } + + public String getTitle() { + return this.title; + } + + public ResultGroup setTitle(String title) { + this.title = title; + return this; + } + + public void unsetTitle() { + this.title = null; + } + + /** Returns true if field title is set (has been assigned a value) and false otherwise */ + public boolean isSetTitle() { + return this.title != null; + } + + public void setTitleIsSet(boolean value) { + if (!value) { + this.title = null; + } + } + + public String getShare() { + return this.share; + } + + public ResultGroup setShare(String share) { + this.share = share; + return this; + } + + public void unsetShare() { + this.share = null; + } + + /** Returns true if field share is set (has been assigned a value) and false otherwise */ + public boolean isSetShare() { + return this.share != null; + } + + public void setShareIsSet(boolean value) { + if (!value) { + this.share = null; + } + } + + public short getMinScore() { + return this.minScore; + } + + public ResultGroup setMinScore(short minScore) { + this.minScore = minScore; + setMinScoreIsSet(true); + return this; + } + + public void unsetMinScore() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __MINSCORE_ISSET_ID); + } + + /** Returns true if field minScore is set (has been assigned a value) and false otherwise */ + public boolean isSetMinScore() { + return EncodingUtils.testBit(__isset_bitfield, __MINSCORE_ISSET_ID); + } + + public void setMinScoreIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __MINSCORE_ISSET_ID, value); + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case TITLE: + if (value == null) { + unsetTitle(); + } else { + setTitle((String)value); + } + break; + + case SHARE: + if (value == null) { + unsetShare(); + } else { + setShare((String)value); + } + break; + + case MIN_SCORE: + if (value == null) { + unsetMinScore(); + } else { + setMinScore((Short)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case TITLE: + return getTitle(); + + case SHARE: + return getShare(); + + case MIN_SCORE: + return Short.valueOf(getMinScore()); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case TITLE: + return isSetTitle(); + case SHARE: + return isSetShare(); + case MIN_SCORE: + return isSetMinScore(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof ResultGroup) + return this.equals((ResultGroup)that); + return false; + } + + public boolean equals(ResultGroup that) { + if (that == null) + return false; + + boolean this_present_title = true && this.isSetTitle(); + boolean that_present_title = true && that.isSetTitle(); + if (this_present_title || that_present_title) { + if (!(this_present_title && that_present_title)) + return false; + if (!this.title.equals(that.title)) + return false; + } + + boolean this_present_share = true && this.isSetShare(); + boolean that_present_share = true && that.isSetShare(); + if (this_present_share || that_present_share) { + if (!(this_present_share && that_present_share)) + return false; + if (!this.share.equals(that.share)) + return false; + } + + boolean this_present_minScore = true; + boolean that_present_minScore = true; + if (this_present_minScore || that_present_minScore) { + if (!(this_present_minScore && that_present_minScore)) + return false; + if (this.minScore != that.minScore) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_title = true && (isSetTitle()); + list.add(present_title); + if (present_title) + list.add(title); + + boolean present_share = true && (isSetShare()); + list.add(present_share); + if (present_share) + list.add(share); + + boolean present_minScore = true; + list.add(present_minScore); + if (present_minScore) + list.add(minScore); + + return list.hashCode(); + } + + @Override + public int compareTo(ResultGroup other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetTitle()).compareTo(other.isSetTitle()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTitle()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.title, other.title); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetShare()).compareTo(other.isSetShare()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetShare()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.share, other.share); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMinScore()).compareTo(other.isSetMinScore()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMinScore()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.minScore, other.minScore); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ResultGroup("); + boolean first = true; + + sb.append("title:"); + if (this.title == null) { + sb.append("null"); + } else { + sb.append(this.title); + } + first = false; + if (!first) sb.append(", "); + sb.append("share:"); + if (this.share == null) { + sb.append("null"); + } else { + sb.append(this.share); + } + first = false; + if (!first) sb.append(", "); + sb.append("minScore:"); + sb.append(this.minScore); + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (title == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'title' was not present! Struct: " + toString()); + } + if (share == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'share' was not present! Struct: " + toString()); + } + // alas, we cannot check 'minScore' because it's a primitive and you chose the non-beans generator. + // check for sub-struct validity + } + + 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, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class ResultGroupStandardSchemeFactory implements SchemeFactory { + public ResultGroupStandardScheme getScheme() { + return new ResultGroupStandardScheme(); + } + } + + private static class ResultGroupStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, ResultGroup struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // TITLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.title = iprot.readString(); + struct.setTitleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // SHARE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.share = iprot.readString(); + struct.setShareIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // MIN_SCORE + if (schemeField.type == org.apache.thrift.protocol.TType.I16) { + struct.minScore = iprot.readI16(); + struct.setMinScoreIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + if (!struct.isSetMinScore()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'minScore' was not found in serialized data! Struct: " + toString()); + } + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, ResultGroup struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.title != null) { + oprot.writeFieldBegin(TITLE_FIELD_DESC); + oprot.writeString(struct.title); + oprot.writeFieldEnd(); + } + if (struct.share != null) { + oprot.writeFieldBegin(SHARE_FIELD_DESC); + oprot.writeString(struct.share); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(MIN_SCORE_FIELD_DESC); + oprot.writeI16(struct.minScore); + oprot.writeFieldEnd(); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class ResultGroupTupleSchemeFactory implements SchemeFactory { + public ResultGroupTupleScheme getScheme() { + return new ResultGroupTupleScheme(); + } + } + + private static class ResultGroupTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, ResultGroup struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + oprot.writeString(struct.title); + oprot.writeString(struct.share); + oprot.writeI16(struct.minScore); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, ResultGroup struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + struct.title = iprot.readString(); + struct.setTitleIsSet(true); + struct.share = iprot.readString(); + struct.setShareIsSet(true); + struct.minScore = iprot.readI16(); + struct.setMinScoreIsSet(true); + } + } + +} + diff --git a/generated/gen-java/tenfour/ResultGroups.java b/generated/gen-java/tenfour/ResultGroups.java new file mode 100644 index 0000000..fecf7dc --- /dev/null +++ b/generated/gen-java/tenfour/ResultGroups.java @@ -0,0 +1,545 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package tenfour; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +public class ResultGroups implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ResultGroups"); + + private static final org.apache.thrift.protocol.TField GROUPS_FIELD_DESC = new org.apache.thrift.protocol.TField("groups", org.apache.thrift.protocol.TType.LIST, (short)1); + private static final org.apache.thrift.protocol.TField REVEAL_AT_END_FIELD_DESC = new org.apache.thrift.protocol.TField("revealAtEnd", org.apache.thrift.protocol.TType.BOOL, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new ResultGroupsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new ResultGroupsTupleSchemeFactory()); + } + + public List groups; // required + public boolean revealAtEnd; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + GROUPS((short)1, "groups"), + REVEAL_AT_END((short)2, "revealAtEnd"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // GROUPS + return GROUPS; + case 2: // REVEAL_AT_END + return REVEAL_AT_END; + 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __REVEALATEND_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.GROUPS, new org.apache.thrift.meta_data.FieldMetaData("groups", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "ResultGroup")))); + tmpMap.put(_Fields.REVEAL_AT_END, new org.apache.thrift.meta_data.FieldMetaData("revealAtEnd", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ResultGroups.class, metaDataMap); + } + + public ResultGroups() { + } + + public ResultGroups( + List groups, + boolean revealAtEnd) + { + this(); + this.groups = groups; + this.revealAtEnd = revealAtEnd; + setRevealAtEndIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public ResultGroups(ResultGroups other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetGroups()) { + List __this__groups = new ArrayList(other.groups.size()); + for (ResultGroup other_element : other.groups) { + __this__groups.add(other_element); + } + this.groups = __this__groups; + } + this.revealAtEnd = other.revealAtEnd; + } + + public ResultGroups deepCopy() { + return new ResultGroups(this); + } + + @Override + public void clear() { + this.groups = null; + setRevealAtEndIsSet(false); + this.revealAtEnd = false; + } + + public int getGroupsSize() { + return (this.groups == null) ? 0 : this.groups.size(); + } + + public java.util.Iterator getGroupsIterator() { + return (this.groups == null) ? null : this.groups.iterator(); + } + + public void addToGroups(ResultGroup elem) { + if (this.groups == null) { + this.groups = new ArrayList(); + } + this.groups.add(elem); + } + + public List getGroups() { + return this.groups; + } + + public ResultGroups setGroups(List groups) { + this.groups = groups; + return this; + } + + public void unsetGroups() { + this.groups = null; + } + + /** Returns true if field groups is set (has been assigned a value) and false otherwise */ + public boolean isSetGroups() { + return this.groups != null; + } + + public void setGroupsIsSet(boolean value) { + if (!value) { + this.groups = null; + } + } + + public boolean isRevealAtEnd() { + return this.revealAtEnd; + } + + public ResultGroups setRevealAtEnd(boolean revealAtEnd) { + this.revealAtEnd = revealAtEnd; + setRevealAtEndIsSet(true); + return this; + } + + public void unsetRevealAtEnd() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __REVEALATEND_ISSET_ID); + } + + /** Returns true if field revealAtEnd is set (has been assigned a value) and false otherwise */ + public boolean isSetRevealAtEnd() { + return EncodingUtils.testBit(__isset_bitfield, __REVEALATEND_ISSET_ID); + } + + public void setRevealAtEndIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __REVEALATEND_ISSET_ID, value); + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case GROUPS: + if (value == null) { + unsetGroups(); + } else { + setGroups((List)value); + } + break; + + case REVEAL_AT_END: + if (value == null) { + unsetRevealAtEnd(); + } else { + setRevealAtEnd((Boolean)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case GROUPS: + return getGroups(); + + case REVEAL_AT_END: + return Boolean.valueOf(isRevealAtEnd()); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case GROUPS: + return isSetGroups(); + case REVEAL_AT_END: + return isSetRevealAtEnd(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof ResultGroups) + return this.equals((ResultGroups)that); + return false; + } + + public boolean equals(ResultGroups that) { + if (that == null) + return false; + + boolean this_present_groups = true && this.isSetGroups(); + boolean that_present_groups = true && that.isSetGroups(); + if (this_present_groups || that_present_groups) { + if (!(this_present_groups && that_present_groups)) + return false; + if (!this.groups.equals(that.groups)) + return false; + } + + boolean this_present_revealAtEnd = true; + boolean that_present_revealAtEnd = true; + if (this_present_revealAtEnd || that_present_revealAtEnd) { + if (!(this_present_revealAtEnd && that_present_revealAtEnd)) + return false; + if (this.revealAtEnd != that.revealAtEnd) + return false; + } + + return true; + } + + @Override + public int hashCode() { + List list = new ArrayList(); + + boolean present_groups = true && (isSetGroups()); + list.add(present_groups); + if (present_groups) + list.add(groups); + + boolean present_revealAtEnd = true; + list.add(present_revealAtEnd); + if (present_revealAtEnd) + list.add(revealAtEnd); + + return list.hashCode(); + } + + @Override + public int compareTo(ResultGroups other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetGroups()).compareTo(other.isSetGroups()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetGroups()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.groups, other.groups); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetRevealAtEnd()).compareTo(other.isSetRevealAtEnd()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetRevealAtEnd()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.revealAtEnd, other.revealAtEnd); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ResultGroups("); + boolean first = true; + + sb.append("groups:"); + if (this.groups == null) { + sb.append("null"); + } else { + sb.append(this.groups); + } + first = false; + if (!first) sb.append(", "); + sb.append("revealAtEnd:"); + sb.append(this.revealAtEnd); + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (groups == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'groups' was not present! Struct: " + toString()); + } + // alas, we cannot check 'revealAtEnd' because it's a primitive and you chose the non-beans generator. + // check for sub-struct validity + } + + 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, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class ResultGroupsStandardSchemeFactory implements SchemeFactory { + public ResultGroupsStandardScheme getScheme() { + return new ResultGroupsStandardScheme(); + } + } + + private static class ResultGroupsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, ResultGroups struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // GROUPS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list8 = iprot.readListBegin(); + struct.groups = new ArrayList(_list8.size); + ResultGroup _elem9; + for (int _i10 = 0; _i10 < _list8.size; ++_i10) + { + _elem9 = new ResultGroup(); + _elem9.read(iprot); + struct.groups.add(_elem9); + } + iprot.readListEnd(); + } + struct.setGroupsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // REVEAL_AT_END + if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { + struct.revealAtEnd = iprot.readBool(); + struct.setRevealAtEndIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + if (!struct.isSetRevealAtEnd()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'revealAtEnd' was not found in serialized data! Struct: " + toString()); + } + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, ResultGroups struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.groups != null) { + oprot.writeFieldBegin(GROUPS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.groups.size())); + for (ResultGroup _iter11 : struct.groups) + { + _iter11.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(REVEAL_AT_END_FIELD_DESC); + oprot.writeBool(struct.revealAtEnd); + oprot.writeFieldEnd(); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class ResultGroupsTupleSchemeFactory implements SchemeFactory { + public ResultGroupsTupleScheme getScheme() { + return new ResultGroupsTupleScheme(); + } + } + + private static class ResultGroupsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, ResultGroups struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + { + oprot.writeI32(struct.groups.size()); + for (ResultGroup _iter12 : struct.groups) + { + _iter12.write(oprot); + } + } + oprot.writeBool(struct.revealAtEnd); + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, ResultGroups struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + { + org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.groups = new ArrayList(_list13.size); + ResultGroup _elem14; + for (int _i15 = 0; _i15 < _list13.size; ++_i15) + { + _elem14 = new ResultGroup(); + _elem14.read(iprot); + struct.groups.add(_elem14); + } + } + struct.setGroupsIsSet(true); + struct.revealAtEnd = iprot.readBool(); + struct.setRevealAtEndIsSet(true); + } + } + +} + diff --git a/generated/gen-nodejs/quiz_types.js b/generated/gen-nodejs/quiz_types.js new file mode 100644 index 0000000..fd80e76 --- /dev/null +++ b/generated/gen-nodejs/quiz_types.js @@ -0,0 +1,891 @@ +// +// Autogenerated by Thrift Compiler (0.9.2) +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// +var thrift = require('thrift'); +var Thrift = thrift.Thrift; +var Q = thrift.Q; + +var shared_ttypes = require('./shared_types') + + +var ttypes = module.exports = {}; +if (typeof tenfour === 'undefined') { + tenfour = {}; +} +tenfour.Content = module.exports.Content = function(args) { + this.id = null; + this.title = null; + this.updatedBy = null; + this.updatedAt = null; + this.createdAt = null; + this.createdBy = null; + this.published = null; + this.type = null; + this.defaultColumns = null; + this.content = null; + if (args) { + if (args.id !== undefined) { + this.id = args.id; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field id is unset!'); + } + if (args.title !== undefined) { + this.title = args.title; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field title is unset!'); + } + if (args.updatedBy !== undefined) { + this.updatedBy = args.updatedBy; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field updatedBy is unset!'); + } + if (args.updatedAt !== undefined) { + this.updatedAt = args.updatedAt; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field updatedAt is unset!'); + } + if (args.createdAt !== undefined) { + this.createdAt = args.createdAt; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field createdAt is unset!'); + } + if (args.createdBy !== undefined) { + this.createdBy = args.createdBy; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field createdBy is unset!'); + } + if (args.published !== undefined) { + this.published = args.published; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field published is unset!'); + } + if (args.type !== undefined) { + this.type = args.type; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field type is unset!'); + } + if (args.defaultColumns !== undefined) { + this.defaultColumns = args.defaultColumns; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field defaultColumns is unset!'); + } + if (args.content !== undefined) { + this.content = args.content; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field content is unset!'); + } + } +}; +tenfour.Content.prototype = {}; +tenfour.Content.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRING) { + this.id = input.readString(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.STRING) { + this.title = input.readString(); + } else { + input.skip(ftype); + } + break; + case 3: + if (ftype == Thrift.Type.STRING) { + this.updatedBy = input.readString(); + } else { + input.skip(ftype); + } + break; + case 4: + if (ftype == Thrift.Type.I64) { + this.updatedAt = input.readI64(); + } else { + input.skip(ftype); + } + break; + case 5: + if (ftype == Thrift.Type.I64) { + this.createdAt = input.readI64(); + } else { + input.skip(ftype); + } + break; + case 6: + if (ftype == Thrift.Type.STRING) { + this.createdBy = input.readString(); + } else { + input.skip(ftype); + } + break; + case 7: + if (ftype == Thrift.Type.BOOL) { + this.published = input.readBool(); + } else { + input.skip(ftype); + } + break; + case 8: + if (ftype == Thrift.Type.STRING) { + this.type = input.readString(); + } else { + input.skip(ftype); + } + break; + case 9: + if (ftype == Thrift.Type.I16) { + this.defaultColumns = input.readI16(); + } else { + input.skip(ftype); + } + break; + case 10: + if (ftype == Thrift.Type.STRUCT) { + this.content = new ttypes.ItemContent(); + this.content.read(input); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +tenfour.Content.prototype.write = function(output) { + output.writeStructBegin('Content'); + if (this.id !== null && this.id !== undefined) { + output.writeFieldBegin('id', Thrift.Type.STRING, 1); + output.writeString(this.id); + output.writeFieldEnd(); + } + if (this.title !== null && this.title !== undefined) { + output.writeFieldBegin('title', Thrift.Type.STRING, 2); + output.writeString(this.title); + output.writeFieldEnd(); + } + if (this.updatedBy !== null && this.updatedBy !== undefined) { + output.writeFieldBegin('updatedBy', Thrift.Type.STRING, 3); + output.writeString(this.updatedBy); + output.writeFieldEnd(); + } + if (this.updatedAt !== null && this.updatedAt !== undefined) { + output.writeFieldBegin('updatedAt', Thrift.Type.I64, 4); + output.writeI64(this.updatedAt); + output.writeFieldEnd(); + } + if (this.createdAt !== null && this.createdAt !== undefined) { + output.writeFieldBegin('createdAt', Thrift.Type.I64, 5); + output.writeI64(this.createdAt); + output.writeFieldEnd(); + } + if (this.createdBy !== null && this.createdBy !== undefined) { + output.writeFieldBegin('createdBy', Thrift.Type.STRING, 6); + output.writeString(this.createdBy); + output.writeFieldEnd(); + } + if (this.published !== null && this.published !== undefined) { + output.writeFieldBegin('published', Thrift.Type.BOOL, 7); + output.writeBool(this.published); + output.writeFieldEnd(); + } + if (this.type !== null && this.type !== undefined) { + output.writeFieldBegin('type', Thrift.Type.STRING, 8); + output.writeString(this.type); + output.writeFieldEnd(); + } + if (this.defaultColumns !== null && this.defaultColumns !== undefined) { + output.writeFieldBegin('defaultColumns', Thrift.Type.I16, 9); + output.writeI16(this.defaultColumns); + output.writeFieldEnd(); + } + if (this.content !== null && this.content !== undefined) { + output.writeFieldBegin('content', Thrift.Type.STRUCT, 10); + this.content.write(output); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +tenfour.ItemContent = module.exports.ItemContent = function(args) { + this.quiz = null; + if (args) { + if (args.quiz !== undefined) { + this.quiz = args.quiz; + } + } +}; +tenfour.ItemContent.prototype = {}; +tenfour.ItemContent.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRUCT) { + this.quiz = new ttypes.QuizContent(); + this.quiz.read(input); + } else { + input.skip(ftype); + } + break; + case 0: + input.skip(ftype); + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +tenfour.ItemContent.prototype.write = function(output) { + output.writeStructBegin('ItemContent'); + if (this.quiz !== null && this.quiz !== undefined) { + output.writeFieldBegin('quiz', Thrift.Type.STRUCT, 1); + this.quiz.write(output); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +tenfour.QuizContent = module.exports.QuizContent = function(args) { + this.questions = null; + this.resultGroups = null; + if (args) { + if (args.questions !== undefined) { + this.questions = args.questions; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field questions is unset!'); + } + if (args.resultGroups !== undefined) { + this.resultGroups = args.resultGroups; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field resultGroups is unset!'); + } + } +}; +tenfour.QuizContent.prototype = {}; +tenfour.QuizContent.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.LIST) { + var _size0 = 0; + var _rtmp34; + this.questions = []; + var _etype3 = 0; + _rtmp34 = input.readListBegin(); + _etype3 = _rtmp34.etype; + _size0 = _rtmp34.size; + for (var _i5 = 0; _i5 < _size0; ++_i5) + { + var elem6 = null; + elem6 = new ttypes.Question(); + elem6.read(input); + this.questions.push(elem6); + } + input.readListEnd(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.STRUCT) { + this.resultGroups = new ttypes.ResultGroups(); + this.resultGroups.read(input); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +tenfour.QuizContent.prototype.write = function(output) { + output.writeStructBegin('QuizContent'); + if (this.questions !== null && this.questions !== undefined) { + output.writeFieldBegin('questions', Thrift.Type.LIST, 1); + output.writeListBegin(Thrift.Type.STRUCT, this.questions.length); + for (var iter7 in this.questions) + { + if (this.questions.hasOwnProperty(iter7)) + { + iter7 = this.questions[iter7]; + iter7.write(output); + } + } + output.writeListEnd(); + output.writeFieldEnd(); + } + if (this.resultGroups !== null && this.resultGroups !== undefined) { + output.writeFieldBegin('resultGroups', Thrift.Type.STRUCT, 2); + this.resultGroups.write(output); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +tenfour.ResultGroups = module.exports.ResultGroups = function(args) { + this.groups = null; + this.revealAtEnd = null; + if (args) { + if (args.groups !== undefined) { + this.groups = args.groups; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field groups is unset!'); + } + if (args.revealAtEnd !== undefined) { + this.revealAtEnd = args.revealAtEnd; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field revealAtEnd is unset!'); + } + } +}; +tenfour.ResultGroups.prototype = {}; +tenfour.ResultGroups.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.LIST) { + var _size8 = 0; + var _rtmp312; + this.groups = []; + var _etype11 = 0; + _rtmp312 = input.readListBegin(); + _etype11 = _rtmp312.etype; + _size8 = _rtmp312.size; + for (var _i13 = 0; _i13 < _size8; ++_i13) + { + var elem14 = null; + elem14 = new ttypes.ResultGroup(); + elem14.read(input); + this.groups.push(elem14); + } + input.readListEnd(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.BOOL) { + this.revealAtEnd = input.readBool(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +tenfour.ResultGroups.prototype.write = function(output) { + output.writeStructBegin('ResultGroups'); + if (this.groups !== null && this.groups !== undefined) { + output.writeFieldBegin('groups', Thrift.Type.LIST, 1); + output.writeListBegin(Thrift.Type.STRUCT, this.groups.length); + for (var iter15 in this.groups) + { + if (this.groups.hasOwnProperty(iter15)) + { + iter15 = this.groups[iter15]; + iter15.write(output); + } + } + output.writeListEnd(); + output.writeFieldEnd(); + } + if (this.revealAtEnd !== null && this.revealAtEnd !== undefined) { + output.writeFieldBegin('revealAtEnd', Thrift.Type.BOOL, 2); + output.writeBool(this.revealAtEnd); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +tenfour.ResultGroup = module.exports.ResultGroup = function(args) { + this.title = null; + this.share = null; + this.minScore = null; + if (args) { + if (args.title !== undefined) { + this.title = args.title; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field title is unset!'); + } + if (args.share !== undefined) { + this.share = args.share; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field share is unset!'); + } + if (args.minScore !== undefined) { + this.minScore = args.minScore; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field minScore is unset!'); + } + } +}; +tenfour.ResultGroup.prototype = {}; +tenfour.ResultGroup.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRING) { + this.title = input.readString(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.STRING) { + this.share = input.readString(); + } else { + input.skip(ftype); + } + break; + case 3: + if (ftype == Thrift.Type.I16) { + this.minScore = input.readI16(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +tenfour.ResultGroup.prototype.write = function(output) { + output.writeStructBegin('ResultGroup'); + if (this.title !== null && this.title !== undefined) { + output.writeFieldBegin('title', Thrift.Type.STRING, 1); + output.writeString(this.title); + output.writeFieldEnd(); + } + if (this.share !== null && this.share !== undefined) { + output.writeFieldBegin('share', Thrift.Type.STRING, 2); + output.writeString(this.share); + output.writeFieldEnd(); + } + if (this.minScore !== null && this.minScore !== undefined) { + output.writeFieldBegin('minScore', Thrift.Type.I16, 3); + output.writeI16(this.minScore); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +tenfour.Question = module.exports.Question = function(args) { + this.questionText = null; + this.assets = null; + this.answers = null; + if (args) { + if (args.questionText !== undefined) { + this.questionText = args.questionText; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field questionText is unset!'); + } + if (args.assets !== undefined) { + this.assets = args.assets; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field assets is unset!'); + } + if (args.answers !== undefined) { + this.answers = args.answers; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field answers is unset!'); + } + } +}; +tenfour.Question.prototype = {}; +tenfour.Question.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRING) { + this.questionText = input.readString(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.LIST) { + var _size16 = 0; + var _rtmp320; + this.assets = []; + var _etype19 = 0; + _rtmp320 = input.readListBegin(); + _etype19 = _rtmp320.etype; + _size16 = _rtmp320.size; + for (var _i21 = 0; _i21 < _size16; ++_i21) + { + var elem22 = null; + elem22 = new ttypes.Asset(); + elem22.read(input); + this.assets.push(elem22); + } + input.readListEnd(); + } else { + input.skip(ftype); + } + break; + case 3: + if (ftype == Thrift.Type.LIST) { + var _size23 = 0; + var _rtmp327; + this.answers = []; + var _etype26 = 0; + _rtmp327 = input.readListBegin(); + _etype26 = _rtmp327.etype; + _size23 = _rtmp327.size; + for (var _i28 = 0; _i28 < _size23; ++_i28) + { + var elem29 = null; + elem29 = new ttypes.Answer(); + elem29.read(input); + this.answers.push(elem29); + } + input.readListEnd(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +tenfour.Question.prototype.write = function(output) { + output.writeStructBegin('Question'); + if (this.questionText !== null && this.questionText !== undefined) { + output.writeFieldBegin('questionText', Thrift.Type.STRING, 1); + output.writeString(this.questionText); + output.writeFieldEnd(); + } + if (this.assets !== null && this.assets !== undefined) { + output.writeFieldBegin('assets', Thrift.Type.LIST, 2); + output.writeListBegin(Thrift.Type.STRUCT, this.assets.length); + for (var iter30 in this.assets) + { + if (this.assets.hasOwnProperty(iter30)) + { + iter30 = this.assets[iter30]; + iter30.write(output); + } + } + output.writeListEnd(); + output.writeFieldEnd(); + } + if (this.answers !== null && this.answers !== undefined) { + output.writeFieldBegin('answers', Thrift.Type.LIST, 3); + output.writeListBegin(Thrift.Type.STRUCT, this.answers.length); + for (var iter31 in this.answers) + { + if (this.answers.hasOwnProperty(iter31)) + { + iter31 = this.answers[iter31]; + iter31.write(output); + } + } + output.writeListEnd(); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +tenfour.Answer = module.exports.Answer = function(args) { + this.answerText = null; + this.assets = null; + this.correct = null; + this.revealText = null; + if (args) { + if (args.answerText !== undefined) { + this.answerText = args.answerText; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field answerText is unset!'); + } + if (args.assets !== undefined) { + this.assets = args.assets; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field assets is unset!'); + } + if (args.correct !== undefined) { + this.correct = args.correct; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field correct is unset!'); + } + if (args.revealText !== undefined) { + this.revealText = args.revealText; + } + } +}; +tenfour.Answer.prototype = {}; +tenfour.Answer.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRING) { + this.answerText = input.readString(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.LIST) { + var _size32 = 0; + var _rtmp336; + this.assets = []; + var _etype35 = 0; + _rtmp336 = input.readListBegin(); + _etype35 = _rtmp336.etype; + _size32 = _rtmp336.size; + for (var _i37 = 0; _i37 < _size32; ++_i37) + { + var elem38 = null; + elem38 = new ttypes.Asset(); + elem38.read(input); + this.assets.push(elem38); + } + input.readListEnd(); + } else { + input.skip(ftype); + } + break; + case 3: + if (ftype == Thrift.Type.BOOL) { + this.correct = input.readBool(); + } else { + input.skip(ftype); + } + break; + case 4: + if (ftype == Thrift.Type.STRING) { + this.revealText = input.readString(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +tenfour.Answer.prototype.write = function(output) { + output.writeStructBegin('Answer'); + if (this.answerText !== null && this.answerText !== undefined) { + output.writeFieldBegin('answerText', Thrift.Type.STRING, 1); + output.writeString(this.answerText); + output.writeFieldEnd(); + } + if (this.assets !== null && this.assets !== undefined) { + output.writeFieldBegin('assets', Thrift.Type.LIST, 2); + output.writeListBegin(Thrift.Type.STRUCT, this.assets.length); + for (var iter39 in this.assets) + { + if (this.assets.hasOwnProperty(iter39)) + { + iter39 = this.assets[iter39]; + iter39.write(output); + } + } + output.writeListEnd(); + output.writeFieldEnd(); + } + if (this.correct !== null && this.correct !== undefined) { + output.writeFieldBegin('correct', Thrift.Type.BOOL, 3); + output.writeBool(this.correct); + output.writeFieldEnd(); + } + if (this.revealText !== null && this.revealText !== undefined) { + output.writeFieldBegin('revealText', Thrift.Type.STRING, 4); + output.writeString(this.revealText); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +tenfour.Asset = module.exports.Asset = function(args) { + this.type = null; + this.data = null; + if (args) { + if (args.type !== undefined) { + this.type = args.type; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field type is unset!'); + } + if (args.data !== undefined) { + this.data = args.data; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field data is unset!'); + } + } +}; +tenfour.Asset.prototype = {}; +tenfour.Asset.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRING) { + this.type = input.readString(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.STRING) { + this.data = input.readString(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +tenfour.Asset.prototype.write = function(output) { + output.writeStructBegin('Asset'); + if (this.type !== null && this.type !== undefined) { + output.writeFieldBegin('type', Thrift.Type.STRING, 1); + output.writeString(this.type); + output.writeFieldEnd(); + } + if (this.data !== null && this.data !== undefined) { + output.writeFieldBegin('data', Thrift.Type.STRING, 2); + output.writeString(this.data); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + diff --git a/generated/gen-nodejs/shared_types.js b/generated/gen-nodejs/shared_types.js new file mode 100644 index 0000000..69278bd --- /dev/null +++ b/generated/gen-nodejs/shared_types.js @@ -0,0 +1,11 @@ +// +// Autogenerated by Thrift Compiler (0.9.2) +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// +var thrift = require('thrift'); +var Thrift = thrift.Thrift; +var Q = thrift.Q; + + +var ttypes = module.exports = {}; diff --git a/thrift/atoms/quiz.thrift b/thrift/atoms/quiz.thrift new file mode 100644 index 0000000..aac2f05 --- /dev/null +++ b/thrift/atoms/quiz.thrift @@ -0,0 +1,61 @@ +namespace * tenfour + +include "../shared.thrift" + +/** date times are reprsented as i64 - epoch millis */ +typedef i64 DateTime + +struct Content { + // do we need to store the ID, seeing as it is replicated(?) in the + // content-atom wrapping? + 1 : required string id + 2 : required string title + 3 : required string updatedBy + 4 : required DateTime updatedAt + 5 : required DateTime createdAt + 6 : required string createdBy + 7 : required bool published + 8 : required string type + 9 : required i16 defaultColumns + 10 : required ItemContent content +} + +// will vary depending on item's type +union ItemContent { + 1: QuizContent quiz +} + +struct QuizContent { + 1: required list questions + 2: required ResultGroups resultGroups +} + +struct ResultGroups { + 1: required list groups + 2: required bool revealAtEnd +} + +struct ResultGroup { + 1: required string title + 2: required string share + 3: required i16 minScore +} + +struct Question { + 1: required string questionText + 2: required list assets + 3: required list answers +} + +struct Answer { + 1: required string answerText + 2: required list assets + 3: required bool correct + 4: optional string revealText +} + +struct Asset { + 1: required string type + /* what type is this? currently assuming opaque json */ + 2: required shared.OpaqueJson data +} diff --git a/thrift/shared.thrift b/thrift/shared.thrift new file mode 100644 index 0000000..d16b0e7 --- /dev/null +++ b/thrift/shared.thrift @@ -0,0 +1 @@ +typedef string OpaqueJson From 649fdf291ed5d53aeae3d320e26f0709d187b4dc Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Wed, 26 Aug 2015 13:37:33 +0100 Subject: [PATCH 02/18] include the quiz/tenfour stuff in the main.js --- generated/gen-nodejs/{quiz_types.js => tenfour_types.js} | 0 js/main.js | 3 ++- package.json | 2 +- thrift/atoms/{quiz.thrift => tenfour.thrift} | 0 4 files changed, 3 insertions(+), 2 deletions(-) rename generated/gen-nodejs/{quiz_types.js => tenfour_types.js} (100%) rename thrift/atoms/{quiz.thrift => tenfour.thrift} (100%) diff --git a/generated/gen-nodejs/quiz_types.js b/generated/gen-nodejs/tenfour_types.js similarity index 100% rename from generated/gen-nodejs/quiz_types.js rename to generated/gen-nodejs/tenfour_types.js diff --git a/js/main.js b/js/main.js index f359855..ed1d226 100644 --- a/js/main.js +++ b/js/main.js @@ -1 +1,2 @@ -exports.events = require('../thrift/gen-nodejs/events_types'); +exports.eventTypes = require('../generated/gen-nodejs/events_types'); +exports.tenfourTypes = require('../generated/gen-nodejs/tenfour_types'); diff --git a/package.json b/package.json index 66859f2..f6154f3 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,6 @@ "license": "Apache-2.0", "files": [ "js/main.js", - "thrift/gen-nodejs" + "generated/gen-nodejs" ] } diff --git a/thrift/atoms/quiz.thrift b/thrift/atoms/tenfour.thrift similarity index 100% rename from thrift/atoms/quiz.thrift rename to thrift/atoms/tenfour.thrift From e079ea92852194828c4925ef15f757997eb8e405 Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Fri, 28 Aug 2015 10:00:04 +0100 Subject: [PATCH 03/18] tweaks to the build script --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index ab4196e..e283ff5 100755 --- a/build.sh +++ b/build.sh @@ -53,7 +53,7 @@ function thrift { LANG_OPTS=${LANGUAGES[@]/#/--gen } - for file in $THRIFT_FILES + for file in "${THRIFT_FILES[@]}" do $THRIFT_CMD $THRIFT_VERBOSE --recurse -o ${OUT_DIR} $LANG_OPTS "$file" done From 3e65b055f480d2a1ea2985c423cb6e9b8f4173ad Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Fri, 28 Aug 2015 10:04:30 +0100 Subject: [PATCH 04/18] document required/optional fields --- thrift/atoms/tenfour.thrift | 4 ++-- thrift/events.thrift | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/thrift/atoms/tenfour.thrift b/thrift/atoms/tenfour.thrift index aac2f05..22e5c04 100644 --- a/thrift/atoms/tenfour.thrift +++ b/thrift/atoms/tenfour.thrift @@ -15,8 +15,8 @@ struct Content { 5 : required DateTime createdAt 6 : required string createdBy 7 : required bool published - 8 : required string type - 9 : required i16 defaultColumns + 8 : required string quizType + 9 : optional i16 defaultColumns 10 : required ItemContent content } diff --git a/thrift/events.thrift b/thrift/events.thrift index 1d80793..c36add1 100644 --- a/thrift/events.thrift +++ b/thrift/events.thrift @@ -1,3 +1,5 @@ +include "contentatom.thrift" + typedef string ContentAtomID enum EventType { PUBLISH, UPDATE, TAKEDOWN } @@ -8,15 +10,15 @@ struct ContentAtomEvent { * across all content-atoms of any type (an alternative model might * be to have the `type+id` be unique) */ - 1: ContentAtomID id + 1: required ContentAtomID id // this is a canonical place from which the current version of the //content atom's data can be downloaded. - 2: string url + 2: required string url - 3: string atomType + 3: required string atomType - 4: EventType eventType + 4: required EventType eventType - 5: string data // a string contain an opaque, JSON-encoded, data blob + 5: required contentatom.ContentAtom data } From 5a9cd8a1f8e182bb30df6fbd68489ffe69c8a10c Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Fri, 28 Aug 2015 10:05:25 +0100 Subject: [PATCH 05/18] update generated code --- generated/gen-java/ContentAtom.java | 307 +++++++++++++++++++ generated/gen-java/ContentAtomEvent.java | 119 +++---- generated/gen-java/tenfour/Answer.java | 2 +- generated/gen-java/tenfour/Asset.java | 2 +- generated/gen-java/tenfour/Content.java | 164 +++++----- generated/gen-java/tenfour/Question.java | 2 +- generated/gen-java/tenfour/QuizContent.java | 2 +- generated/gen-java/tenfour/ResultGroup.java | 2 +- generated/gen-java/tenfour/ResultGroups.java | 2 +- generated/gen-nodejs/content-atom_types.js | 67 ++++ generated/gen-nodejs/contentatom_types.js | 67 ++++ generated/gen-nodejs/events_types.js | 21 +- generated/gen-nodejs/tenfour_types.js | 18 +- 13 files changed, 607 insertions(+), 168 deletions(-) create mode 100644 generated/gen-java/ContentAtom.java create mode 100644 generated/gen-nodejs/content-atom_types.js create mode 100644 generated/gen-nodejs/contentatom_types.js diff --git a/generated/gen-java/ContentAtom.java b/generated/gen-java/ContentAtom.java new file mode 100644 index 0000000..287f034 --- /dev/null +++ b/generated/gen-java/ContentAtom.java @@ -0,0 +1,307 @@ +/** + * Autogenerated by Thrift Compiler (0.9.2) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import org.apache.thrift.async.AsyncMethodCallback; +import org.apache.thrift.server.AbstractNonblockingServer.*; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import javax.annotation.Generated; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) +public class ContentAtom extends org.apache.thrift.TUnion { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ContentAtom"); + private static final org.apache.thrift.protocol.TField TENFOUR_FIELD_DESC = new org.apache.thrift.protocol.TField("tenfour", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + TENFOUR((short)1, "tenfour"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // TENFOUR + return TENFOUR; + 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.TENFOUR, new org.apache.thrift.meta_data.FieldMetaData("tenfour", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, tenfour.Content.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ContentAtom.class, metaDataMap); + } + + public ContentAtom() { + super(); + } + + public ContentAtom(_Fields setField, Object value) { + super(setField, value); + } + + public ContentAtom(ContentAtom other) { + super(other); + } + public ContentAtom deepCopy() { + return new ContentAtom(this); + } + + public static ContentAtom tenfour(tenfour.Content value) { + ContentAtom x = new ContentAtom(); + x.setTenfour(value); + return x; + } + + + @Override + protected void checkType(_Fields setField, Object value) throws ClassCastException { + switch (setField) { + case TENFOUR: + if (value instanceof tenfour.Content) { + break; + } + throw new ClassCastException("Was expecting value of type tenfour.Content for field 'tenfour', but got " + value.getClass().getSimpleName()); + default: + throw new IllegalArgumentException("Unknown field id " + setField); + } + } + + @Override + protected 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 TENFOUR: + if (field.type == TENFOUR_FIELD_DESC.type) { + tenfour.Content tenfour; + tenfour = new tenfour.Content(); + tenfour.read(iprot); + return tenfour; + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + return null; + } + default: + throw new 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 TENFOUR: + tenfour.Content tenfour = (tenfour.Content)value_; + tenfour.write(oprot); + return; + default: + throw new IllegalStateException("Cannot write union with unknown field " + setField_); + } + } + + @Override + protected 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 TENFOUR: + tenfour.Content tenfour; + tenfour = new tenfour.Content(); + tenfour.read(iprot); + return tenfour; + default: + throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!"); + } + } else { + throw new 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 TENFOUR: + tenfour.Content tenfour = (tenfour.Content)value_; + tenfour.write(oprot); + return; + default: + throw new IllegalStateException("Cannot write union with unknown field " + setField_); + } + } + + @Override + protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) { + switch (setField) { + case TENFOUR: + return TENFOUR_FIELD_DESC; + default: + throw new 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); + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + + public tenfour.Content getTenfour() { + if (getSetField() == _Fields.TENFOUR) { + return (tenfour.Content)getFieldValue(); + } else { + throw new RuntimeException("Cannot get field 'tenfour' because union is currently set to " + getFieldDesc(getSetField()).name); + } + } + + public void setTenfour(tenfour.Content value) { + if (value == null) throw new NullPointerException(); + setField_ = _Fields.TENFOUR; + value_ = value; + } + + public boolean isSetTenfour() { + return setField_ == _Fields.TENFOUR; + } + + + public boolean equals(Object other) { + if (other instanceof ContentAtom) { + return equals((ContentAtom)other); + } else { + return false; + } + } + + public boolean equals(ContentAtom other) { + return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue()); + } + + @Override + public int compareTo(ContentAtom 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() { + List list = new ArrayList(); + list.add(this.getClass().getName()); + org.apache.thrift.TFieldIdEnum setField = getSetField(); + if (setField != null) { + list.add(setField.getThriftFieldId()); + 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, 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); + } + } + + +} diff --git a/generated/gen-java/ContentAtomEvent.java b/generated/gen-java/ContentAtomEvent.java index 628de6e..cc449d2 100644 --- a/generated/gen-java/ContentAtomEvent.java +++ b/generated/gen-java/ContentAtomEvent.java @@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") public class ContentAtomEvent implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ContentAtomEvent"); @@ -40,7 +40,7 @@ public class ContentAtomEvent implements org.apache.thrift.TBase, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { @@ -56,7 +56,7 @@ public class ContentAtomEvent implements org.apache.thrift.TBase metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT, + tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , "ContentAtomID"))); - tmpMap.put(_Fields.URL, new org.apache.thrift.meta_data.FieldMetaData("url", org.apache.thrift.TFieldRequirementType.DEFAULT, + tmpMap.put(_Fields.URL, new org.apache.thrift.meta_data.FieldMetaData("url", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.ATOM_TYPE, new org.apache.thrift.meta_data.FieldMetaData("atomType", org.apache.thrift.TFieldRequirementType.DEFAULT, + tmpMap.put(_Fields.ATOM_TYPE, new org.apache.thrift.meta_data.FieldMetaData("atomType", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.EVENT_TYPE, new org.apache.thrift.meta_data.FieldMetaData("eventType", org.apache.thrift.TFieldRequirementType.DEFAULT, + tmpMap.put(_Fields.EVENT_TYPE, new org.apache.thrift.meta_data.FieldMetaData("eventType", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, EventType.class))); - tmpMap.put(_Fields.DATA, new org.apache.thrift.meta_data.FieldMetaData("data", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.DATA, new org.apache.thrift.meta_data.FieldMetaData("data", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ContentAtom.class))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ContentAtomEvent.class, metaDataMap); } @@ -158,7 +158,7 @@ public ContentAtomEvent( String url, String atomType, EventType eventType, - String data) + ContentAtom data) { this(); this.id = id; @@ -185,7 +185,7 @@ public ContentAtomEvent(ContentAtomEvent other) { this.eventType = other.eventType; } if (other.isSetData()) { - this.data = other.data; + this.data = new ContentAtom(other.data); } } @@ -306,11 +306,11 @@ public void setEventTypeIsSet(boolean value) { } } - public String getData() { + public ContentAtom getData() { return this.data; } - public ContentAtomEvent setData(String data) { + public ContentAtomEvent setData(ContentAtom data) { this.data = data; return this; } @@ -368,7 +368,7 @@ public void setFieldValue(_Fields field, Object value) { if (value == null) { unsetData(); } else { - setData((String)value); + setData((ContentAtom)value); } break; @@ -633,6 +633,21 @@ public String toString() { public void validate() throws org.apache.thrift.TException { // check for required fields + if (id == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'id' was not present! Struct: " + toString()); + } + if (url == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'url' was not present! Struct: " + toString()); + } + if (atomType == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'atomType' was not present! Struct: " + toString()); + } + if (eventType == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'eventType' was not present! Struct: " + toString()); + } + if (data == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'data' was not present! Struct: " + toString()); + } // check for sub-struct validity } @@ -703,8 +718,9 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, ContentAtomEvent st } break; case 5: // DATA - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.data = iprot.readString(); + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.data = new ContentAtom(); + struct.data.read(iprot); struct.setDataIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); @@ -747,7 +763,7 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, ContentAtomEvent s } if (struct.data != null) { oprot.writeFieldBegin(DATA_FIELD_DESC); - oprot.writeString(struct.data); + struct.data.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); @@ -767,64 +783,27 @@ private static class ContentAtomEventTupleScheme extends TupleScheme, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Answer"); diff --git a/generated/gen-java/tenfour/Asset.java b/generated/gen-java/tenfour/Asset.java index 1994139..82dc759 100644 --- a/generated/gen-java/tenfour/Asset.java +++ b/generated/gen-java/tenfour/Asset.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") public class Asset implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Asset"); diff --git a/generated/gen-java/tenfour/Content.java b/generated/gen-java/tenfour/Content.java index 4546cb0..8e6c459 100644 --- a/generated/gen-java/tenfour/Content.java +++ b/generated/gen-java/tenfour/Content.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") public class Content implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Content"); @@ -45,7 +45,7 @@ public class Content implements org.apache.thrift.TBase metaDataMap; static { Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); @@ -174,9 +175,9 @@ public String getFieldName() { new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.PUBLISHED, new org.apache.thrift.meta_data.FieldMetaData("published", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); - tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED, + tmpMap.put(_Fields.QUIZ_TYPE, new org.apache.thrift.meta_data.FieldMetaData("quizType", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.DEFAULT_COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("defaultColumns", org.apache.thrift.TFieldRequirementType.REQUIRED, + tmpMap.put(_Fields.DEFAULT_COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("defaultColumns", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); tmpMap.put(_Fields.CONTENT, new org.apache.thrift.meta_data.FieldMetaData("content", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "ItemContent"))); @@ -195,8 +196,7 @@ public Content( long createdAt, String createdBy, boolean published, - String type, - short defaultColumns, + String quizType, ItemContent content) { this(); @@ -210,9 +210,7 @@ public Content( this.createdBy = createdBy; this.published = published; setPublishedIsSet(true); - this.type = type; - this.defaultColumns = defaultColumns; - setDefaultColumnsIsSet(true); + this.quizType = quizType; this.content = content; } @@ -236,8 +234,8 @@ public Content(Content other) { this.createdBy = other.createdBy; } this.published = other.published; - if (other.isSetType()) { - this.type = other.type; + if (other.isSetQuizType()) { + this.quizType = other.quizType; } this.defaultColumns = other.defaultColumns; if (other.isSetContent()) { @@ -261,7 +259,7 @@ public void clear() { this.createdBy = null; setPublishedIsSet(false); this.published = false; - this.type = null; + this.quizType = null; setDefaultColumnsIsSet(false); this.defaultColumns = 0; this.content = null; @@ -432,27 +430,27 @@ public void setPublishedIsSet(boolean value) { __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PUBLISHED_ISSET_ID, value); } - public String getType() { - return this.type; + public String getQuizType() { + return this.quizType; } - public Content setType(String type) { - this.type = type; + public Content setQuizType(String quizType) { + this.quizType = quizType; return this; } - public void unsetType() { - this.type = null; + public void unsetQuizType() { + this.quizType = null; } - /** Returns true if field type is set (has been assigned a value) and false otherwise */ - public boolean isSetType() { - return this.type != null; + /** Returns true if field quizType is set (has been assigned a value) and false otherwise */ + public boolean isSetQuizType() { + return this.quizType != null; } - public void setTypeIsSet(boolean value) { + public void setQuizTypeIsSet(boolean value) { if (!value) { - this.type = null; + this.quizType = null; } } @@ -561,11 +559,11 @@ public void setFieldValue(_Fields field, Object value) { } break; - case TYPE: + case QUIZ_TYPE: if (value == null) { - unsetType(); + unsetQuizType(); } else { - setType((String)value); + setQuizType((String)value); } break; @@ -611,8 +609,8 @@ public Object getFieldValue(_Fields field) { case PUBLISHED: return Boolean.valueOf(isPublished()); - case TYPE: - return getType(); + case QUIZ_TYPE: + return getQuizType(); case DEFAULT_COLUMNS: return Short.valueOf(getDefaultColumns()); @@ -645,8 +643,8 @@ public boolean isSet(_Fields field) { return isSetCreatedBy(); case PUBLISHED: return isSetPublished(); - case TYPE: - return isSetType(); + case QUIZ_TYPE: + return isSetQuizType(); case DEFAULT_COLUMNS: return isSetDefaultColumns(); case CONTENT: @@ -731,17 +729,17 @@ public boolean equals(Content that) { return false; } - boolean this_present_type = true && this.isSetType(); - boolean that_present_type = true && that.isSetType(); - if (this_present_type || that_present_type) { - if (!(this_present_type && that_present_type)) + boolean this_present_quizType = true && this.isSetQuizType(); + boolean that_present_quizType = true && that.isSetQuizType(); + if (this_present_quizType || that_present_quizType) { + if (!(this_present_quizType && that_present_quizType)) return false; - if (!this.type.equals(that.type)) + if (!this.quizType.equals(that.quizType)) return false; } - boolean this_present_defaultColumns = true; - boolean that_present_defaultColumns = true; + boolean this_present_defaultColumns = true && this.isSetDefaultColumns(); + boolean that_present_defaultColumns = true && that.isSetDefaultColumns(); if (this_present_defaultColumns || that_present_defaultColumns) { if (!(this_present_defaultColumns && that_present_defaultColumns)) return false; @@ -800,12 +798,12 @@ public int hashCode() { if (present_published) list.add(published); - boolean present_type = true && (isSetType()); - list.add(present_type); - if (present_type) - list.add(type); + boolean present_quizType = true && (isSetQuizType()); + list.add(present_quizType); + if (present_quizType) + list.add(quizType); - boolean present_defaultColumns = true; + boolean present_defaultColumns = true && (isSetDefaultColumns()); list.add(present_defaultColumns); if (present_defaultColumns) list.add(defaultColumns); @@ -896,12 +894,12 @@ public int compareTo(Content other) { return lastComparison; } } - lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType()); + lastComparison = Boolean.valueOf(isSetQuizType()).compareTo(other.isSetQuizType()); if (lastComparison != 0) { return lastComparison; } - if (isSetType()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type); + if (isSetQuizType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.quizType, other.quizType); if (lastComparison != 0) { return lastComparison; } @@ -990,17 +988,19 @@ public String toString() { sb.append(this.published); first = false; if (!first) sb.append(", "); - sb.append("type:"); - if (this.type == null) { + sb.append("quizType:"); + if (this.quizType == null) { sb.append("null"); } else { - sb.append(this.type); + sb.append(this.quizType); } first = false; - if (!first) sb.append(", "); - sb.append("defaultColumns:"); - sb.append(this.defaultColumns); - first = false; + if (isSetDefaultColumns()) { + if (!first) sb.append(", "); + sb.append("defaultColumns:"); + sb.append(this.defaultColumns); + first = false; + } if (!first) sb.append(", "); sb.append("content:"); if (this.content == null) { @@ -1030,10 +1030,9 @@ public void validate() throws org.apache.thrift.TException { throw new org.apache.thrift.protocol.TProtocolException("Required field 'createdBy' was not present! Struct: " + toString()); } // alas, we cannot check 'published' because it's a primitive and you chose the non-beans generator. - if (type == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' was not present! Struct: " + toString()); + if (quizType == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'quizType' was not present! Struct: " + toString()); } - // alas, we cannot check 'defaultColumns' because it's a primitive and you chose the non-beans generator. if (content == null) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'content' was not present! Struct: " + toString()); } @@ -1132,10 +1131,10 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, Content struct) thr org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; - case 8: // TYPE + case 8: // QUIZ_TYPE if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.type = iprot.readString(); - struct.setTypeIsSet(true); + struct.quizType = iprot.readString(); + struct.setQuizTypeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } @@ -1174,9 +1173,6 @@ public void read(org.apache.thrift.protocol.TProtocol iprot, Content struct) thr if (!struct.isSetPublished()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'published' was not found in serialized data! Struct: " + toString()); } - if (!struct.isSetDefaultColumns()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'defaultColumns' was not found in serialized data! Struct: " + toString()); - } struct.validate(); } @@ -1213,14 +1209,16 @@ public void write(org.apache.thrift.protocol.TProtocol oprot, Content struct) th oprot.writeFieldBegin(PUBLISHED_FIELD_DESC); oprot.writeBool(struct.published); oprot.writeFieldEnd(); - if (struct.type != null) { - oprot.writeFieldBegin(TYPE_FIELD_DESC); - oprot.writeString(struct.type); + if (struct.quizType != null) { + oprot.writeFieldBegin(QUIZ_TYPE_FIELD_DESC); + oprot.writeString(struct.quizType); + oprot.writeFieldEnd(); + } + if (struct.isSetDefaultColumns()) { + oprot.writeFieldBegin(DEFAULT_COLUMNS_FIELD_DESC); + oprot.writeI16(struct.defaultColumns); oprot.writeFieldEnd(); } - oprot.writeFieldBegin(DEFAULT_COLUMNS_FIELD_DESC); - oprot.writeI16(struct.defaultColumns); - oprot.writeFieldEnd(); if (struct.content != null) { oprot.writeFieldBegin(CONTENT_FIELD_DESC); struct.content.write(oprot); @@ -1250,9 +1248,16 @@ public void write(org.apache.thrift.protocol.TProtocol prot, Content struct) thr oprot.writeI64(struct.createdAt); oprot.writeString(struct.createdBy); oprot.writeBool(struct.published); - oprot.writeString(struct.type); - oprot.writeI16(struct.defaultColumns); + oprot.writeString(struct.quizType); struct.content.write(oprot); + BitSet optionals = new BitSet(); + if (struct.isSetDefaultColumns()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetDefaultColumns()) { + oprot.writeI16(struct.defaultColumns); + } } @Override @@ -1272,13 +1277,16 @@ public void read(org.apache.thrift.protocol.TProtocol prot, Content struct) thro struct.setCreatedByIsSet(true); struct.published = iprot.readBool(); struct.setPublishedIsSet(true); - struct.type = iprot.readString(); - struct.setTypeIsSet(true); - struct.defaultColumns = iprot.readI16(); - struct.setDefaultColumnsIsSet(true); + struct.quizType = iprot.readString(); + struct.setQuizTypeIsSet(true); struct.content = new ItemContent(); struct.content.read(iprot); struct.setContentIsSet(true); + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.defaultColumns = iprot.readI16(); + struct.setDefaultColumnsIsSet(true); + } } } diff --git a/generated/gen-java/tenfour/Question.java b/generated/gen-java/tenfour/Question.java index 99ec7fb..dd5a5dd 100644 --- a/generated/gen-java/tenfour/Question.java +++ b/generated/gen-java/tenfour/Question.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") public class Question implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Question"); diff --git a/generated/gen-java/tenfour/QuizContent.java b/generated/gen-java/tenfour/QuizContent.java index d92fc7f..157eadb 100644 --- a/generated/gen-java/tenfour/QuizContent.java +++ b/generated/gen-java/tenfour/QuizContent.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") public class QuizContent implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("QuizContent"); diff --git a/generated/gen-java/tenfour/ResultGroup.java b/generated/gen-java/tenfour/ResultGroup.java index 65256f4..62eced9 100644 --- a/generated/gen-java/tenfour/ResultGroup.java +++ b/generated/gen-java/tenfour/ResultGroup.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") public class ResultGroup implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ResultGroup"); diff --git a/generated/gen-java/tenfour/ResultGroups.java b/generated/gen-java/tenfour/ResultGroups.java index fecf7dc..a07713a 100644 --- a/generated/gen-java/tenfour/ResultGroups.java +++ b/generated/gen-java/tenfour/ResultGroups.java @@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-26") +@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") public class ResultGroups implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ResultGroups"); diff --git a/generated/gen-nodejs/content-atom_types.js b/generated/gen-nodejs/content-atom_types.js new file mode 100644 index 0000000..e778770 --- /dev/null +++ b/generated/gen-nodejs/content-atom_types.js @@ -0,0 +1,67 @@ +// +// Autogenerated by Thrift Compiler (0.9.2) +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// +var thrift = require('thrift'); +var Thrift = thrift.Thrift; +var Q = thrift.Q; + +var tenfour_ttypes = require('./tenfour_types') + + +var ttypes = module.exports = {}; +ContentAtom = module.exports.ContentAtom = function(args) { + this.tenfour = null; + if (args) { + if (args.tenfour !== undefined) { + this.tenfour = args.tenfour; + } + } +}; +ContentAtom.prototype = {}; +ContentAtom.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRUCT) { + this.tenfour = new tenfour_ttypes.Content(); + this.tenfour.read(input); + } else { + input.skip(ftype); + } + break; + case 0: + input.skip(ftype); + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +ContentAtom.prototype.write = function(output) { + output.writeStructBegin('ContentAtom'); + if (this.tenfour !== null && this.tenfour !== undefined) { + output.writeFieldBegin('tenfour', Thrift.Type.STRUCT, 1); + this.tenfour.write(output); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + diff --git a/generated/gen-nodejs/contentatom_types.js b/generated/gen-nodejs/contentatom_types.js new file mode 100644 index 0000000..e778770 --- /dev/null +++ b/generated/gen-nodejs/contentatom_types.js @@ -0,0 +1,67 @@ +// +// Autogenerated by Thrift Compiler (0.9.2) +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// +var thrift = require('thrift'); +var Thrift = thrift.Thrift; +var Q = thrift.Q; + +var tenfour_ttypes = require('./tenfour_types') + + +var ttypes = module.exports = {}; +ContentAtom = module.exports.ContentAtom = function(args) { + this.tenfour = null; + if (args) { + if (args.tenfour !== undefined) { + this.tenfour = args.tenfour; + } + } +}; +ContentAtom.prototype = {}; +ContentAtom.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRUCT) { + this.tenfour = new tenfour_ttypes.Content(); + this.tenfour.read(input); + } else { + input.skip(ftype); + } + break; + case 0: + input.skip(ftype); + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +ContentAtom.prototype.write = function(output) { + output.writeStructBegin('ContentAtom'); + if (this.tenfour !== null && this.tenfour !== undefined) { + output.writeFieldBegin('tenfour', Thrift.Type.STRUCT, 1); + this.tenfour.write(output); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + diff --git a/generated/gen-nodejs/events_types.js b/generated/gen-nodejs/events_types.js index 8a81622..e055127 100644 --- a/generated/gen-nodejs/events_types.js +++ b/generated/gen-nodejs/events_types.js @@ -7,6 +7,8 @@ var thrift = require('thrift'); var Thrift = thrift.Thrift; var Q = thrift.Q; +var contentatom_ttypes = require('./contentatom_types') + var ttypes = module.exports = {}; ttypes.EventType = { @@ -23,18 +25,28 @@ ContentAtomEvent = module.exports.ContentAtomEvent = function(args) { if (args) { if (args.id !== undefined) { this.id = args.id; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field id is unset!'); } if (args.url !== undefined) { this.url = args.url; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field url is unset!'); } if (args.atomType !== undefined) { this.atomType = args.atomType; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field atomType is unset!'); } if (args.eventType !== undefined) { this.eventType = args.eventType; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field eventType is unset!'); } if (args.data !== undefined) { this.data = args.data; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field data is unset!'); } } }; @@ -81,8 +93,9 @@ ContentAtomEvent.prototype.read = function(input) { } break; case 5: - if (ftype == Thrift.Type.STRING) { - this.data = input.readString(); + if (ftype == Thrift.Type.STRUCT) { + this.data = new contentatom_ttypes.ContentAtom(); + this.data.read(input); } else { input.skip(ftype); } @@ -119,8 +132,8 @@ ContentAtomEvent.prototype.write = function(output) { output.writeFieldEnd(); } if (this.data !== null && this.data !== undefined) { - output.writeFieldBegin('data', Thrift.Type.STRING, 5); - output.writeString(this.data); + output.writeFieldBegin('data', Thrift.Type.STRUCT, 5); + this.data.write(output); output.writeFieldEnd(); } output.writeFieldStop(); diff --git a/generated/gen-nodejs/tenfour_types.js b/generated/gen-nodejs/tenfour_types.js index fd80e76..bfe5021 100644 --- a/generated/gen-nodejs/tenfour_types.js +++ b/generated/gen-nodejs/tenfour_types.js @@ -22,7 +22,7 @@ tenfour.Content = module.exports.Content = function(args) { this.createdAt = null; this.createdBy = null; this.published = null; - this.type = null; + this.quizType = null; this.defaultColumns = null; this.content = null; if (args) { @@ -61,15 +61,13 @@ tenfour.Content = module.exports.Content = function(args) { } else { throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field published is unset!'); } - if (args.type !== undefined) { - this.type = args.type; + if (args.quizType !== undefined) { + this.quizType = args.quizType; } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field type is unset!'); + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field quizType is unset!'); } if (args.defaultColumns !== undefined) { this.defaultColumns = args.defaultColumns; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field defaultColumns is unset!'); } if (args.content !== undefined) { this.content = args.content; @@ -143,7 +141,7 @@ tenfour.Content.prototype.read = function(input) { break; case 8: if (ftype == Thrift.Type.STRING) { - this.type = input.readString(); + this.quizType = input.readString(); } else { input.skip(ftype); } @@ -209,9 +207,9 @@ tenfour.Content.prototype.write = function(output) { output.writeBool(this.published); output.writeFieldEnd(); } - if (this.type !== null && this.type !== undefined) { - output.writeFieldBegin('type', Thrift.Type.STRING, 8); - output.writeString(this.type); + if (this.quizType !== null && this.quizType !== undefined) { + output.writeFieldBegin('quizType', Thrift.Type.STRING, 8); + output.writeString(this.quizType); output.writeFieldEnd(); } if (this.defaultColumns !== null && this.defaultColumns !== undefined) { From 2686b61ebce959ca6138f89e163a89a65cb1f2a4 Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Fri, 28 Aug 2015 10:05:48 +0100 Subject: [PATCH 06/18] add types of content atom so they can fit into a union --- js/main.js | 1 + thrift/contentatom.thrift | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 thrift/contentatom.thrift diff --git a/js/main.js b/js/main.js index ed1d226..0156e5e 100644 --- a/js/main.js +++ b/js/main.js @@ -1,2 +1,3 @@ +exports.contentAtomTypes = require('../generated/gen-nodejs/contentatom_types'); exports.eventTypes = require('../generated/gen-nodejs/events_types'); exports.tenfourTypes = require('../generated/gen-nodejs/tenfour_types'); diff --git a/thrift/contentatom.thrift b/thrift/contentatom.thrift new file mode 100644 index 0000000..c94c0a1 --- /dev/null +++ b/thrift/contentatom.thrift @@ -0,0 +1,5 @@ +include "atoms/tenfour.thrift" + +union ContentAtom { + 1: tenfour.Content tenfour +} From 3eedf304da1be5693e6eb37f06fdbe96c588138b Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Fri, 28 Aug 2015 11:37:08 +0100 Subject: [PATCH 07/18] remove the url from the event type --- thrift/events.thrift | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/thrift/events.thrift b/thrift/events.thrift index c36add1..d21afa8 100644 --- a/thrift/events.thrift +++ b/thrift/events.thrift @@ -12,13 +12,9 @@ struct ContentAtomEvent { 1: required ContentAtomID id - // this is a canonical place from which the current version of the - //content atom's data can be downloaded. - 2: required string url + 2: required string atomType - 3: required string atomType - - 4: required EventType eventType + 3: required EventType eventType - 5: required contentatom.ContentAtom data + 4: required contentatom.ContentAtom data } From 6938ddefde20b75c10a042c967824c4ceed4283d Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Fri, 28 Aug 2015 11:38:42 +0100 Subject: [PATCH 08/18] dont build java code --- build.sh | 2 +- generated/gen-java/ContentAtom.java | 307 ----- generated/gen-java/ContentAtomEvent.java | 811 ----------- generated/gen-java/EventType.java | 46 - generated/gen-java/tenfour/Answer.java | 757 ---------- generated/gen-java/tenfour/Asset.java | 492 ------- generated/gen-java/tenfour/Content.java | 1294 ------------------ generated/gen-java/tenfour/ItemContent.java | 309 ----- generated/gen-java/tenfour/Question.java | 701 ---------- generated/gen-java/tenfour/QuizContent.java | 548 -------- generated/gen-java/tenfour/ResultGroup.java | 592 -------- generated/gen-java/tenfour/ResultGroups.java | 545 -------- 12 files changed, 1 insertion(+), 6403 deletions(-) delete mode 100644 generated/gen-java/ContentAtom.java delete mode 100644 generated/gen-java/ContentAtomEvent.java delete mode 100644 generated/gen-java/EventType.java delete mode 100644 generated/gen-java/tenfour/Answer.java delete mode 100644 generated/gen-java/tenfour/Asset.java delete mode 100644 generated/gen-java/tenfour/Content.java delete mode 100644 generated/gen-java/tenfour/ItemContent.java delete mode 100644 generated/gen-java/tenfour/Question.java delete mode 100644 generated/gen-java/tenfour/QuizContent.java delete mode 100644 generated/gen-java/tenfour/ResultGroup.java delete mode 100644 generated/gen-java/tenfour/ResultGroups.java diff --git a/build.sh b/build.sh index e283ff5..2b9b5b3 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -LANGUAGES=("js:node" "java") +LANGUAGES=("js:node") THRIFT_VERBOSE="-v" diff --git a/generated/gen-java/ContentAtom.java b/generated/gen-java/ContentAtom.java deleted file mode 100644 index 287f034..0000000 --- a/generated/gen-java/ContentAtom.java +++ /dev/null @@ -1,307 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.2) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import javax.annotation.Generated; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -public class ContentAtom extends org.apache.thrift.TUnion { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ContentAtom"); - private static final org.apache.thrift.protocol.TField TENFOUR_FIELD_DESC = new org.apache.thrift.protocol.TField("tenfour", org.apache.thrift.protocol.TType.STRUCT, (short)1); - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - TENFOUR((short)1, "tenfour"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // TENFOUR - return TENFOUR; - 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.TENFOUR, new org.apache.thrift.meta_data.FieldMetaData("tenfour", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, tenfour.Content.class))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ContentAtom.class, metaDataMap); - } - - public ContentAtom() { - super(); - } - - public ContentAtom(_Fields setField, Object value) { - super(setField, value); - } - - public ContentAtom(ContentAtom other) { - super(other); - } - public ContentAtom deepCopy() { - return new ContentAtom(this); - } - - public static ContentAtom tenfour(tenfour.Content value) { - ContentAtom x = new ContentAtom(); - x.setTenfour(value); - return x; - } - - - @Override - protected void checkType(_Fields setField, Object value) throws ClassCastException { - switch (setField) { - case TENFOUR: - if (value instanceof tenfour.Content) { - break; - } - throw new ClassCastException("Was expecting value of type tenfour.Content for field 'tenfour', but got " + value.getClass().getSimpleName()); - default: - throw new IllegalArgumentException("Unknown field id " + setField); - } - } - - @Override - protected 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 TENFOUR: - if (field.type == TENFOUR_FIELD_DESC.type) { - tenfour.Content tenfour; - tenfour = new tenfour.Content(); - tenfour.read(iprot); - return tenfour; - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); - return null; - } - default: - throw new 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 TENFOUR: - tenfour.Content tenfour = (tenfour.Content)value_; - tenfour.write(oprot); - return; - default: - throw new IllegalStateException("Cannot write union with unknown field " + setField_); - } - } - - @Override - protected 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 TENFOUR: - tenfour.Content tenfour; - tenfour = new tenfour.Content(); - tenfour.read(iprot); - return tenfour; - default: - throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!"); - } - } else { - throw new 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 TENFOUR: - tenfour.Content tenfour = (tenfour.Content)value_; - tenfour.write(oprot); - return; - default: - throw new IllegalStateException("Cannot write union with unknown field " + setField_); - } - } - - @Override - protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) { - switch (setField) { - case TENFOUR: - return TENFOUR_FIELD_DESC; - default: - throw new 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); - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - - public tenfour.Content getTenfour() { - if (getSetField() == _Fields.TENFOUR) { - return (tenfour.Content)getFieldValue(); - } else { - throw new RuntimeException("Cannot get field 'tenfour' because union is currently set to " + getFieldDesc(getSetField()).name); - } - } - - public void setTenfour(tenfour.Content value) { - if (value == null) throw new NullPointerException(); - setField_ = _Fields.TENFOUR; - value_ = value; - } - - public boolean isSetTenfour() { - return setField_ == _Fields.TENFOUR; - } - - - public boolean equals(Object other) { - if (other instanceof ContentAtom) { - return equals((ContentAtom)other); - } else { - return false; - } - } - - public boolean equals(ContentAtom other) { - return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue()); - } - - @Override - public int compareTo(ContentAtom 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() { - List list = new ArrayList(); - list.add(this.getClass().getName()); - org.apache.thrift.TFieldIdEnum setField = getSetField(); - if (setField != null) { - list.add(setField.getThriftFieldId()); - 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, 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); - } - } - - -} diff --git a/generated/gen-java/ContentAtomEvent.java b/generated/gen-java/ContentAtomEvent.java deleted file mode 100644 index cc449d2..0000000 --- a/generated/gen-java/ContentAtomEvent.java +++ /dev/null @@ -1,811 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.2) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import javax.annotation.Generated; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") -public class ContentAtomEvent implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ContentAtomEvent"); - - private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.STRING, (short)1); - private static final org.apache.thrift.protocol.TField URL_FIELD_DESC = new org.apache.thrift.protocol.TField("url", org.apache.thrift.protocol.TType.STRING, (short)2); - private static final org.apache.thrift.protocol.TField ATOM_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("atomType", org.apache.thrift.protocol.TType.STRING, (short)3); - private static final org.apache.thrift.protocol.TField EVENT_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("eventType", org.apache.thrift.protocol.TType.I32, (short)4); - private static final org.apache.thrift.protocol.TField DATA_FIELD_DESC = new org.apache.thrift.protocol.TField("data", org.apache.thrift.protocol.TType.STRUCT, (short)5); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new ContentAtomEventStandardSchemeFactory()); - schemes.put(TupleScheme.class, new ContentAtomEventTupleSchemeFactory()); - } - - public String id; // required - public String url; // required - public String atomType; // required - /** - * - * @see EventType - */ - public EventType eventType; // required - public ContentAtom data; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - ID((short)1, "id"), - URL((short)2, "url"), - ATOM_TYPE((short)3, "atomType"), - /** - * - * @see EventType - */ - EVENT_TYPE((short)4, "eventType"), - DATA((short)5, "data"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // ID - return ID; - case 2: // URL - return URL; - case 3: // ATOM_TYPE - return ATOM_TYPE; - case 4: // EVENT_TYPE - return EVENT_TYPE; - case 5: // DATA - return DATA; - 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , "ContentAtomID"))); - tmpMap.put(_Fields.URL, new org.apache.thrift.meta_data.FieldMetaData("url", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.ATOM_TYPE, new org.apache.thrift.meta_data.FieldMetaData("atomType", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.EVENT_TYPE, new org.apache.thrift.meta_data.FieldMetaData("eventType", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, EventType.class))); - tmpMap.put(_Fields.DATA, new org.apache.thrift.meta_data.FieldMetaData("data", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ContentAtom.class))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ContentAtomEvent.class, metaDataMap); - } - - public ContentAtomEvent() { - } - - public ContentAtomEvent( - String id, - String url, - String atomType, - EventType eventType, - ContentAtom data) - { - this(); - this.id = id; - this.url = url; - this.atomType = atomType; - this.eventType = eventType; - this.data = data; - } - - /** - * Performs a deep copy on other. - */ - public ContentAtomEvent(ContentAtomEvent other) { - if (other.isSetId()) { - this.id = other.id; - } - if (other.isSetUrl()) { - this.url = other.url; - } - if (other.isSetAtomType()) { - this.atomType = other.atomType; - } - if (other.isSetEventType()) { - this.eventType = other.eventType; - } - if (other.isSetData()) { - this.data = new ContentAtom(other.data); - } - } - - public ContentAtomEvent deepCopy() { - return new ContentAtomEvent(this); - } - - @Override - public void clear() { - this.id = null; - this.url = null; - this.atomType = null; - this.eventType = null; - this.data = null; - } - - public String getId() { - return this.id; - } - - public ContentAtomEvent setId(String id) { - this.id = id; - return this; - } - - public void unsetId() { - this.id = null; - } - - /** Returns true if field id is set (has been assigned a value) and false otherwise */ - public boolean isSetId() { - return this.id != null; - } - - public void setIdIsSet(boolean value) { - if (!value) { - this.id = null; - } - } - - public String getUrl() { - return this.url; - } - - public ContentAtomEvent setUrl(String url) { - this.url = url; - return this; - } - - public void unsetUrl() { - this.url = null; - } - - /** Returns true if field url is set (has been assigned a value) and false otherwise */ - public boolean isSetUrl() { - return this.url != null; - } - - public void setUrlIsSet(boolean value) { - if (!value) { - this.url = null; - } - } - - public String getAtomType() { - return this.atomType; - } - - public ContentAtomEvent setAtomType(String atomType) { - this.atomType = atomType; - return this; - } - - public void unsetAtomType() { - this.atomType = null; - } - - /** Returns true if field atomType is set (has been assigned a value) and false otherwise */ - public boolean isSetAtomType() { - return this.atomType != null; - } - - public void setAtomTypeIsSet(boolean value) { - if (!value) { - this.atomType = null; - } - } - - /** - * - * @see EventType - */ - public EventType getEventType() { - return this.eventType; - } - - /** - * - * @see EventType - */ - public ContentAtomEvent setEventType(EventType eventType) { - this.eventType = eventType; - return this; - } - - public void unsetEventType() { - this.eventType = null; - } - - /** Returns true if field eventType is set (has been assigned a value) and false otherwise */ - public boolean isSetEventType() { - return this.eventType != null; - } - - public void setEventTypeIsSet(boolean value) { - if (!value) { - this.eventType = null; - } - } - - public ContentAtom getData() { - return this.data; - } - - public ContentAtomEvent setData(ContentAtom data) { - this.data = data; - return this; - } - - public void unsetData() { - this.data = null; - } - - /** Returns true if field data is set (has been assigned a value) and false otherwise */ - public boolean isSetData() { - return this.data != null; - } - - public void setDataIsSet(boolean value) { - if (!value) { - this.data = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case ID: - if (value == null) { - unsetId(); - } else { - setId((String)value); - } - break; - - case URL: - if (value == null) { - unsetUrl(); - } else { - setUrl((String)value); - } - break; - - case ATOM_TYPE: - if (value == null) { - unsetAtomType(); - } else { - setAtomType((String)value); - } - break; - - case EVENT_TYPE: - if (value == null) { - unsetEventType(); - } else { - setEventType((EventType)value); - } - break; - - case DATA: - if (value == null) { - unsetData(); - } else { - setData((ContentAtom)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case ID: - return getId(); - - case URL: - return getUrl(); - - case ATOM_TYPE: - return getAtomType(); - - case EVENT_TYPE: - return getEventType(); - - case DATA: - return getData(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case ID: - return isSetId(); - case URL: - return isSetUrl(); - case ATOM_TYPE: - return isSetAtomType(); - case EVENT_TYPE: - return isSetEventType(); - case DATA: - return isSetData(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof ContentAtomEvent) - return this.equals((ContentAtomEvent)that); - return false; - } - - public boolean equals(ContentAtomEvent that) { - if (that == null) - return false; - - boolean this_present_id = true && this.isSetId(); - boolean that_present_id = true && that.isSetId(); - if (this_present_id || that_present_id) { - if (!(this_present_id && that_present_id)) - return false; - if (!this.id.equals(that.id)) - return false; - } - - boolean this_present_url = true && this.isSetUrl(); - boolean that_present_url = true && that.isSetUrl(); - if (this_present_url || that_present_url) { - if (!(this_present_url && that_present_url)) - return false; - if (!this.url.equals(that.url)) - return false; - } - - boolean this_present_atomType = true && this.isSetAtomType(); - boolean that_present_atomType = true && that.isSetAtomType(); - if (this_present_atomType || that_present_atomType) { - if (!(this_present_atomType && that_present_atomType)) - return false; - if (!this.atomType.equals(that.atomType)) - return false; - } - - boolean this_present_eventType = true && this.isSetEventType(); - boolean that_present_eventType = true && that.isSetEventType(); - if (this_present_eventType || that_present_eventType) { - if (!(this_present_eventType && that_present_eventType)) - return false; - if (!this.eventType.equals(that.eventType)) - return false; - } - - boolean this_present_data = true && this.isSetData(); - boolean that_present_data = true && that.isSetData(); - if (this_present_data || that_present_data) { - if (!(this_present_data && that_present_data)) - return false; - if (!this.data.equals(that.data)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - List list = new ArrayList(); - - boolean present_id = true && (isSetId()); - list.add(present_id); - if (present_id) - list.add(id); - - boolean present_url = true && (isSetUrl()); - list.add(present_url); - if (present_url) - list.add(url); - - boolean present_atomType = true && (isSetAtomType()); - list.add(present_atomType); - if (present_atomType) - list.add(atomType); - - boolean present_eventType = true && (isSetEventType()); - list.add(present_eventType); - if (present_eventType) - list.add(eventType.getValue()); - - boolean present_data = true && (isSetData()); - list.add(present_data); - if (present_data) - list.add(data); - - return list.hashCode(); - } - - @Override - public int compareTo(ContentAtomEvent other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetId()).compareTo(other.isSetId()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetId()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetUrl()).compareTo(other.isSetUrl()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetUrl()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.url, other.url); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetAtomType()).compareTo(other.isSetAtomType()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetAtomType()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.atomType, other.atomType); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetEventType()).compareTo(other.isSetEventType()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetEventType()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.eventType, other.eventType); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetData()).compareTo(other.isSetData()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetData()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.data, other.data); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("ContentAtomEvent("); - boolean first = true; - - sb.append("id:"); - if (this.id == null) { - sb.append("null"); - } else { - sb.append(this.id); - } - first = false; - if (!first) sb.append(", "); - sb.append("url:"); - if (this.url == null) { - sb.append("null"); - } else { - sb.append(this.url); - } - first = false; - if (!first) sb.append(", "); - sb.append("atomType:"); - if (this.atomType == null) { - sb.append("null"); - } else { - sb.append(this.atomType); - } - first = false; - if (!first) sb.append(", "); - sb.append("eventType:"); - if (this.eventType == null) { - sb.append("null"); - } else { - sb.append(this.eventType); - } - first = false; - if (!first) sb.append(", "); - sb.append("data:"); - if (this.data == null) { - sb.append("null"); - } else { - sb.append(this.data); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (id == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'id' was not present! Struct: " + toString()); - } - if (url == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'url' was not present! Struct: " + toString()); - } - if (atomType == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'atomType' was not present! Struct: " + toString()); - } - if (eventType == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'eventType' was not present! Struct: " + toString()); - } - if (data == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'data' was not present! Struct: " + toString()); - } - // check for sub-struct validity - } - - 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, 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); - } - } - - private static class ContentAtomEventStandardSchemeFactory implements SchemeFactory { - public ContentAtomEventStandardScheme getScheme() { - return new ContentAtomEventStandardScheme(); - } - } - - private static class ContentAtomEventStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, ContentAtomEvent struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // ID - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.id = iprot.readString(); - struct.setIdIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // URL - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.url = iprot.readString(); - struct.setUrlIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // ATOM_TYPE - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.atomType = iprot.readString(); - struct.setAtomTypeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 4: // EVENT_TYPE - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.eventType = EventType.findByValue(iprot.readI32()); - struct.setEventTypeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 5: // DATA - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.data = new ContentAtom(); - struct.data.read(iprot); - struct.setDataIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, ContentAtomEvent struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.id != null) { - oprot.writeFieldBegin(ID_FIELD_DESC); - oprot.writeString(struct.id); - oprot.writeFieldEnd(); - } - if (struct.url != null) { - oprot.writeFieldBegin(URL_FIELD_DESC); - oprot.writeString(struct.url); - oprot.writeFieldEnd(); - } - if (struct.atomType != null) { - oprot.writeFieldBegin(ATOM_TYPE_FIELD_DESC); - oprot.writeString(struct.atomType); - oprot.writeFieldEnd(); - } - if (struct.eventType != null) { - oprot.writeFieldBegin(EVENT_TYPE_FIELD_DESC); - oprot.writeI32(struct.eventType.getValue()); - oprot.writeFieldEnd(); - } - if (struct.data != null) { - oprot.writeFieldBegin(DATA_FIELD_DESC); - struct.data.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class ContentAtomEventTupleSchemeFactory implements SchemeFactory { - public ContentAtomEventTupleScheme getScheme() { - return new ContentAtomEventTupleScheme(); - } - } - - private static class ContentAtomEventTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, ContentAtomEvent struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - oprot.writeString(struct.id); - oprot.writeString(struct.url); - oprot.writeString(struct.atomType); - oprot.writeI32(struct.eventType.getValue()); - struct.data.write(oprot); - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, ContentAtomEvent struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - struct.id = iprot.readString(); - struct.setIdIsSet(true); - struct.url = iprot.readString(); - struct.setUrlIsSet(true); - struct.atomType = iprot.readString(); - struct.setAtomTypeIsSet(true); - struct.eventType = EventType.findByValue(iprot.readI32()); - struct.setEventTypeIsSet(true); - struct.data = new ContentAtom(); - struct.data.read(iprot); - struct.setDataIsSet(true); - } - } - -} - diff --git a/generated/gen-java/EventType.java b/generated/gen-java/EventType.java deleted file mode 100644 index b0a1eeb..0000000 --- a/generated/gen-java/EventType.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.2) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ - -import java.util.Map; -import java.util.HashMap; -import org.apache.thrift.TEnum; - -public enum EventType implements org.apache.thrift.TEnum { - PUBLISH(0), - UPDATE(1), - TAKEDOWN(2); - - private final int value; - - private EventType(int value) { - this.value = value; - } - - /** - * Get the integer value of this enum value, as defined in the Thrift IDL. - */ - public int getValue() { - return value; - } - - /** - * Find a the enum type by its integer value, as defined in the Thrift IDL. - * @return null if the value is not found. - */ - public static EventType findByValue(int value) { - switch (value) { - case 0: - return PUBLISH; - case 1: - return UPDATE; - case 2: - return TAKEDOWN; - default: - return null; - } - } -} diff --git a/generated/gen-java/tenfour/Answer.java b/generated/gen-java/tenfour/Answer.java deleted file mode 100644 index 1c4a142..0000000 --- a/generated/gen-java/tenfour/Answer.java +++ /dev/null @@ -1,757 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.2) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package tenfour; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import javax.annotation.Generated; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") -public class Answer implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Answer"); - - private static final org.apache.thrift.protocol.TField ANSWER_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("answerText", org.apache.thrift.protocol.TType.STRING, (short)1); - private static final org.apache.thrift.protocol.TField ASSETS_FIELD_DESC = new org.apache.thrift.protocol.TField("assets", org.apache.thrift.protocol.TType.LIST, (short)2); - private static final org.apache.thrift.protocol.TField CORRECT_FIELD_DESC = new org.apache.thrift.protocol.TField("correct", org.apache.thrift.protocol.TType.BOOL, (short)3); - private static final org.apache.thrift.protocol.TField REVEAL_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("revealText", org.apache.thrift.protocol.TType.STRING, (short)4); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new AnswerStandardSchemeFactory()); - schemes.put(TupleScheme.class, new AnswerTupleSchemeFactory()); - } - - public String answerText; // required - public List assets; // required - public boolean correct; // required - public String revealText; // optional - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - ANSWER_TEXT((short)1, "answerText"), - ASSETS((short)2, "assets"), - CORRECT((short)3, "correct"), - REVEAL_TEXT((short)4, "revealText"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // ANSWER_TEXT - return ANSWER_TEXT; - case 2: // ASSETS - return ASSETS; - case 3: // CORRECT - return CORRECT; - case 4: // REVEAL_TEXT - return REVEAL_TEXT; - 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - private static final int __CORRECT_ISSET_ID = 0; - private byte __isset_bitfield = 0; - private static final _Fields optionals[] = {_Fields.REVEAL_TEXT}; - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.ANSWER_TEXT, new org.apache.thrift.meta_data.FieldMetaData("answerText", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.ASSETS, new org.apache.thrift.meta_data.FieldMetaData("assets", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "Asset")))); - tmpMap.put(_Fields.CORRECT, new org.apache.thrift.meta_data.FieldMetaData("correct", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); - tmpMap.put(_Fields.REVEAL_TEXT, new org.apache.thrift.meta_data.FieldMetaData("revealText", org.apache.thrift.TFieldRequirementType.OPTIONAL, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Answer.class, metaDataMap); - } - - public Answer() { - } - - public Answer( - String answerText, - List assets, - boolean correct) - { - this(); - this.answerText = answerText; - this.assets = assets; - this.correct = correct; - setCorrectIsSet(true); - } - - /** - * Performs a deep copy on other. - */ - public Answer(Answer other) { - __isset_bitfield = other.__isset_bitfield; - if (other.isSetAnswerText()) { - this.answerText = other.answerText; - } - if (other.isSetAssets()) { - List __this__assets = new ArrayList(other.assets.size()); - for (Asset other_element : other.assets) { - __this__assets.add(other_element); - } - this.assets = __this__assets; - } - this.correct = other.correct; - if (other.isSetRevealText()) { - this.revealText = other.revealText; - } - } - - public Answer deepCopy() { - return new Answer(this); - } - - @Override - public void clear() { - this.answerText = null; - this.assets = null; - setCorrectIsSet(false); - this.correct = false; - this.revealText = null; - } - - public String getAnswerText() { - return this.answerText; - } - - public Answer setAnswerText(String answerText) { - this.answerText = answerText; - return this; - } - - public void unsetAnswerText() { - this.answerText = null; - } - - /** Returns true if field answerText is set (has been assigned a value) and false otherwise */ - public boolean isSetAnswerText() { - return this.answerText != null; - } - - public void setAnswerTextIsSet(boolean value) { - if (!value) { - this.answerText = null; - } - } - - public int getAssetsSize() { - return (this.assets == null) ? 0 : this.assets.size(); - } - - public java.util.Iterator getAssetsIterator() { - return (this.assets == null) ? null : this.assets.iterator(); - } - - public void addToAssets(Asset elem) { - if (this.assets == null) { - this.assets = new ArrayList(); - } - this.assets.add(elem); - } - - public List getAssets() { - return this.assets; - } - - public Answer setAssets(List assets) { - this.assets = assets; - return this; - } - - public void unsetAssets() { - this.assets = null; - } - - /** Returns true if field assets is set (has been assigned a value) and false otherwise */ - public boolean isSetAssets() { - return this.assets != null; - } - - public void setAssetsIsSet(boolean value) { - if (!value) { - this.assets = null; - } - } - - public boolean isCorrect() { - return this.correct; - } - - public Answer setCorrect(boolean correct) { - this.correct = correct; - setCorrectIsSet(true); - return this; - } - - public void unsetCorrect() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __CORRECT_ISSET_ID); - } - - /** Returns true if field correct is set (has been assigned a value) and false otherwise */ - public boolean isSetCorrect() { - return EncodingUtils.testBit(__isset_bitfield, __CORRECT_ISSET_ID); - } - - public void setCorrectIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __CORRECT_ISSET_ID, value); - } - - public String getRevealText() { - return this.revealText; - } - - public Answer setRevealText(String revealText) { - this.revealText = revealText; - return this; - } - - public void unsetRevealText() { - this.revealText = null; - } - - /** Returns true if field revealText is set (has been assigned a value) and false otherwise */ - public boolean isSetRevealText() { - return this.revealText != null; - } - - public void setRevealTextIsSet(boolean value) { - if (!value) { - this.revealText = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case ANSWER_TEXT: - if (value == null) { - unsetAnswerText(); - } else { - setAnswerText((String)value); - } - break; - - case ASSETS: - if (value == null) { - unsetAssets(); - } else { - setAssets((List)value); - } - break; - - case CORRECT: - if (value == null) { - unsetCorrect(); - } else { - setCorrect((Boolean)value); - } - break; - - case REVEAL_TEXT: - if (value == null) { - unsetRevealText(); - } else { - setRevealText((String)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case ANSWER_TEXT: - return getAnswerText(); - - case ASSETS: - return getAssets(); - - case CORRECT: - return Boolean.valueOf(isCorrect()); - - case REVEAL_TEXT: - return getRevealText(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case ANSWER_TEXT: - return isSetAnswerText(); - case ASSETS: - return isSetAssets(); - case CORRECT: - return isSetCorrect(); - case REVEAL_TEXT: - return isSetRevealText(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof Answer) - return this.equals((Answer)that); - return false; - } - - public boolean equals(Answer that) { - if (that == null) - return false; - - boolean this_present_answerText = true && this.isSetAnswerText(); - boolean that_present_answerText = true && that.isSetAnswerText(); - if (this_present_answerText || that_present_answerText) { - if (!(this_present_answerText && that_present_answerText)) - return false; - if (!this.answerText.equals(that.answerText)) - return false; - } - - boolean this_present_assets = true && this.isSetAssets(); - boolean that_present_assets = true && that.isSetAssets(); - if (this_present_assets || that_present_assets) { - if (!(this_present_assets && that_present_assets)) - return false; - if (!this.assets.equals(that.assets)) - return false; - } - - boolean this_present_correct = true; - boolean that_present_correct = true; - if (this_present_correct || that_present_correct) { - if (!(this_present_correct && that_present_correct)) - return false; - if (this.correct != that.correct) - return false; - } - - boolean this_present_revealText = true && this.isSetRevealText(); - boolean that_present_revealText = true && that.isSetRevealText(); - if (this_present_revealText || that_present_revealText) { - if (!(this_present_revealText && that_present_revealText)) - return false; - if (!this.revealText.equals(that.revealText)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - List list = new ArrayList(); - - boolean present_answerText = true && (isSetAnswerText()); - list.add(present_answerText); - if (present_answerText) - list.add(answerText); - - boolean present_assets = true && (isSetAssets()); - list.add(present_assets); - if (present_assets) - list.add(assets); - - boolean present_correct = true; - list.add(present_correct); - if (present_correct) - list.add(correct); - - boolean present_revealText = true && (isSetRevealText()); - list.add(present_revealText); - if (present_revealText) - list.add(revealText); - - return list.hashCode(); - } - - @Override - public int compareTo(Answer other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetAnswerText()).compareTo(other.isSetAnswerText()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetAnswerText()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.answerText, other.answerText); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetAssets()).compareTo(other.isSetAssets()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetAssets()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.assets, other.assets); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetCorrect()).compareTo(other.isSetCorrect()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetCorrect()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.correct, other.correct); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetRevealText()).compareTo(other.isSetRevealText()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetRevealText()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.revealText, other.revealText); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("Answer("); - boolean first = true; - - sb.append("answerText:"); - if (this.answerText == null) { - sb.append("null"); - } else { - sb.append(this.answerText); - } - first = false; - if (!first) sb.append(", "); - sb.append("assets:"); - if (this.assets == null) { - sb.append("null"); - } else { - sb.append(this.assets); - } - first = false; - if (!first) sb.append(", "); - sb.append("correct:"); - sb.append(this.correct); - first = false; - if (isSetRevealText()) { - if (!first) sb.append(", "); - sb.append("revealText:"); - if (this.revealText == null) { - sb.append("null"); - } else { - sb.append(this.revealText); - } - first = false; - } - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (answerText == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'answerText' was not present! Struct: " + toString()); - } - if (assets == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'assets' was not present! Struct: " + toString()); - } - // alas, we cannot check 'correct' because it's a primitive and you chose the non-beans generator. - // check for sub-struct validity - } - - 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, ClassNotFoundException { - try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class AnswerStandardSchemeFactory implements SchemeFactory { - public AnswerStandardScheme getScheme() { - return new AnswerStandardScheme(); - } - } - - private static class AnswerStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, Answer struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // ANSWER_TEXT - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.answerText = iprot.readString(); - struct.setAnswerTextIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // ASSETS - if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { - { - org.apache.thrift.protocol.TList _list32 = iprot.readListBegin(); - struct.assets = new ArrayList(_list32.size); - Asset _elem33; - for (int _i34 = 0; _i34 < _list32.size; ++_i34) - { - _elem33 = new Asset(); - _elem33.read(iprot); - struct.assets.add(_elem33); - } - iprot.readListEnd(); - } - struct.setAssetsIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // CORRECT - if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { - struct.correct = iprot.readBool(); - struct.setCorrectIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 4: // REVEAL_TEXT - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.revealText = iprot.readString(); - struct.setRevealTextIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - if (!struct.isSetCorrect()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'correct' was not found in serialized data! Struct: " + toString()); - } - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, Answer struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.answerText != null) { - oprot.writeFieldBegin(ANSWER_TEXT_FIELD_DESC); - oprot.writeString(struct.answerText); - oprot.writeFieldEnd(); - } - if (struct.assets != null) { - oprot.writeFieldBegin(ASSETS_FIELD_DESC); - { - oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.assets.size())); - for (Asset _iter35 : struct.assets) - { - _iter35.write(oprot); - } - oprot.writeListEnd(); - } - oprot.writeFieldEnd(); - } - oprot.writeFieldBegin(CORRECT_FIELD_DESC); - oprot.writeBool(struct.correct); - oprot.writeFieldEnd(); - if (struct.revealText != null) { - if (struct.isSetRevealText()) { - oprot.writeFieldBegin(REVEAL_TEXT_FIELD_DESC); - oprot.writeString(struct.revealText); - oprot.writeFieldEnd(); - } - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class AnswerTupleSchemeFactory implements SchemeFactory { - public AnswerTupleScheme getScheme() { - return new AnswerTupleScheme(); - } - } - - private static class AnswerTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, Answer struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - oprot.writeString(struct.answerText); - { - oprot.writeI32(struct.assets.size()); - for (Asset _iter36 : struct.assets) - { - _iter36.write(oprot); - } - } - oprot.writeBool(struct.correct); - BitSet optionals = new BitSet(); - if (struct.isSetRevealText()) { - optionals.set(0); - } - oprot.writeBitSet(optionals, 1); - if (struct.isSetRevealText()) { - oprot.writeString(struct.revealText); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, Answer struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - struct.answerText = iprot.readString(); - struct.setAnswerTextIsSet(true); - { - org.apache.thrift.protocol.TList _list37 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.assets = new ArrayList(_list37.size); - Asset _elem38; - for (int _i39 = 0; _i39 < _list37.size; ++_i39) - { - _elem38 = new Asset(); - _elem38.read(iprot); - struct.assets.add(_elem38); - } - } - struct.setAssetsIsSet(true); - struct.correct = iprot.readBool(); - struct.setCorrectIsSet(true); - BitSet incoming = iprot.readBitSet(1); - if (incoming.get(0)) { - struct.revealText = iprot.readString(); - struct.setRevealTextIsSet(true); - } - } - } - -} - diff --git a/generated/gen-java/tenfour/Asset.java b/generated/gen-java/tenfour/Asset.java deleted file mode 100644 index 82dc759..0000000 --- a/generated/gen-java/tenfour/Asset.java +++ /dev/null @@ -1,492 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.2) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package tenfour; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import javax.annotation.Generated; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") -public class Asset implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Asset"); - - private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.STRING, (short)1); - private static final org.apache.thrift.protocol.TField DATA_FIELD_DESC = new org.apache.thrift.protocol.TField("data", org.apache.thrift.protocol.TType.STRING, (short)2); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new AssetStandardSchemeFactory()); - schemes.put(TupleScheme.class, new AssetTupleSchemeFactory()); - } - - public String type; // required - public String data; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - TYPE((short)1, "type"), - DATA((short)2, "data"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // TYPE - return TYPE; - case 2: // DATA - return DATA; - 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.DATA, new org.apache.thrift.meta_data.FieldMetaData("data", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , "OpaqueJson"))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Asset.class, metaDataMap); - } - - public Asset() { - } - - public Asset( - String type, - String data) - { - this(); - this.type = type; - this.data = data; - } - - /** - * Performs a deep copy on other. - */ - public Asset(Asset other) { - if (other.isSetType()) { - this.type = other.type; - } - if (other.isSetData()) { - this.data = other.data; - } - } - - public Asset deepCopy() { - return new Asset(this); - } - - @Override - public void clear() { - this.type = null; - this.data = null; - } - - public String getType() { - return this.type; - } - - public Asset setType(String type) { - this.type = type; - return this; - } - - public void unsetType() { - this.type = null; - } - - /** Returns true if field type is set (has been assigned a value) and false otherwise */ - public boolean isSetType() { - return this.type != null; - } - - public void setTypeIsSet(boolean value) { - if (!value) { - this.type = null; - } - } - - public String getData() { - return this.data; - } - - public Asset setData(String data) { - this.data = data; - return this; - } - - public void unsetData() { - this.data = null; - } - - /** Returns true if field data is set (has been assigned a value) and false otherwise */ - public boolean isSetData() { - return this.data != null; - } - - public void setDataIsSet(boolean value) { - if (!value) { - this.data = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case TYPE: - if (value == null) { - unsetType(); - } else { - setType((String)value); - } - break; - - case DATA: - if (value == null) { - unsetData(); - } else { - setData((String)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case TYPE: - return getType(); - - case DATA: - return getData(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case TYPE: - return isSetType(); - case DATA: - return isSetData(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof Asset) - return this.equals((Asset)that); - return false; - } - - public boolean equals(Asset that) { - if (that == null) - return false; - - boolean this_present_type = true && this.isSetType(); - boolean that_present_type = true && that.isSetType(); - if (this_present_type || that_present_type) { - if (!(this_present_type && that_present_type)) - return false; - if (!this.type.equals(that.type)) - return false; - } - - boolean this_present_data = true && this.isSetData(); - boolean that_present_data = true && that.isSetData(); - if (this_present_data || that_present_data) { - if (!(this_present_data && that_present_data)) - return false; - if (!this.data.equals(that.data)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - List list = new ArrayList(); - - boolean present_type = true && (isSetType()); - list.add(present_type); - if (present_type) - list.add(type); - - boolean present_data = true && (isSetData()); - list.add(present_data); - if (present_data) - list.add(data); - - return list.hashCode(); - } - - @Override - public int compareTo(Asset other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetType()).compareTo(other.isSetType()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetType()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetData()).compareTo(other.isSetData()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetData()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.data, other.data); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("Asset("); - boolean first = true; - - sb.append("type:"); - if (this.type == null) { - sb.append("null"); - } else { - sb.append(this.type); - } - first = false; - if (!first) sb.append(", "); - sb.append("data:"); - if (this.data == null) { - sb.append("null"); - } else { - sb.append(this.data); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (type == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' was not present! Struct: " + toString()); - } - if (data == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'data' was not present! Struct: " + toString()); - } - // check for sub-struct validity - } - - 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, 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); - } - } - - private static class AssetStandardSchemeFactory implements SchemeFactory { - public AssetStandardScheme getScheme() { - return new AssetStandardScheme(); - } - } - - private static class AssetStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, Asset struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // TYPE - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.type = iprot.readString(); - struct.setTypeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // DATA - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.data = iprot.readString(); - struct.setDataIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, Asset struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.type != null) { - oprot.writeFieldBegin(TYPE_FIELD_DESC); - oprot.writeString(struct.type); - oprot.writeFieldEnd(); - } - if (struct.data != null) { - oprot.writeFieldBegin(DATA_FIELD_DESC); - oprot.writeString(struct.data); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class AssetTupleSchemeFactory implements SchemeFactory { - public AssetTupleScheme getScheme() { - return new AssetTupleScheme(); - } - } - - private static class AssetTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, Asset struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - oprot.writeString(struct.type); - oprot.writeString(struct.data); - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, Asset struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - struct.type = iprot.readString(); - struct.setTypeIsSet(true); - struct.data = iprot.readString(); - struct.setDataIsSet(true); - } - } - -} - diff --git a/generated/gen-java/tenfour/Content.java b/generated/gen-java/tenfour/Content.java deleted file mode 100644 index 8e6c459..0000000 --- a/generated/gen-java/tenfour/Content.java +++ /dev/null @@ -1,1294 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.2) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package tenfour; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import javax.annotation.Generated; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") -public class Content implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Content"); - - private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.STRING, (short)1); - private static final org.apache.thrift.protocol.TField TITLE_FIELD_DESC = new org.apache.thrift.protocol.TField("title", org.apache.thrift.protocol.TType.STRING, (short)2); - private static final org.apache.thrift.protocol.TField UPDATED_BY_FIELD_DESC = new org.apache.thrift.protocol.TField("updatedBy", org.apache.thrift.protocol.TType.STRING, (short)3); - private static final org.apache.thrift.protocol.TField UPDATED_AT_FIELD_DESC = new org.apache.thrift.protocol.TField("updatedAt", org.apache.thrift.protocol.TType.I64, (short)4); - private static final org.apache.thrift.protocol.TField CREATED_AT_FIELD_DESC = new org.apache.thrift.protocol.TField("createdAt", org.apache.thrift.protocol.TType.I64, (short)5); - private static final org.apache.thrift.protocol.TField CREATED_BY_FIELD_DESC = new org.apache.thrift.protocol.TField("createdBy", org.apache.thrift.protocol.TType.STRING, (short)6); - private static final org.apache.thrift.protocol.TField PUBLISHED_FIELD_DESC = new org.apache.thrift.protocol.TField("published", org.apache.thrift.protocol.TType.BOOL, (short)7); - private static final org.apache.thrift.protocol.TField QUIZ_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("quizType", org.apache.thrift.protocol.TType.STRING, (short)8); - private static final org.apache.thrift.protocol.TField DEFAULT_COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("defaultColumns", org.apache.thrift.protocol.TType.I16, (short)9); - private static final org.apache.thrift.protocol.TField CONTENT_FIELD_DESC = new org.apache.thrift.protocol.TField("content", org.apache.thrift.protocol.TType.STRUCT, (short)10); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new ContentStandardSchemeFactory()); - schemes.put(TupleScheme.class, new ContentTupleSchemeFactory()); - } - - public String id; // required - public String title; // required - public String updatedBy; // required - public long updatedAt; // required - public long createdAt; // required - public String createdBy; // required - public boolean published; // required - public String quizType; // required - public short defaultColumns; // optional - public ItemContent content; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - ID((short)1, "id"), - TITLE((short)2, "title"), - UPDATED_BY((short)3, "updatedBy"), - UPDATED_AT((short)4, "updatedAt"), - CREATED_AT((short)5, "createdAt"), - CREATED_BY((short)6, "createdBy"), - PUBLISHED((short)7, "published"), - QUIZ_TYPE((short)8, "quizType"), - DEFAULT_COLUMNS((short)9, "defaultColumns"), - CONTENT((short)10, "content"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // ID - return ID; - case 2: // TITLE - return TITLE; - case 3: // UPDATED_BY - return UPDATED_BY; - case 4: // UPDATED_AT - return UPDATED_AT; - case 5: // CREATED_AT - return CREATED_AT; - case 6: // CREATED_BY - return CREATED_BY; - case 7: // PUBLISHED - return PUBLISHED; - case 8: // QUIZ_TYPE - return QUIZ_TYPE; - case 9: // DEFAULT_COLUMNS - return DEFAULT_COLUMNS; - case 10: // CONTENT - return CONTENT; - 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - private static final int __UPDATEDAT_ISSET_ID = 0; - private static final int __CREATEDAT_ISSET_ID = 1; - private static final int __PUBLISHED_ISSET_ID = 2; - private static final int __DEFAULTCOLUMNS_ISSET_ID = 3; - private byte __isset_bitfield = 0; - private static final _Fields optionals[] = {_Fields.DEFAULT_COLUMNS}; - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.TITLE, new org.apache.thrift.meta_data.FieldMetaData("title", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.UPDATED_BY, new org.apache.thrift.meta_data.FieldMetaData("updatedBy", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.UPDATED_AT, new org.apache.thrift.meta_data.FieldMetaData("updatedAt", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64 , "DateTime"))); - tmpMap.put(_Fields.CREATED_AT, new org.apache.thrift.meta_data.FieldMetaData("createdAt", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64 , "DateTime"))); - tmpMap.put(_Fields.CREATED_BY, new org.apache.thrift.meta_data.FieldMetaData("createdBy", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.PUBLISHED, new org.apache.thrift.meta_data.FieldMetaData("published", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); - tmpMap.put(_Fields.QUIZ_TYPE, new org.apache.thrift.meta_data.FieldMetaData("quizType", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.DEFAULT_COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("defaultColumns", org.apache.thrift.TFieldRequirementType.OPTIONAL, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); - tmpMap.put(_Fields.CONTENT, new org.apache.thrift.meta_data.FieldMetaData("content", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "ItemContent"))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Content.class, metaDataMap); - } - - public Content() { - } - - public Content( - String id, - String title, - String updatedBy, - long updatedAt, - long createdAt, - String createdBy, - boolean published, - String quizType, - ItemContent content) - { - this(); - this.id = id; - this.title = title; - this.updatedBy = updatedBy; - this.updatedAt = updatedAt; - setUpdatedAtIsSet(true); - this.createdAt = createdAt; - setCreatedAtIsSet(true); - this.createdBy = createdBy; - this.published = published; - setPublishedIsSet(true); - this.quizType = quizType; - this.content = content; - } - - /** - * Performs a deep copy on other. - */ - public Content(Content other) { - __isset_bitfield = other.__isset_bitfield; - if (other.isSetId()) { - this.id = other.id; - } - if (other.isSetTitle()) { - this.title = other.title; - } - if (other.isSetUpdatedBy()) { - this.updatedBy = other.updatedBy; - } - this.updatedAt = other.updatedAt; - this.createdAt = other.createdAt; - if (other.isSetCreatedBy()) { - this.createdBy = other.createdBy; - } - this.published = other.published; - if (other.isSetQuizType()) { - this.quizType = other.quizType; - } - this.defaultColumns = other.defaultColumns; - if (other.isSetContent()) { - this.content = other.content; - } - } - - public Content deepCopy() { - return new Content(this); - } - - @Override - public void clear() { - this.id = null; - this.title = null; - this.updatedBy = null; - setUpdatedAtIsSet(false); - this.updatedAt = 0; - setCreatedAtIsSet(false); - this.createdAt = 0; - this.createdBy = null; - setPublishedIsSet(false); - this.published = false; - this.quizType = null; - setDefaultColumnsIsSet(false); - this.defaultColumns = 0; - this.content = null; - } - - public String getId() { - return this.id; - } - - public Content setId(String id) { - this.id = id; - return this; - } - - public void unsetId() { - this.id = null; - } - - /** Returns true if field id is set (has been assigned a value) and false otherwise */ - public boolean isSetId() { - return this.id != null; - } - - public void setIdIsSet(boolean value) { - if (!value) { - this.id = null; - } - } - - public String getTitle() { - return this.title; - } - - public Content setTitle(String title) { - this.title = title; - return this; - } - - public void unsetTitle() { - this.title = null; - } - - /** Returns true if field title is set (has been assigned a value) and false otherwise */ - public boolean isSetTitle() { - return this.title != null; - } - - public void setTitleIsSet(boolean value) { - if (!value) { - this.title = null; - } - } - - public String getUpdatedBy() { - return this.updatedBy; - } - - public Content setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy; - return this; - } - - public void unsetUpdatedBy() { - this.updatedBy = null; - } - - /** Returns true if field updatedBy is set (has been assigned a value) and false otherwise */ - public boolean isSetUpdatedBy() { - return this.updatedBy != null; - } - - public void setUpdatedByIsSet(boolean value) { - if (!value) { - this.updatedBy = null; - } - } - - public long getUpdatedAt() { - return this.updatedAt; - } - - public Content setUpdatedAt(long updatedAt) { - this.updatedAt = updatedAt; - setUpdatedAtIsSet(true); - return this; - } - - public void unsetUpdatedAt() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __UPDATEDAT_ISSET_ID); - } - - /** Returns true if field updatedAt is set (has been assigned a value) and false otherwise */ - public boolean isSetUpdatedAt() { - return EncodingUtils.testBit(__isset_bitfield, __UPDATEDAT_ISSET_ID); - } - - public void setUpdatedAtIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __UPDATEDAT_ISSET_ID, value); - } - - public long getCreatedAt() { - return this.createdAt; - } - - public Content setCreatedAt(long createdAt) { - this.createdAt = createdAt; - setCreatedAtIsSet(true); - return this; - } - - public void unsetCreatedAt() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __CREATEDAT_ISSET_ID); - } - - /** Returns true if field createdAt is set (has been assigned a value) and false otherwise */ - public boolean isSetCreatedAt() { - return EncodingUtils.testBit(__isset_bitfield, __CREATEDAT_ISSET_ID); - } - - public void setCreatedAtIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __CREATEDAT_ISSET_ID, value); - } - - public String getCreatedBy() { - return this.createdBy; - } - - public Content setCreatedBy(String createdBy) { - this.createdBy = createdBy; - return this; - } - - public void unsetCreatedBy() { - this.createdBy = null; - } - - /** Returns true if field createdBy is set (has been assigned a value) and false otherwise */ - public boolean isSetCreatedBy() { - return this.createdBy != null; - } - - public void setCreatedByIsSet(boolean value) { - if (!value) { - this.createdBy = null; - } - } - - public boolean isPublished() { - return this.published; - } - - public Content setPublished(boolean published) { - this.published = published; - setPublishedIsSet(true); - return this; - } - - public void unsetPublished() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PUBLISHED_ISSET_ID); - } - - /** Returns true if field published is set (has been assigned a value) and false otherwise */ - public boolean isSetPublished() { - return EncodingUtils.testBit(__isset_bitfield, __PUBLISHED_ISSET_ID); - } - - public void setPublishedIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PUBLISHED_ISSET_ID, value); - } - - public String getQuizType() { - return this.quizType; - } - - public Content setQuizType(String quizType) { - this.quizType = quizType; - return this; - } - - public void unsetQuizType() { - this.quizType = null; - } - - /** Returns true if field quizType is set (has been assigned a value) and false otherwise */ - public boolean isSetQuizType() { - return this.quizType != null; - } - - public void setQuizTypeIsSet(boolean value) { - if (!value) { - this.quizType = null; - } - } - - public short getDefaultColumns() { - return this.defaultColumns; - } - - public Content setDefaultColumns(short defaultColumns) { - this.defaultColumns = defaultColumns; - setDefaultColumnsIsSet(true); - return this; - } - - public void unsetDefaultColumns() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __DEFAULTCOLUMNS_ISSET_ID); - } - - /** Returns true if field defaultColumns is set (has been assigned a value) and false otherwise */ - public boolean isSetDefaultColumns() { - return EncodingUtils.testBit(__isset_bitfield, __DEFAULTCOLUMNS_ISSET_ID); - } - - public void setDefaultColumnsIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __DEFAULTCOLUMNS_ISSET_ID, value); - } - - public ItemContent getContent() { - return this.content; - } - - public Content setContent(ItemContent content) { - this.content = content; - return this; - } - - public void unsetContent() { - this.content = null; - } - - /** Returns true if field content is set (has been assigned a value) and false otherwise */ - public boolean isSetContent() { - return this.content != null; - } - - public void setContentIsSet(boolean value) { - if (!value) { - this.content = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case ID: - if (value == null) { - unsetId(); - } else { - setId((String)value); - } - break; - - case TITLE: - if (value == null) { - unsetTitle(); - } else { - setTitle((String)value); - } - break; - - case UPDATED_BY: - if (value == null) { - unsetUpdatedBy(); - } else { - setUpdatedBy((String)value); - } - break; - - case UPDATED_AT: - if (value == null) { - unsetUpdatedAt(); - } else { - setUpdatedAt((Long)value); - } - break; - - case CREATED_AT: - if (value == null) { - unsetCreatedAt(); - } else { - setCreatedAt((Long)value); - } - break; - - case CREATED_BY: - if (value == null) { - unsetCreatedBy(); - } else { - setCreatedBy((String)value); - } - break; - - case PUBLISHED: - if (value == null) { - unsetPublished(); - } else { - setPublished((Boolean)value); - } - break; - - case QUIZ_TYPE: - if (value == null) { - unsetQuizType(); - } else { - setQuizType((String)value); - } - break; - - case DEFAULT_COLUMNS: - if (value == null) { - unsetDefaultColumns(); - } else { - setDefaultColumns((Short)value); - } - break; - - case CONTENT: - if (value == null) { - unsetContent(); - } else { - setContent((ItemContent)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case ID: - return getId(); - - case TITLE: - return getTitle(); - - case UPDATED_BY: - return getUpdatedBy(); - - case UPDATED_AT: - return Long.valueOf(getUpdatedAt()); - - case CREATED_AT: - return Long.valueOf(getCreatedAt()); - - case CREATED_BY: - return getCreatedBy(); - - case PUBLISHED: - return Boolean.valueOf(isPublished()); - - case QUIZ_TYPE: - return getQuizType(); - - case DEFAULT_COLUMNS: - return Short.valueOf(getDefaultColumns()); - - case CONTENT: - return getContent(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case ID: - return isSetId(); - case TITLE: - return isSetTitle(); - case UPDATED_BY: - return isSetUpdatedBy(); - case UPDATED_AT: - return isSetUpdatedAt(); - case CREATED_AT: - return isSetCreatedAt(); - case CREATED_BY: - return isSetCreatedBy(); - case PUBLISHED: - return isSetPublished(); - case QUIZ_TYPE: - return isSetQuizType(); - case DEFAULT_COLUMNS: - return isSetDefaultColumns(); - case CONTENT: - return isSetContent(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof Content) - return this.equals((Content)that); - return false; - } - - public boolean equals(Content that) { - if (that == null) - return false; - - boolean this_present_id = true && this.isSetId(); - boolean that_present_id = true && that.isSetId(); - if (this_present_id || that_present_id) { - if (!(this_present_id && that_present_id)) - return false; - if (!this.id.equals(that.id)) - return false; - } - - boolean this_present_title = true && this.isSetTitle(); - boolean that_present_title = true && that.isSetTitle(); - if (this_present_title || that_present_title) { - if (!(this_present_title && that_present_title)) - return false; - if (!this.title.equals(that.title)) - return false; - } - - boolean this_present_updatedBy = true && this.isSetUpdatedBy(); - boolean that_present_updatedBy = true && that.isSetUpdatedBy(); - if (this_present_updatedBy || that_present_updatedBy) { - if (!(this_present_updatedBy && that_present_updatedBy)) - return false; - if (!this.updatedBy.equals(that.updatedBy)) - return false; - } - - boolean this_present_updatedAt = true; - boolean that_present_updatedAt = true; - if (this_present_updatedAt || that_present_updatedAt) { - if (!(this_present_updatedAt && that_present_updatedAt)) - return false; - if (this.updatedAt != that.updatedAt) - return false; - } - - boolean this_present_createdAt = true; - boolean that_present_createdAt = true; - if (this_present_createdAt || that_present_createdAt) { - if (!(this_present_createdAt && that_present_createdAt)) - return false; - if (this.createdAt != that.createdAt) - return false; - } - - boolean this_present_createdBy = true && this.isSetCreatedBy(); - boolean that_present_createdBy = true && that.isSetCreatedBy(); - if (this_present_createdBy || that_present_createdBy) { - if (!(this_present_createdBy && that_present_createdBy)) - return false; - if (!this.createdBy.equals(that.createdBy)) - return false; - } - - boolean this_present_published = true; - boolean that_present_published = true; - if (this_present_published || that_present_published) { - if (!(this_present_published && that_present_published)) - return false; - if (this.published != that.published) - return false; - } - - boolean this_present_quizType = true && this.isSetQuizType(); - boolean that_present_quizType = true && that.isSetQuizType(); - if (this_present_quizType || that_present_quizType) { - if (!(this_present_quizType && that_present_quizType)) - return false; - if (!this.quizType.equals(that.quizType)) - return false; - } - - boolean this_present_defaultColumns = true && this.isSetDefaultColumns(); - boolean that_present_defaultColumns = true && that.isSetDefaultColumns(); - if (this_present_defaultColumns || that_present_defaultColumns) { - if (!(this_present_defaultColumns && that_present_defaultColumns)) - return false; - if (this.defaultColumns != that.defaultColumns) - return false; - } - - boolean this_present_content = true && this.isSetContent(); - boolean that_present_content = true && that.isSetContent(); - if (this_present_content || that_present_content) { - if (!(this_present_content && that_present_content)) - return false; - if (!this.content.equals(that.content)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - List list = new ArrayList(); - - boolean present_id = true && (isSetId()); - list.add(present_id); - if (present_id) - list.add(id); - - boolean present_title = true && (isSetTitle()); - list.add(present_title); - if (present_title) - list.add(title); - - boolean present_updatedBy = true && (isSetUpdatedBy()); - list.add(present_updatedBy); - if (present_updatedBy) - list.add(updatedBy); - - boolean present_updatedAt = true; - list.add(present_updatedAt); - if (present_updatedAt) - list.add(updatedAt); - - boolean present_createdAt = true; - list.add(present_createdAt); - if (present_createdAt) - list.add(createdAt); - - boolean present_createdBy = true && (isSetCreatedBy()); - list.add(present_createdBy); - if (present_createdBy) - list.add(createdBy); - - boolean present_published = true; - list.add(present_published); - if (present_published) - list.add(published); - - boolean present_quizType = true && (isSetQuizType()); - list.add(present_quizType); - if (present_quizType) - list.add(quizType); - - boolean present_defaultColumns = true && (isSetDefaultColumns()); - list.add(present_defaultColumns); - if (present_defaultColumns) - list.add(defaultColumns); - - boolean present_content = true && (isSetContent()); - list.add(present_content); - if (present_content) - list.add(content); - - return list.hashCode(); - } - - @Override - public int compareTo(Content other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetId()).compareTo(other.isSetId()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetId()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetTitle()).compareTo(other.isSetTitle()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetTitle()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.title, other.title); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetUpdatedBy()).compareTo(other.isSetUpdatedBy()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetUpdatedBy()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updatedBy, other.updatedBy); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetUpdatedAt()).compareTo(other.isSetUpdatedAt()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetUpdatedAt()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updatedAt, other.updatedAt); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetCreatedAt()).compareTo(other.isSetCreatedAt()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetCreatedAt()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createdAt, other.createdAt); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetCreatedBy()).compareTo(other.isSetCreatedBy()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetCreatedBy()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.createdBy, other.createdBy); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetPublished()).compareTo(other.isSetPublished()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetPublished()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.published, other.published); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetQuizType()).compareTo(other.isSetQuizType()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetQuizType()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.quizType, other.quizType); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetDefaultColumns()).compareTo(other.isSetDefaultColumns()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetDefaultColumns()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.defaultColumns, other.defaultColumns); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetContent()).compareTo(other.isSetContent()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetContent()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.content, other.content); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("Content("); - boolean first = true; - - sb.append("id:"); - if (this.id == null) { - sb.append("null"); - } else { - sb.append(this.id); - } - first = false; - if (!first) sb.append(", "); - sb.append("title:"); - if (this.title == null) { - sb.append("null"); - } else { - sb.append(this.title); - } - first = false; - if (!first) sb.append(", "); - sb.append("updatedBy:"); - if (this.updatedBy == null) { - sb.append("null"); - } else { - sb.append(this.updatedBy); - } - first = false; - if (!first) sb.append(", "); - sb.append("updatedAt:"); - sb.append(this.updatedAt); - first = false; - if (!first) sb.append(", "); - sb.append("createdAt:"); - sb.append(this.createdAt); - first = false; - if (!first) sb.append(", "); - sb.append("createdBy:"); - if (this.createdBy == null) { - sb.append("null"); - } else { - sb.append(this.createdBy); - } - first = false; - if (!first) sb.append(", "); - sb.append("published:"); - sb.append(this.published); - first = false; - if (!first) sb.append(", "); - sb.append("quizType:"); - if (this.quizType == null) { - sb.append("null"); - } else { - sb.append(this.quizType); - } - first = false; - if (isSetDefaultColumns()) { - if (!first) sb.append(", "); - sb.append("defaultColumns:"); - sb.append(this.defaultColumns); - first = false; - } - if (!first) sb.append(", "); - sb.append("content:"); - if (this.content == null) { - sb.append("null"); - } else { - sb.append(this.content); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (id == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'id' was not present! Struct: " + toString()); - } - if (title == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'title' was not present! Struct: " + toString()); - } - if (updatedBy == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'updatedBy' was not present! Struct: " + toString()); - } - // alas, we cannot check 'updatedAt' because it's a primitive and you chose the non-beans generator. - // alas, we cannot check 'createdAt' because it's a primitive and you chose the non-beans generator. - if (createdBy == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'createdBy' was not present! Struct: " + toString()); - } - // alas, we cannot check 'published' because it's a primitive and you chose the non-beans generator. - if (quizType == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'quizType' was not present! Struct: " + toString()); - } - if (content == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'content' was not present! Struct: " + toString()); - } - // check for sub-struct validity - } - - 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, ClassNotFoundException { - try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class ContentStandardSchemeFactory implements SchemeFactory { - public ContentStandardScheme getScheme() { - return new ContentStandardScheme(); - } - } - - private static class ContentStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, Content struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // ID - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.id = iprot.readString(); - struct.setIdIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // TITLE - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.title = iprot.readString(); - struct.setTitleIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // UPDATED_BY - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.updatedBy = iprot.readString(); - struct.setUpdatedByIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 4: // UPDATED_AT - if (schemeField.type == org.apache.thrift.protocol.TType.I64) { - struct.updatedAt = iprot.readI64(); - struct.setUpdatedAtIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 5: // CREATED_AT - if (schemeField.type == org.apache.thrift.protocol.TType.I64) { - struct.createdAt = iprot.readI64(); - struct.setCreatedAtIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 6: // CREATED_BY - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.createdBy = iprot.readString(); - struct.setCreatedByIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 7: // PUBLISHED - if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { - struct.published = iprot.readBool(); - struct.setPublishedIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 8: // QUIZ_TYPE - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.quizType = iprot.readString(); - struct.setQuizTypeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 9: // DEFAULT_COLUMNS - if (schemeField.type == org.apache.thrift.protocol.TType.I16) { - struct.defaultColumns = iprot.readI16(); - struct.setDefaultColumnsIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 10: // CONTENT - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.content = new ItemContent(); - struct.content.read(iprot); - struct.setContentIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - if (!struct.isSetUpdatedAt()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'updatedAt' was not found in serialized data! Struct: " + toString()); - } - if (!struct.isSetCreatedAt()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'createdAt' was not found in serialized data! Struct: " + toString()); - } - if (!struct.isSetPublished()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'published' was not found in serialized data! Struct: " + toString()); - } - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, Content struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.id != null) { - oprot.writeFieldBegin(ID_FIELD_DESC); - oprot.writeString(struct.id); - oprot.writeFieldEnd(); - } - if (struct.title != null) { - oprot.writeFieldBegin(TITLE_FIELD_DESC); - oprot.writeString(struct.title); - oprot.writeFieldEnd(); - } - if (struct.updatedBy != null) { - oprot.writeFieldBegin(UPDATED_BY_FIELD_DESC); - oprot.writeString(struct.updatedBy); - oprot.writeFieldEnd(); - } - oprot.writeFieldBegin(UPDATED_AT_FIELD_DESC); - oprot.writeI64(struct.updatedAt); - oprot.writeFieldEnd(); - oprot.writeFieldBegin(CREATED_AT_FIELD_DESC); - oprot.writeI64(struct.createdAt); - oprot.writeFieldEnd(); - if (struct.createdBy != null) { - oprot.writeFieldBegin(CREATED_BY_FIELD_DESC); - oprot.writeString(struct.createdBy); - oprot.writeFieldEnd(); - } - oprot.writeFieldBegin(PUBLISHED_FIELD_DESC); - oprot.writeBool(struct.published); - oprot.writeFieldEnd(); - if (struct.quizType != null) { - oprot.writeFieldBegin(QUIZ_TYPE_FIELD_DESC); - oprot.writeString(struct.quizType); - oprot.writeFieldEnd(); - } - if (struct.isSetDefaultColumns()) { - oprot.writeFieldBegin(DEFAULT_COLUMNS_FIELD_DESC); - oprot.writeI16(struct.defaultColumns); - oprot.writeFieldEnd(); - } - if (struct.content != null) { - oprot.writeFieldBegin(CONTENT_FIELD_DESC); - struct.content.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class ContentTupleSchemeFactory implements SchemeFactory { - public ContentTupleScheme getScheme() { - return new ContentTupleScheme(); - } - } - - private static class ContentTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, Content struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - oprot.writeString(struct.id); - oprot.writeString(struct.title); - oprot.writeString(struct.updatedBy); - oprot.writeI64(struct.updatedAt); - oprot.writeI64(struct.createdAt); - oprot.writeString(struct.createdBy); - oprot.writeBool(struct.published); - oprot.writeString(struct.quizType); - struct.content.write(oprot); - BitSet optionals = new BitSet(); - if (struct.isSetDefaultColumns()) { - optionals.set(0); - } - oprot.writeBitSet(optionals, 1); - if (struct.isSetDefaultColumns()) { - oprot.writeI16(struct.defaultColumns); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, Content struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - struct.id = iprot.readString(); - struct.setIdIsSet(true); - struct.title = iprot.readString(); - struct.setTitleIsSet(true); - struct.updatedBy = iprot.readString(); - struct.setUpdatedByIsSet(true); - struct.updatedAt = iprot.readI64(); - struct.setUpdatedAtIsSet(true); - struct.createdAt = iprot.readI64(); - struct.setCreatedAtIsSet(true); - struct.createdBy = iprot.readString(); - struct.setCreatedByIsSet(true); - struct.published = iprot.readBool(); - struct.setPublishedIsSet(true); - struct.quizType = iprot.readString(); - struct.setQuizTypeIsSet(true); - struct.content = new ItemContent(); - struct.content.read(iprot); - struct.setContentIsSet(true); - BitSet incoming = iprot.readBitSet(1); - if (incoming.get(0)) { - struct.defaultColumns = iprot.readI16(); - struct.setDefaultColumnsIsSet(true); - } - } - } - -} - diff --git a/generated/gen-java/tenfour/ItemContent.java b/generated/gen-java/tenfour/ItemContent.java deleted file mode 100644 index 6400dd5..0000000 --- a/generated/gen-java/tenfour/ItemContent.java +++ /dev/null @@ -1,309 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.2) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package tenfour; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import javax.annotation.Generated; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -public class ItemContent extends org.apache.thrift.TUnion { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ItemContent"); - private static final org.apache.thrift.protocol.TField QUIZ_FIELD_DESC = new org.apache.thrift.protocol.TField("quiz", org.apache.thrift.protocol.TType.STRUCT, (short)1); - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - QUIZ((short)1, "quiz"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // QUIZ - return QUIZ; - 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.QUIZ, new org.apache.thrift.meta_data.FieldMetaData("quiz", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "QuizContent"))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ItemContent.class, metaDataMap); - } - - public ItemContent() { - super(); - } - - public ItemContent(_Fields setField, Object value) { - super(setField, value); - } - - public ItemContent(ItemContent other) { - super(other); - } - public ItemContent deepCopy() { - return new ItemContent(this); - } - - public static ItemContent quiz(QuizContent value) { - ItemContent x = new ItemContent(); - x.setQuiz(value); - return x; - } - - - @Override - protected void checkType(_Fields setField, Object value) throws ClassCastException { - switch (setField) { - case QUIZ: - if (value instanceof QuizContent) { - break; - } - throw new ClassCastException("Was expecting value of type QuizContent for field 'quiz', but got " + value.getClass().getSimpleName()); - default: - throw new IllegalArgumentException("Unknown field id " + setField); - } - } - - @Override - protected 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 QUIZ: - if (field.type == QUIZ_FIELD_DESC.type) { - QuizContent quiz; - quiz = new QuizContent(); - quiz.read(iprot); - return quiz; - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); - return null; - } - default: - throw new 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 QUIZ: - QuizContent quiz = (QuizContent)value_; - quiz.write(oprot); - return; - default: - throw new IllegalStateException("Cannot write union with unknown field " + setField_); - } - } - - @Override - protected 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 QUIZ: - QuizContent quiz; - quiz = new QuizContent(); - quiz.read(iprot); - return quiz; - default: - throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!"); - } - } else { - throw new 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 QUIZ: - QuizContent quiz = (QuizContent)value_; - quiz.write(oprot); - return; - default: - throw new IllegalStateException("Cannot write union with unknown field " + setField_); - } - } - - @Override - protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) { - switch (setField) { - case QUIZ: - return QUIZ_FIELD_DESC; - default: - throw new 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); - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - - public QuizContent getQuiz() { - if (getSetField() == _Fields.QUIZ) { - return (QuizContent)getFieldValue(); - } else { - throw new RuntimeException("Cannot get field 'quiz' because union is currently set to " + getFieldDesc(getSetField()).name); - } - } - - public void setQuiz(QuizContent value) { - if (value == null) throw new NullPointerException(); - setField_ = _Fields.QUIZ; - value_ = value; - } - - public boolean isSetQuiz() { - return setField_ == _Fields.QUIZ; - } - - - public boolean equals(Object other) { - if (other instanceof ItemContent) { - return equals((ItemContent)other); - } else { - return false; - } - } - - public boolean equals(ItemContent other) { - return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue()); - } - - @Override - public int compareTo(ItemContent 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() { - List list = new ArrayList(); - list.add(this.getClass().getName()); - org.apache.thrift.TFieldIdEnum setField = getSetField(); - if (setField != null) { - list.add(setField.getThriftFieldId()); - 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, 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); - } - } - - -} diff --git a/generated/gen-java/tenfour/Question.java b/generated/gen-java/tenfour/Question.java deleted file mode 100644 index dd5a5dd..0000000 --- a/generated/gen-java/tenfour/Question.java +++ /dev/null @@ -1,701 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.2) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package tenfour; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import javax.annotation.Generated; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") -public class Question implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Question"); - - private static final org.apache.thrift.protocol.TField QUESTION_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("questionText", org.apache.thrift.protocol.TType.STRING, (short)1); - private static final org.apache.thrift.protocol.TField ASSETS_FIELD_DESC = new org.apache.thrift.protocol.TField("assets", org.apache.thrift.protocol.TType.LIST, (short)2); - private static final org.apache.thrift.protocol.TField ANSWERS_FIELD_DESC = new org.apache.thrift.protocol.TField("answers", org.apache.thrift.protocol.TType.LIST, (short)3); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new QuestionStandardSchemeFactory()); - schemes.put(TupleScheme.class, new QuestionTupleSchemeFactory()); - } - - public String questionText; // required - public List assets; // required - public List answers; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - QUESTION_TEXT((short)1, "questionText"), - ASSETS((short)2, "assets"), - ANSWERS((short)3, "answers"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // QUESTION_TEXT - return QUESTION_TEXT; - case 2: // ASSETS - return ASSETS; - case 3: // ANSWERS - return ANSWERS; - 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.QUESTION_TEXT, new org.apache.thrift.meta_data.FieldMetaData("questionText", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.ASSETS, new org.apache.thrift.meta_data.FieldMetaData("assets", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "Asset")))); - tmpMap.put(_Fields.ANSWERS, new org.apache.thrift.meta_data.FieldMetaData("answers", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "Answer")))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Question.class, metaDataMap); - } - - public Question() { - } - - public Question( - String questionText, - List assets, - List answers) - { - this(); - this.questionText = questionText; - this.assets = assets; - this.answers = answers; - } - - /** - * Performs a deep copy on other. - */ - public Question(Question other) { - if (other.isSetQuestionText()) { - this.questionText = other.questionText; - } - if (other.isSetAssets()) { - List __this__assets = new ArrayList(other.assets.size()); - for (Asset other_element : other.assets) { - __this__assets.add(other_element); - } - this.assets = __this__assets; - } - if (other.isSetAnswers()) { - List __this__answers = new ArrayList(other.answers.size()); - for (Answer other_element : other.answers) { - __this__answers.add(other_element); - } - this.answers = __this__answers; - } - } - - public Question deepCopy() { - return new Question(this); - } - - @Override - public void clear() { - this.questionText = null; - this.assets = null; - this.answers = null; - } - - public String getQuestionText() { - return this.questionText; - } - - public Question setQuestionText(String questionText) { - this.questionText = questionText; - return this; - } - - public void unsetQuestionText() { - this.questionText = null; - } - - /** Returns true if field questionText is set (has been assigned a value) and false otherwise */ - public boolean isSetQuestionText() { - return this.questionText != null; - } - - public void setQuestionTextIsSet(boolean value) { - if (!value) { - this.questionText = null; - } - } - - public int getAssetsSize() { - return (this.assets == null) ? 0 : this.assets.size(); - } - - public java.util.Iterator getAssetsIterator() { - return (this.assets == null) ? null : this.assets.iterator(); - } - - public void addToAssets(Asset elem) { - if (this.assets == null) { - this.assets = new ArrayList(); - } - this.assets.add(elem); - } - - public List getAssets() { - return this.assets; - } - - public Question setAssets(List assets) { - this.assets = assets; - return this; - } - - public void unsetAssets() { - this.assets = null; - } - - /** Returns true if field assets is set (has been assigned a value) and false otherwise */ - public boolean isSetAssets() { - return this.assets != null; - } - - public void setAssetsIsSet(boolean value) { - if (!value) { - this.assets = null; - } - } - - public int getAnswersSize() { - return (this.answers == null) ? 0 : this.answers.size(); - } - - public java.util.Iterator getAnswersIterator() { - return (this.answers == null) ? null : this.answers.iterator(); - } - - public void addToAnswers(Answer elem) { - if (this.answers == null) { - this.answers = new ArrayList(); - } - this.answers.add(elem); - } - - public List getAnswers() { - return this.answers; - } - - public Question setAnswers(List answers) { - this.answers = answers; - return this; - } - - public void unsetAnswers() { - this.answers = null; - } - - /** Returns true if field answers is set (has been assigned a value) and false otherwise */ - public boolean isSetAnswers() { - return this.answers != null; - } - - public void setAnswersIsSet(boolean value) { - if (!value) { - this.answers = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case QUESTION_TEXT: - if (value == null) { - unsetQuestionText(); - } else { - setQuestionText((String)value); - } - break; - - case ASSETS: - if (value == null) { - unsetAssets(); - } else { - setAssets((List)value); - } - break; - - case ANSWERS: - if (value == null) { - unsetAnswers(); - } else { - setAnswers((List)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case QUESTION_TEXT: - return getQuestionText(); - - case ASSETS: - return getAssets(); - - case ANSWERS: - return getAnswers(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case QUESTION_TEXT: - return isSetQuestionText(); - case ASSETS: - return isSetAssets(); - case ANSWERS: - return isSetAnswers(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof Question) - return this.equals((Question)that); - return false; - } - - public boolean equals(Question that) { - if (that == null) - return false; - - boolean this_present_questionText = true && this.isSetQuestionText(); - boolean that_present_questionText = true && that.isSetQuestionText(); - if (this_present_questionText || that_present_questionText) { - if (!(this_present_questionText && that_present_questionText)) - return false; - if (!this.questionText.equals(that.questionText)) - return false; - } - - boolean this_present_assets = true && this.isSetAssets(); - boolean that_present_assets = true && that.isSetAssets(); - if (this_present_assets || that_present_assets) { - if (!(this_present_assets && that_present_assets)) - return false; - if (!this.assets.equals(that.assets)) - return false; - } - - boolean this_present_answers = true && this.isSetAnswers(); - boolean that_present_answers = true && that.isSetAnswers(); - if (this_present_answers || that_present_answers) { - if (!(this_present_answers && that_present_answers)) - return false; - if (!this.answers.equals(that.answers)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - List list = new ArrayList(); - - boolean present_questionText = true && (isSetQuestionText()); - list.add(present_questionText); - if (present_questionText) - list.add(questionText); - - boolean present_assets = true && (isSetAssets()); - list.add(present_assets); - if (present_assets) - list.add(assets); - - boolean present_answers = true && (isSetAnswers()); - list.add(present_answers); - if (present_answers) - list.add(answers); - - return list.hashCode(); - } - - @Override - public int compareTo(Question other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetQuestionText()).compareTo(other.isSetQuestionText()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetQuestionText()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.questionText, other.questionText); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetAssets()).compareTo(other.isSetAssets()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetAssets()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.assets, other.assets); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetAnswers()).compareTo(other.isSetAnswers()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetAnswers()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.answers, other.answers); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("Question("); - boolean first = true; - - sb.append("questionText:"); - if (this.questionText == null) { - sb.append("null"); - } else { - sb.append(this.questionText); - } - first = false; - if (!first) sb.append(", "); - sb.append("assets:"); - if (this.assets == null) { - sb.append("null"); - } else { - sb.append(this.assets); - } - first = false; - if (!first) sb.append(", "); - sb.append("answers:"); - if (this.answers == null) { - sb.append("null"); - } else { - sb.append(this.answers); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (questionText == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'questionText' was not present! Struct: " + toString()); - } - if (assets == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'assets' was not present! Struct: " + toString()); - } - if (answers == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'answers' was not present! Struct: " + toString()); - } - // check for sub-struct validity - } - - 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, 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); - } - } - - private static class QuestionStandardSchemeFactory implements SchemeFactory { - public QuestionStandardScheme getScheme() { - return new QuestionStandardScheme(); - } - } - - private static class QuestionStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, Question struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // QUESTION_TEXT - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.questionText = iprot.readString(); - struct.setQuestionTextIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // ASSETS - if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { - { - org.apache.thrift.protocol.TList _list16 = iprot.readListBegin(); - struct.assets = new ArrayList(_list16.size); - Asset _elem17; - for (int _i18 = 0; _i18 < _list16.size; ++_i18) - { - _elem17 = new Asset(); - _elem17.read(iprot); - struct.assets.add(_elem17); - } - iprot.readListEnd(); - } - struct.setAssetsIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // ANSWERS - if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { - { - org.apache.thrift.protocol.TList _list19 = iprot.readListBegin(); - struct.answers = new ArrayList(_list19.size); - Answer _elem20; - for (int _i21 = 0; _i21 < _list19.size; ++_i21) - { - _elem20 = new Answer(); - _elem20.read(iprot); - struct.answers.add(_elem20); - } - iprot.readListEnd(); - } - struct.setAnswersIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, Question struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.questionText != null) { - oprot.writeFieldBegin(QUESTION_TEXT_FIELD_DESC); - oprot.writeString(struct.questionText); - oprot.writeFieldEnd(); - } - if (struct.assets != null) { - oprot.writeFieldBegin(ASSETS_FIELD_DESC); - { - oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.assets.size())); - for (Asset _iter22 : struct.assets) - { - _iter22.write(oprot); - } - oprot.writeListEnd(); - } - oprot.writeFieldEnd(); - } - if (struct.answers != null) { - oprot.writeFieldBegin(ANSWERS_FIELD_DESC); - { - oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.answers.size())); - for (Answer _iter23 : struct.answers) - { - _iter23.write(oprot); - } - oprot.writeListEnd(); - } - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class QuestionTupleSchemeFactory implements SchemeFactory { - public QuestionTupleScheme getScheme() { - return new QuestionTupleScheme(); - } - } - - private static class QuestionTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, Question struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - oprot.writeString(struct.questionText); - { - oprot.writeI32(struct.assets.size()); - for (Asset _iter24 : struct.assets) - { - _iter24.write(oprot); - } - } - { - oprot.writeI32(struct.answers.size()); - for (Answer _iter25 : struct.answers) - { - _iter25.write(oprot); - } - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, Question struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - struct.questionText = iprot.readString(); - struct.setQuestionTextIsSet(true); - { - org.apache.thrift.protocol.TList _list26 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.assets = new ArrayList(_list26.size); - Asset _elem27; - for (int _i28 = 0; _i28 < _list26.size; ++_i28) - { - _elem27 = new Asset(); - _elem27.read(iprot); - struct.assets.add(_elem27); - } - } - struct.setAssetsIsSet(true); - { - org.apache.thrift.protocol.TList _list29 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.answers = new ArrayList(_list29.size); - Answer _elem30; - for (int _i31 = 0; _i31 < _list29.size; ++_i31) - { - _elem30 = new Answer(); - _elem30.read(iprot); - struct.answers.add(_elem30); - } - } - struct.setAnswersIsSet(true); - } - } - -} - diff --git a/generated/gen-java/tenfour/QuizContent.java b/generated/gen-java/tenfour/QuizContent.java deleted file mode 100644 index 157eadb..0000000 --- a/generated/gen-java/tenfour/QuizContent.java +++ /dev/null @@ -1,548 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.2) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package tenfour; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import javax.annotation.Generated; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") -public class QuizContent implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("QuizContent"); - - private static final org.apache.thrift.protocol.TField QUESTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("questions", org.apache.thrift.protocol.TType.LIST, (short)1); - private static final org.apache.thrift.protocol.TField RESULT_GROUPS_FIELD_DESC = new org.apache.thrift.protocol.TField("resultGroups", org.apache.thrift.protocol.TType.STRUCT, (short)2); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new QuizContentStandardSchemeFactory()); - schemes.put(TupleScheme.class, new QuizContentTupleSchemeFactory()); - } - - public List questions; // required - public ResultGroups resultGroups; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - QUESTIONS((short)1, "questions"), - RESULT_GROUPS((short)2, "resultGroups"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // QUESTIONS - return QUESTIONS; - case 2: // RESULT_GROUPS - return RESULT_GROUPS; - 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.QUESTIONS, new org.apache.thrift.meta_data.FieldMetaData("questions", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "Question")))); - tmpMap.put(_Fields.RESULT_GROUPS, new org.apache.thrift.meta_data.FieldMetaData("resultGroups", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "ResultGroups"))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(QuizContent.class, metaDataMap); - } - - public QuizContent() { - } - - public QuizContent( - List questions, - ResultGroups resultGroups) - { - this(); - this.questions = questions; - this.resultGroups = resultGroups; - } - - /** - * Performs a deep copy on other. - */ - public QuizContent(QuizContent other) { - if (other.isSetQuestions()) { - List __this__questions = new ArrayList(other.questions.size()); - for (Question other_element : other.questions) { - __this__questions.add(other_element); - } - this.questions = __this__questions; - } - if (other.isSetResultGroups()) { - this.resultGroups = other.resultGroups; - } - } - - public QuizContent deepCopy() { - return new QuizContent(this); - } - - @Override - public void clear() { - this.questions = null; - this.resultGroups = null; - } - - public int getQuestionsSize() { - return (this.questions == null) ? 0 : this.questions.size(); - } - - public java.util.Iterator getQuestionsIterator() { - return (this.questions == null) ? null : this.questions.iterator(); - } - - public void addToQuestions(Question elem) { - if (this.questions == null) { - this.questions = new ArrayList(); - } - this.questions.add(elem); - } - - public List getQuestions() { - return this.questions; - } - - public QuizContent setQuestions(List questions) { - this.questions = questions; - return this; - } - - public void unsetQuestions() { - this.questions = null; - } - - /** Returns true if field questions is set (has been assigned a value) and false otherwise */ - public boolean isSetQuestions() { - return this.questions != null; - } - - public void setQuestionsIsSet(boolean value) { - if (!value) { - this.questions = null; - } - } - - public ResultGroups getResultGroups() { - return this.resultGroups; - } - - public QuizContent setResultGroups(ResultGroups resultGroups) { - this.resultGroups = resultGroups; - return this; - } - - public void unsetResultGroups() { - this.resultGroups = null; - } - - /** Returns true if field resultGroups is set (has been assigned a value) and false otherwise */ - public boolean isSetResultGroups() { - return this.resultGroups != null; - } - - public void setResultGroupsIsSet(boolean value) { - if (!value) { - this.resultGroups = null; - } - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case QUESTIONS: - if (value == null) { - unsetQuestions(); - } else { - setQuestions((List)value); - } - break; - - case RESULT_GROUPS: - if (value == null) { - unsetResultGroups(); - } else { - setResultGroups((ResultGroups)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case QUESTIONS: - return getQuestions(); - - case RESULT_GROUPS: - return getResultGroups(); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case QUESTIONS: - return isSetQuestions(); - case RESULT_GROUPS: - return isSetResultGroups(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof QuizContent) - return this.equals((QuizContent)that); - return false; - } - - public boolean equals(QuizContent that) { - if (that == null) - return false; - - boolean this_present_questions = true && this.isSetQuestions(); - boolean that_present_questions = true && that.isSetQuestions(); - if (this_present_questions || that_present_questions) { - if (!(this_present_questions && that_present_questions)) - return false; - if (!this.questions.equals(that.questions)) - return false; - } - - boolean this_present_resultGroups = true && this.isSetResultGroups(); - boolean that_present_resultGroups = true && that.isSetResultGroups(); - if (this_present_resultGroups || that_present_resultGroups) { - if (!(this_present_resultGroups && that_present_resultGroups)) - return false; - if (!this.resultGroups.equals(that.resultGroups)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - List list = new ArrayList(); - - boolean present_questions = true && (isSetQuestions()); - list.add(present_questions); - if (present_questions) - list.add(questions); - - boolean present_resultGroups = true && (isSetResultGroups()); - list.add(present_resultGroups); - if (present_resultGroups) - list.add(resultGroups); - - return list.hashCode(); - } - - @Override - public int compareTo(QuizContent other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetQuestions()).compareTo(other.isSetQuestions()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetQuestions()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.questions, other.questions); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetResultGroups()).compareTo(other.isSetResultGroups()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetResultGroups()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.resultGroups, other.resultGroups); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("QuizContent("); - boolean first = true; - - sb.append("questions:"); - if (this.questions == null) { - sb.append("null"); - } else { - sb.append(this.questions); - } - first = false; - if (!first) sb.append(", "); - sb.append("resultGroups:"); - if (this.resultGroups == null) { - sb.append("null"); - } else { - sb.append(this.resultGroups); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (questions == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'questions' was not present! Struct: " + toString()); - } - if (resultGroups == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'resultGroups' was not present! Struct: " + toString()); - } - // check for sub-struct validity - } - - 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, 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); - } - } - - private static class QuizContentStandardSchemeFactory implements SchemeFactory { - public QuizContentStandardScheme getScheme() { - return new QuizContentStandardScheme(); - } - } - - private static class QuizContentStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, QuizContent struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // QUESTIONS - if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { - { - org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); - struct.questions = new ArrayList(_list0.size); - Question _elem1; - for (int _i2 = 0; _i2 < _list0.size; ++_i2) - { - _elem1 = new Question(); - _elem1.read(iprot); - struct.questions.add(_elem1); - } - iprot.readListEnd(); - } - struct.setQuestionsIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // RESULT_GROUPS - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.resultGroups = new ResultGroups(); - struct.resultGroups.read(iprot); - struct.setResultGroupsIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, QuizContent struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.questions != null) { - oprot.writeFieldBegin(QUESTIONS_FIELD_DESC); - { - oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.questions.size())); - for (Question _iter3 : struct.questions) - { - _iter3.write(oprot); - } - oprot.writeListEnd(); - } - oprot.writeFieldEnd(); - } - if (struct.resultGroups != null) { - oprot.writeFieldBegin(RESULT_GROUPS_FIELD_DESC); - struct.resultGroups.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class QuizContentTupleSchemeFactory implements SchemeFactory { - public QuizContentTupleScheme getScheme() { - return new QuizContentTupleScheme(); - } - } - - private static class QuizContentTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, QuizContent struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - { - oprot.writeI32(struct.questions.size()); - for (Question _iter4 : struct.questions) - { - _iter4.write(oprot); - } - } - struct.resultGroups.write(oprot); - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, QuizContent struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - { - org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.questions = new ArrayList(_list5.size); - Question _elem6; - for (int _i7 = 0; _i7 < _list5.size; ++_i7) - { - _elem6 = new Question(); - _elem6.read(iprot); - struct.questions.add(_elem6); - } - } - struct.setQuestionsIsSet(true); - struct.resultGroups = new ResultGroups(); - struct.resultGroups.read(iprot); - struct.setResultGroupsIsSet(true); - } - } - -} - diff --git a/generated/gen-java/tenfour/ResultGroup.java b/generated/gen-java/tenfour/ResultGroup.java deleted file mode 100644 index 62eced9..0000000 --- a/generated/gen-java/tenfour/ResultGroup.java +++ /dev/null @@ -1,592 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.2) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package tenfour; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import javax.annotation.Generated; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") -public class ResultGroup implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ResultGroup"); - - private static final org.apache.thrift.protocol.TField TITLE_FIELD_DESC = new org.apache.thrift.protocol.TField("title", org.apache.thrift.protocol.TType.STRING, (short)1); - private static final org.apache.thrift.protocol.TField SHARE_FIELD_DESC = new org.apache.thrift.protocol.TField("share", org.apache.thrift.protocol.TType.STRING, (short)2); - private static final org.apache.thrift.protocol.TField MIN_SCORE_FIELD_DESC = new org.apache.thrift.protocol.TField("minScore", org.apache.thrift.protocol.TType.I16, (short)3); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new ResultGroupStandardSchemeFactory()); - schemes.put(TupleScheme.class, new ResultGroupTupleSchemeFactory()); - } - - public String title; // required - public String share; // required - public short minScore; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - TITLE((short)1, "title"), - SHARE((short)2, "share"), - MIN_SCORE((short)3, "minScore"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // TITLE - return TITLE; - case 2: // SHARE - return SHARE; - case 3: // MIN_SCORE - return MIN_SCORE; - 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - private static final int __MINSCORE_ISSET_ID = 0; - private byte __isset_bitfield = 0; - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.TITLE, new org.apache.thrift.meta_data.FieldMetaData("title", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.SHARE, new org.apache.thrift.meta_data.FieldMetaData("share", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - tmpMap.put(_Fields.MIN_SCORE, new org.apache.thrift.meta_data.FieldMetaData("minScore", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ResultGroup.class, metaDataMap); - } - - public ResultGroup() { - } - - public ResultGroup( - String title, - String share, - short minScore) - { - this(); - this.title = title; - this.share = share; - this.minScore = minScore; - setMinScoreIsSet(true); - } - - /** - * Performs a deep copy on other. - */ - public ResultGroup(ResultGroup other) { - __isset_bitfield = other.__isset_bitfield; - if (other.isSetTitle()) { - this.title = other.title; - } - if (other.isSetShare()) { - this.share = other.share; - } - this.minScore = other.minScore; - } - - public ResultGroup deepCopy() { - return new ResultGroup(this); - } - - @Override - public void clear() { - this.title = null; - this.share = null; - setMinScoreIsSet(false); - this.minScore = 0; - } - - public String getTitle() { - return this.title; - } - - public ResultGroup setTitle(String title) { - this.title = title; - return this; - } - - public void unsetTitle() { - this.title = null; - } - - /** Returns true if field title is set (has been assigned a value) and false otherwise */ - public boolean isSetTitle() { - return this.title != null; - } - - public void setTitleIsSet(boolean value) { - if (!value) { - this.title = null; - } - } - - public String getShare() { - return this.share; - } - - public ResultGroup setShare(String share) { - this.share = share; - return this; - } - - public void unsetShare() { - this.share = null; - } - - /** Returns true if field share is set (has been assigned a value) and false otherwise */ - public boolean isSetShare() { - return this.share != null; - } - - public void setShareIsSet(boolean value) { - if (!value) { - this.share = null; - } - } - - public short getMinScore() { - return this.minScore; - } - - public ResultGroup setMinScore(short minScore) { - this.minScore = minScore; - setMinScoreIsSet(true); - return this; - } - - public void unsetMinScore() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __MINSCORE_ISSET_ID); - } - - /** Returns true if field minScore is set (has been assigned a value) and false otherwise */ - public boolean isSetMinScore() { - return EncodingUtils.testBit(__isset_bitfield, __MINSCORE_ISSET_ID); - } - - public void setMinScoreIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __MINSCORE_ISSET_ID, value); - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case TITLE: - if (value == null) { - unsetTitle(); - } else { - setTitle((String)value); - } - break; - - case SHARE: - if (value == null) { - unsetShare(); - } else { - setShare((String)value); - } - break; - - case MIN_SCORE: - if (value == null) { - unsetMinScore(); - } else { - setMinScore((Short)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case TITLE: - return getTitle(); - - case SHARE: - return getShare(); - - case MIN_SCORE: - return Short.valueOf(getMinScore()); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case TITLE: - return isSetTitle(); - case SHARE: - return isSetShare(); - case MIN_SCORE: - return isSetMinScore(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof ResultGroup) - return this.equals((ResultGroup)that); - return false; - } - - public boolean equals(ResultGroup that) { - if (that == null) - return false; - - boolean this_present_title = true && this.isSetTitle(); - boolean that_present_title = true && that.isSetTitle(); - if (this_present_title || that_present_title) { - if (!(this_present_title && that_present_title)) - return false; - if (!this.title.equals(that.title)) - return false; - } - - boolean this_present_share = true && this.isSetShare(); - boolean that_present_share = true && that.isSetShare(); - if (this_present_share || that_present_share) { - if (!(this_present_share && that_present_share)) - return false; - if (!this.share.equals(that.share)) - return false; - } - - boolean this_present_minScore = true; - boolean that_present_minScore = true; - if (this_present_minScore || that_present_minScore) { - if (!(this_present_minScore && that_present_minScore)) - return false; - if (this.minScore != that.minScore) - return false; - } - - return true; - } - - @Override - public int hashCode() { - List list = new ArrayList(); - - boolean present_title = true && (isSetTitle()); - list.add(present_title); - if (present_title) - list.add(title); - - boolean present_share = true && (isSetShare()); - list.add(present_share); - if (present_share) - list.add(share); - - boolean present_minScore = true; - list.add(present_minScore); - if (present_minScore) - list.add(minScore); - - return list.hashCode(); - } - - @Override - public int compareTo(ResultGroup other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetTitle()).compareTo(other.isSetTitle()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetTitle()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.title, other.title); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetShare()).compareTo(other.isSetShare()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetShare()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.share, other.share); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetMinScore()).compareTo(other.isSetMinScore()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetMinScore()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.minScore, other.minScore); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("ResultGroup("); - boolean first = true; - - sb.append("title:"); - if (this.title == null) { - sb.append("null"); - } else { - sb.append(this.title); - } - first = false; - if (!first) sb.append(", "); - sb.append("share:"); - if (this.share == null) { - sb.append("null"); - } else { - sb.append(this.share); - } - first = false; - if (!first) sb.append(", "); - sb.append("minScore:"); - sb.append(this.minScore); - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (title == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'title' was not present! Struct: " + toString()); - } - if (share == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'share' was not present! Struct: " + toString()); - } - // alas, we cannot check 'minScore' because it's a primitive and you chose the non-beans generator. - // check for sub-struct validity - } - - 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, ClassNotFoundException { - try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class ResultGroupStandardSchemeFactory implements SchemeFactory { - public ResultGroupStandardScheme getScheme() { - return new ResultGroupStandardScheme(); - } - } - - private static class ResultGroupStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, ResultGroup struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // TITLE - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.title = iprot.readString(); - struct.setTitleIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // SHARE - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.share = iprot.readString(); - struct.setShareIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 3: // MIN_SCORE - if (schemeField.type == org.apache.thrift.protocol.TType.I16) { - struct.minScore = iprot.readI16(); - struct.setMinScoreIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - if (!struct.isSetMinScore()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'minScore' was not found in serialized data! Struct: " + toString()); - } - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, ResultGroup struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.title != null) { - oprot.writeFieldBegin(TITLE_FIELD_DESC); - oprot.writeString(struct.title); - oprot.writeFieldEnd(); - } - if (struct.share != null) { - oprot.writeFieldBegin(SHARE_FIELD_DESC); - oprot.writeString(struct.share); - oprot.writeFieldEnd(); - } - oprot.writeFieldBegin(MIN_SCORE_FIELD_DESC); - oprot.writeI16(struct.minScore); - oprot.writeFieldEnd(); - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class ResultGroupTupleSchemeFactory implements SchemeFactory { - public ResultGroupTupleScheme getScheme() { - return new ResultGroupTupleScheme(); - } - } - - private static class ResultGroupTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, ResultGroup struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - oprot.writeString(struct.title); - oprot.writeString(struct.share); - oprot.writeI16(struct.minScore); - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, ResultGroup struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - struct.title = iprot.readString(); - struct.setTitleIsSet(true); - struct.share = iprot.readString(); - struct.setShareIsSet(true); - struct.minScore = iprot.readI16(); - struct.setMinScoreIsSet(true); - } - } - -} - diff --git a/generated/gen-java/tenfour/ResultGroups.java b/generated/gen-java/tenfour/ResultGroups.java deleted file mode 100644 index a07713a..0000000 --- a/generated/gen-java/tenfour/ResultGroups.java +++ /dev/null @@ -1,545 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.9.2) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package tenfour; - -import org.apache.thrift.scheme.IScheme; -import org.apache.thrift.scheme.SchemeFactory; -import org.apache.thrift.scheme.StandardScheme; - -import org.apache.thrift.scheme.TupleScheme; -import org.apache.thrift.protocol.TTupleProtocol; -import org.apache.thrift.protocol.TProtocolException; -import org.apache.thrift.EncodingUtils; -import org.apache.thrift.TException; -import org.apache.thrift.async.AsyncMethodCallback; -import org.apache.thrift.server.AbstractNonblockingServer.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.HashMap; -import java.util.EnumMap; -import java.util.Set; -import java.util.HashSet; -import java.util.EnumSet; -import java.util.Collections; -import java.util.BitSet; -import java.nio.ByteBuffer; -import java.util.Arrays; -import javax.annotation.Generated; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"}) -@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-8-27") -public class ResultGroups implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ResultGroups"); - - private static final org.apache.thrift.protocol.TField GROUPS_FIELD_DESC = new org.apache.thrift.protocol.TField("groups", org.apache.thrift.protocol.TType.LIST, (short)1); - private static final org.apache.thrift.protocol.TField REVEAL_AT_END_FIELD_DESC = new org.apache.thrift.protocol.TField("revealAtEnd", org.apache.thrift.protocol.TType.BOOL, (short)2); - - private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); - static { - schemes.put(StandardScheme.class, new ResultGroupsStandardSchemeFactory()); - schemes.put(TupleScheme.class, new ResultGroupsTupleSchemeFactory()); - } - - public List groups; // required - public boolean revealAtEnd; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - GROUPS((short)1, "groups"), - REVEAL_AT_END((short)2, "revealAtEnd"); - - private static final Map byName = new HashMap(); - - static { - for (_Fields field : EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // GROUPS - return GROUPS; - case 2: // REVEAL_AT_END - return REVEAL_AT_END; - 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 IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(String name) { - return byName.get(name); - } - - private final short _thriftId; - private final String _fieldName; - - _Fields(short thriftId, String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - private static final int __REVEALATEND_ISSET_ID = 0; - private byte __isset_bitfield = 0; - public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.GROUPS, new org.apache.thrift.meta_data.FieldMetaData("groups", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "ResultGroup")))); - tmpMap.put(_Fields.REVEAL_AT_END, new org.apache.thrift.meta_data.FieldMetaData("revealAtEnd", org.apache.thrift.TFieldRequirementType.REQUIRED, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL))); - metaDataMap = Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ResultGroups.class, metaDataMap); - } - - public ResultGroups() { - } - - public ResultGroups( - List groups, - boolean revealAtEnd) - { - this(); - this.groups = groups; - this.revealAtEnd = revealAtEnd; - setRevealAtEndIsSet(true); - } - - /** - * Performs a deep copy on other. - */ - public ResultGroups(ResultGroups other) { - __isset_bitfield = other.__isset_bitfield; - if (other.isSetGroups()) { - List __this__groups = new ArrayList(other.groups.size()); - for (ResultGroup other_element : other.groups) { - __this__groups.add(other_element); - } - this.groups = __this__groups; - } - this.revealAtEnd = other.revealAtEnd; - } - - public ResultGroups deepCopy() { - return new ResultGroups(this); - } - - @Override - public void clear() { - this.groups = null; - setRevealAtEndIsSet(false); - this.revealAtEnd = false; - } - - public int getGroupsSize() { - return (this.groups == null) ? 0 : this.groups.size(); - } - - public java.util.Iterator getGroupsIterator() { - return (this.groups == null) ? null : this.groups.iterator(); - } - - public void addToGroups(ResultGroup elem) { - if (this.groups == null) { - this.groups = new ArrayList(); - } - this.groups.add(elem); - } - - public List getGroups() { - return this.groups; - } - - public ResultGroups setGroups(List groups) { - this.groups = groups; - return this; - } - - public void unsetGroups() { - this.groups = null; - } - - /** Returns true if field groups is set (has been assigned a value) and false otherwise */ - public boolean isSetGroups() { - return this.groups != null; - } - - public void setGroupsIsSet(boolean value) { - if (!value) { - this.groups = null; - } - } - - public boolean isRevealAtEnd() { - return this.revealAtEnd; - } - - public ResultGroups setRevealAtEnd(boolean revealAtEnd) { - this.revealAtEnd = revealAtEnd; - setRevealAtEndIsSet(true); - return this; - } - - public void unsetRevealAtEnd() { - __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __REVEALATEND_ISSET_ID); - } - - /** Returns true if field revealAtEnd is set (has been assigned a value) and false otherwise */ - public boolean isSetRevealAtEnd() { - return EncodingUtils.testBit(__isset_bitfield, __REVEALATEND_ISSET_ID); - } - - public void setRevealAtEndIsSet(boolean value) { - __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __REVEALATEND_ISSET_ID, value); - } - - public void setFieldValue(_Fields field, Object value) { - switch (field) { - case GROUPS: - if (value == null) { - unsetGroups(); - } else { - setGroups((List)value); - } - break; - - case REVEAL_AT_END: - if (value == null) { - unsetRevealAtEnd(); - } else { - setRevealAtEnd((Boolean)value); - } - break; - - } - } - - public Object getFieldValue(_Fields field) { - switch (field) { - case GROUPS: - return getGroups(); - - case REVEAL_AT_END: - return Boolean.valueOf(isRevealAtEnd()); - - } - throw new IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new IllegalArgumentException(); - } - - switch (field) { - case GROUPS: - return isSetGroups(); - case REVEAL_AT_END: - return isSetRevealAtEnd(); - } - throw new IllegalStateException(); - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof ResultGroups) - return this.equals((ResultGroups)that); - return false; - } - - public boolean equals(ResultGroups that) { - if (that == null) - return false; - - boolean this_present_groups = true && this.isSetGroups(); - boolean that_present_groups = true && that.isSetGroups(); - if (this_present_groups || that_present_groups) { - if (!(this_present_groups && that_present_groups)) - return false; - if (!this.groups.equals(that.groups)) - return false; - } - - boolean this_present_revealAtEnd = true; - boolean that_present_revealAtEnd = true; - if (this_present_revealAtEnd || that_present_revealAtEnd) { - if (!(this_present_revealAtEnd && that_present_revealAtEnd)) - return false; - if (this.revealAtEnd != that.revealAtEnd) - return false; - } - - return true; - } - - @Override - public int hashCode() { - List list = new ArrayList(); - - boolean present_groups = true && (isSetGroups()); - list.add(present_groups); - if (present_groups) - list.add(groups); - - boolean present_revealAtEnd = true; - list.add(present_revealAtEnd); - if (present_revealAtEnd) - list.add(revealAtEnd); - - return list.hashCode(); - } - - @Override - public int compareTo(ResultGroups other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = Boolean.valueOf(isSetGroups()).compareTo(other.isSetGroups()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetGroups()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.groups, other.groups); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = Boolean.valueOf(isSetRevealAtEnd()).compareTo(other.isSetRevealAtEnd()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetRevealAtEnd()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.revealAtEnd, other.revealAtEnd); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - schemes.get(iprot.getScheme()).getScheme().read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - schemes.get(oprot.getScheme()).getScheme().write(oprot, this); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("ResultGroups("); - boolean first = true; - - sb.append("groups:"); - if (this.groups == null) { - sb.append("null"); - } else { - sb.append(this.groups); - } - first = false; - if (!first) sb.append(", "); - sb.append("revealAtEnd:"); - sb.append(this.revealAtEnd); - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - if (groups == null) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'groups' was not present! Struct: " + toString()); - } - // alas, we cannot check 'revealAtEnd' because it's a primitive and you chose the non-beans generator. - // check for sub-struct validity - } - - 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, ClassNotFoundException { - try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class ResultGroupsStandardSchemeFactory implements SchemeFactory { - public ResultGroupsStandardScheme getScheme() { - return new ResultGroupsStandardScheme(); - } - } - - private static class ResultGroupsStandardScheme extends StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, ResultGroups struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // GROUPS - if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { - { - org.apache.thrift.protocol.TList _list8 = iprot.readListBegin(); - struct.groups = new ArrayList(_list8.size); - ResultGroup _elem9; - for (int _i10 = 0; _i10 < _list8.size; ++_i10) - { - _elem9 = new ResultGroup(); - _elem9.read(iprot); - struct.groups.add(_elem9); - } - iprot.readListEnd(); - } - struct.setGroupsIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // REVEAL_AT_END - if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) { - struct.revealAtEnd = iprot.readBool(); - struct.setRevealAtEndIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - if (!struct.isSetRevealAtEnd()) { - throw new org.apache.thrift.protocol.TProtocolException("Required field 'revealAtEnd' was not found in serialized data! Struct: " + toString()); - } - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, ResultGroups struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.groups != null) { - oprot.writeFieldBegin(GROUPS_FIELD_DESC); - { - oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.groups.size())); - for (ResultGroup _iter11 : struct.groups) - { - _iter11.write(oprot); - } - oprot.writeListEnd(); - } - oprot.writeFieldEnd(); - } - oprot.writeFieldBegin(REVEAL_AT_END_FIELD_DESC); - oprot.writeBool(struct.revealAtEnd); - oprot.writeFieldEnd(); - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class ResultGroupsTupleSchemeFactory implements SchemeFactory { - public ResultGroupsTupleScheme getScheme() { - return new ResultGroupsTupleScheme(); - } - } - - private static class ResultGroupsTupleScheme extends TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, ResultGroups struct) throws org.apache.thrift.TException { - TTupleProtocol oprot = (TTupleProtocol) prot; - { - oprot.writeI32(struct.groups.size()); - for (ResultGroup _iter12 : struct.groups) - { - _iter12.write(oprot); - } - } - oprot.writeBool(struct.revealAtEnd); - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, ResultGroups struct) throws org.apache.thrift.TException { - TTupleProtocol iprot = (TTupleProtocol) prot; - { - org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.groups = new ArrayList(_list13.size); - ResultGroup _elem14; - for (int _i15 = 0; _i15 < _list13.size; ++_i15) - { - _elem14 = new ResultGroup(); - _elem14.read(iprot); - struct.groups.add(_elem14); - } - } - struct.setGroupsIsSet(true); - struct.revealAtEnd = iprot.readBool(); - struct.setRevealAtEndIsSet(true); - } - } - -} - From 0418bcd569f817b6934ecfa465c403bf4aabae8f Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Fri, 28 Aug 2015 11:40:12 +0100 Subject: [PATCH 09/18] use an enum for the atom type --- generated/gen-nodejs/events_types.js | 35 ++++++++-------------------- thrift/events.thrift | 4 +++- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/generated/gen-nodejs/events_types.js b/generated/gen-nodejs/events_types.js index e055127..cd08c0b 100644 --- a/generated/gen-nodejs/events_types.js +++ b/generated/gen-nodejs/events_types.js @@ -16,9 +16,11 @@ ttypes.EventType = { 'UPDATE' : 1, 'TAKEDOWN' : 2 }; +ttypes.AtomType = { + 'TENFOUR_QUIZ' : 0 +}; ContentAtomEvent = module.exports.ContentAtomEvent = function(args) { this.id = null; - this.url = null; this.atomType = null; this.eventType = null; this.data = null; @@ -28,11 +30,6 @@ ContentAtomEvent = module.exports.ContentAtomEvent = function(args) { } else { throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field id is unset!'); } - if (args.url !== undefined) { - this.url = args.url; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field url is unset!'); - } if (args.atomType !== undefined) { this.atomType = args.atomType; } else { @@ -72,27 +69,20 @@ ContentAtomEvent.prototype.read = function(input) { } break; case 2: - if (ftype == Thrift.Type.STRING) { - this.url = input.readString(); + if (ftype == Thrift.Type.I32) { + this.atomType = input.readI32(); } else { input.skip(ftype); } break; case 3: - if (ftype == Thrift.Type.STRING) { - this.atomType = input.readString(); - } else { - input.skip(ftype); - } - break; - case 4: if (ftype == Thrift.Type.I32) { this.eventType = input.readI32(); } else { input.skip(ftype); } break; - case 5: + case 4: if (ftype == Thrift.Type.STRUCT) { this.data = new contentatom_ttypes.ContentAtom(); this.data.read(input); @@ -116,23 +106,18 @@ ContentAtomEvent.prototype.write = function(output) { output.writeString(this.id); output.writeFieldEnd(); } - if (this.url !== null && this.url !== undefined) { - output.writeFieldBegin('url', Thrift.Type.STRING, 2); - output.writeString(this.url); - output.writeFieldEnd(); - } if (this.atomType !== null && this.atomType !== undefined) { - output.writeFieldBegin('atomType', Thrift.Type.STRING, 3); - output.writeString(this.atomType); + output.writeFieldBegin('atomType', Thrift.Type.I32, 2); + output.writeI32(this.atomType); output.writeFieldEnd(); } if (this.eventType !== null && this.eventType !== undefined) { - output.writeFieldBegin('eventType', Thrift.Type.I32, 4); + output.writeFieldBegin('eventType', Thrift.Type.I32, 3); output.writeI32(this.eventType); output.writeFieldEnd(); } if (this.data !== null && this.data !== undefined) { - output.writeFieldBegin('data', Thrift.Type.STRUCT, 5); + output.writeFieldBegin('data', Thrift.Type.STRUCT, 4); this.data.write(output); output.writeFieldEnd(); } diff --git a/thrift/events.thrift b/thrift/events.thrift index d21afa8..6bc094d 100644 --- a/thrift/events.thrift +++ b/thrift/events.thrift @@ -4,6 +4,8 @@ typedef string ContentAtomID enum EventType { PUBLISH, UPDATE, TAKEDOWN } +enum AtomType { TENFOUR_QUIZ } + struct ContentAtomEvent { /* this opaque identifier should uniquely identify this content atom @@ -12,7 +14,7 @@ struct ContentAtomEvent { 1: required ContentAtomID id - 2: required string atomType + 2: required AtomType atomType 3: required EventType eventType From 77ae1ad70858924ec80bde8226173320f75eb991 Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Fri, 28 Aug 2015 11:44:47 +0100 Subject: [PATCH 10/18] disambiguate naming --- thrift/atoms/tenfour.thrift | 2 +- thrift/events.thrift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/thrift/atoms/tenfour.thrift b/thrift/atoms/tenfour.thrift index 22e5c04..290d7a6 100644 --- a/thrift/atoms/tenfour.thrift +++ b/thrift/atoms/tenfour.thrift @@ -5,7 +5,7 @@ include "../shared.thrift" /** date times are reprsented as i64 - epoch millis */ typedef i64 DateTime -struct Content { +struct TenfourQuizBuilderAtom { // do we need to store the ID, seeing as it is replicated(?) in the // content-atom wrapping? 1 : required string id diff --git a/thrift/events.thrift b/thrift/events.thrift index 6bc094d..6d25548 100644 --- a/thrift/events.thrift +++ b/thrift/events.thrift @@ -4,7 +4,7 @@ typedef string ContentAtomID enum EventType { PUBLISH, UPDATE, TAKEDOWN } -enum AtomType { TENFOUR_QUIZ } +enum AtomType { TENFOUR_QUIZ_BUILDER } struct ContentAtomEvent { From 8242da3aa9b1b67df36254513265d1ee59a3b3cd Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Wed, 2 Sep 2015 12:49:17 +0100 Subject: [PATCH 11/18] minor changes --- build.sh | 3 ++- generated/gen-nodejs/contentatom_types.js | 2 +- generated/gen-nodejs/events_types.js | 2 +- generated/gen-nodejs/tenfour_types.js | 10 +++++----- package.json | 2 +- thrift/contentatom.thrift | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/build.sh b/build.sh index 2b9b5b3..f691d50 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ LANGUAGES=("js:node") -THRIFT_VERBOSE="-v" +THRIFT_VERBOSE="" while getopts "q" OPT do @@ -55,6 +55,7 @@ function thrift { for file in "${THRIFT_FILES[@]}" do + echo "FILE: $file" $THRIFT_CMD $THRIFT_VERBOSE --recurse -o ${OUT_DIR} $LANG_OPTS "$file" done } diff --git a/generated/gen-nodejs/contentatom_types.js b/generated/gen-nodejs/contentatom_types.js index e778770..6a3f5b3 100644 --- a/generated/gen-nodejs/contentatom_types.js +++ b/generated/gen-nodejs/contentatom_types.js @@ -35,7 +35,7 @@ ContentAtom.prototype.read = function(input) { { case 1: if (ftype == Thrift.Type.STRUCT) { - this.tenfour = new tenfour_ttypes.Content(); + this.tenfour = new tenfour_ttypes.TenfourQuizBuilderAtom(); this.tenfour.read(input); } else { input.skip(ftype); diff --git a/generated/gen-nodejs/events_types.js b/generated/gen-nodejs/events_types.js index cd08c0b..3db4c05 100644 --- a/generated/gen-nodejs/events_types.js +++ b/generated/gen-nodejs/events_types.js @@ -17,7 +17,7 @@ ttypes.EventType = { 'TAKEDOWN' : 2 }; ttypes.AtomType = { - 'TENFOUR_QUIZ' : 0 + 'TENFOUR_QUIZ_BUILDER' : 0 }; ContentAtomEvent = module.exports.ContentAtomEvent = function(args) { this.id = null; diff --git a/generated/gen-nodejs/tenfour_types.js b/generated/gen-nodejs/tenfour_types.js index bfe5021..3b02106 100644 --- a/generated/gen-nodejs/tenfour_types.js +++ b/generated/gen-nodejs/tenfour_types.js @@ -14,7 +14,7 @@ var ttypes = module.exports = {}; if (typeof tenfour === 'undefined') { tenfour = {}; } -tenfour.Content = module.exports.Content = function(args) { +tenfour.TenfourQuizBuilderAtom = module.exports.TenfourQuizBuilderAtom = function(args) { this.id = null; this.title = null; this.updatedBy = null; @@ -76,8 +76,8 @@ tenfour.Content = module.exports.Content = function(args) { } } }; -tenfour.Content.prototype = {}; -tenfour.Content.prototype.read = function(input) { +tenfour.TenfourQuizBuilderAtom.prototype = {}; +tenfour.TenfourQuizBuilderAtom.prototype.read = function(input) { input.readStructBegin(); while (true) { @@ -170,8 +170,8 @@ tenfour.Content.prototype.read = function(input) { return; }; -tenfour.Content.prototype.write = function(output) { - output.writeStructBegin('Content'); +tenfour.TenfourQuizBuilderAtom.prototype.write = function(output) { + output.writeStructBegin('TenfourQuizBuilderAtom'); if (this.id !== null && this.id !== undefined) { output.writeFieldBegin('id', Thrift.Type.STRING, 1); output.writeString(this.id); diff --git a/package.json b/package.json index f6154f3..13d08e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "content-atom-js", - "version": "1.0.0", + "version": "0.2.0", "description": "Tool for building Guardian quiz JSON", "repository": "https://github.com/guardian/ten-four", "main": "js/main.js", diff --git a/thrift/contentatom.thrift b/thrift/contentatom.thrift index c94c0a1..71f5857 100644 --- a/thrift/contentatom.thrift +++ b/thrift/contentatom.thrift @@ -1,5 +1,5 @@ include "atoms/tenfour.thrift" union ContentAtom { - 1: tenfour.Content tenfour + 1: tenfour.TenfourQuizBuilderAtom tenfour } From 6560d2176c5c8f087a80a1adf0040dbed901a40f Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Wed, 2 Sep 2015 14:54:16 +0100 Subject: [PATCH 12/18] updating model after whiteboard session --- generated/gen-nodejs/contentatom_types.js | 273 +++++- generated/gen-nodejs/quiz_types.js | 892 +++++++++++++++++++ thrift/atoms/{tenfour.thrift => quiz.thrift} | 11 +- thrift/contentatom.thrift | 27 +- thrift/events.thrift | 22 - thrift/shared.thrift | 3 + 6 files changed, 1182 insertions(+), 46 deletions(-) create mode 100644 generated/gen-nodejs/quiz_types.js rename thrift/atoms/{tenfour.thrift => quiz.thrift} (85%) delete mode 100644 thrift/events.thrift diff --git a/generated/gen-nodejs/contentatom_types.js b/generated/gen-nodejs/contentatom_types.js index 6a3f5b3..11d6ff8 100644 --- a/generated/gen-nodejs/contentatom_types.js +++ b/generated/gen-nodejs/contentatom_types.js @@ -7,20 +7,55 @@ var thrift = require('thrift'); var Thrift = thrift.Thrift; var Q = thrift.Q; -var tenfour_ttypes = require('./tenfour_types') +var quiz_ttypes = require('./quiz_types') +var shared_ttypes = require('./shared_types') var ttypes = module.exports = {}; -ContentAtom = module.exports.ContentAtom = function(args) { - this.tenfour = null; +ttypes.AtomType = { + 'QUIZ' : 0 +}; +ttypes.EventType = { + 'PUBLISH' : 0, + 'UPDATE' : 1, + 'TAKEDOWN' : 2 +}; +Atom = module.exports.Atom = function(args) { + this.id = null; + this.atomType = null; + this.labels = null; + this.defaultBody = null; + this.data = null; if (args) { - if (args.tenfour !== undefined) { - this.tenfour = args.tenfour; + if (args.id !== undefined) { + this.id = args.id; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field id is unset!'); + } + if (args.atomType !== undefined) { + this.atomType = args.atomType; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field atomType is unset!'); + } + if (args.labels !== undefined) { + this.labels = args.labels; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field labels is unset!'); + } + if (args.defaultBody !== undefined) { + this.defaultBody = args.defaultBody; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field defaultBody is unset!'); + } + if (args.data !== undefined) { + this.data = args.data; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field data is unset!'); } } }; -ContentAtom.prototype = {}; -ContentAtom.prototype.read = function(input) { +Atom.prototype = {}; +Atom.prototype.read = function(input) { input.readStructBegin(); while (true) { @@ -34,9 +69,130 @@ ContentAtom.prototype.read = function(input) { switch (fid) { case 1: + if (ftype == Thrift.Type.STRING) { + this.id = input.readString(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.I32) { + this.atomType = input.readI32(); + } else { + input.skip(ftype); + } + break; + case 3: + if (ftype == Thrift.Type.LIST) { + var _size0 = 0; + var _rtmp34; + this.labels = []; + var _etype3 = 0; + _rtmp34 = input.readListBegin(); + _etype3 = _rtmp34.etype; + _size0 = _rtmp34.size; + for (var _i5 = 0; _i5 < _size0; ++_i5) + { + var elem6 = null; + elem6 = input.readString(); + this.labels.push(elem6); + } + input.readListEnd(); + } else { + input.skip(ftype); + } + break; + case 4: + if (ftype == Thrift.Type.STRING) { + this.defaultBody = input.readString(); + } else { + input.skip(ftype); + } + break; + case 5: if (ftype == Thrift.Type.STRUCT) { - this.tenfour = new tenfour_ttypes.TenfourQuizBuilderAtom(); - this.tenfour.read(input); + this.data = new ttypes.AtomData(); + this.data.read(input); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +Atom.prototype.write = function(output) { + output.writeStructBegin('Atom'); + if (this.id !== null && this.id !== undefined) { + output.writeFieldBegin('id', Thrift.Type.STRING, 1); + output.writeString(this.id); + output.writeFieldEnd(); + } + if (this.atomType !== null && this.atomType !== undefined) { + output.writeFieldBegin('atomType', Thrift.Type.I32, 2); + output.writeI32(this.atomType); + output.writeFieldEnd(); + } + if (this.labels !== null && this.labels !== undefined) { + output.writeFieldBegin('labels', Thrift.Type.LIST, 3); + output.writeListBegin(Thrift.Type.STRING, this.labels.length); + for (var iter7 in this.labels) + { + if (this.labels.hasOwnProperty(iter7)) + { + iter7 = this.labels[iter7]; + output.writeString(iter7); + } + } + output.writeListEnd(); + output.writeFieldEnd(); + } + if (this.defaultBody !== null && this.defaultBody !== undefined) { + output.writeFieldBegin('defaultBody', Thrift.Type.STRING, 4); + output.writeString(this.defaultBody); + output.writeFieldEnd(); + } + if (this.data !== null && this.data !== undefined) { + output.writeFieldBegin('data', Thrift.Type.STRUCT, 5); + this.data.write(output); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +AtomData = module.exports.AtomData = function(args) { + this.quiz = null; + if (args) { + if (args.quiz !== undefined) { + this.quiz = args.quiz; + } + } +}; +AtomData.prototype = {}; +AtomData.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRUCT) { + this.quiz = new quiz_ttypes.QuizAtom(); + this.quiz.read(input); } else { input.skip(ftype); } @@ -53,11 +209,100 @@ ContentAtom.prototype.read = function(input) { return; }; -ContentAtom.prototype.write = function(output) { - output.writeStructBegin('ContentAtom'); - if (this.tenfour !== null && this.tenfour !== undefined) { - output.writeFieldBegin('tenfour', Thrift.Type.STRUCT, 1); - this.tenfour.write(output); +AtomData.prototype.write = function(output) { + output.writeStructBegin('AtomData'); + if (this.quiz !== null && this.quiz !== undefined) { + output.writeFieldBegin('quiz', Thrift.Type.STRUCT, 1); + this.quiz.write(output); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +ContentAtomEvent = module.exports.ContentAtomEvent = function(args) { + this.atom = null; + this.eventType = null; + this.eventCreationTime = null; + if (args) { + if (args.atom !== undefined) { + this.atom = args.atom; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field atom is unset!'); + } + if (args.eventType !== undefined) { + this.eventType = args.eventType; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field eventType is unset!'); + } + if (args.eventCreationTime !== undefined) { + this.eventCreationTime = args.eventCreationTime; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field eventCreationTime is unset!'); + } + } +}; +ContentAtomEvent.prototype = {}; +ContentAtomEvent.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRUCT) { + this.atom = new ttypes.Atom(); + this.atom.read(input); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.I32) { + this.eventType = input.readI32(); + } else { + input.skip(ftype); + } + break; + case 3: + if (ftype == Thrift.Type.I64) { + this.eventCreationTime = input.readI64(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +ContentAtomEvent.prototype.write = function(output) { + output.writeStructBegin('ContentAtomEvent'); + if (this.atom !== null && this.atom !== undefined) { + output.writeFieldBegin('atom', Thrift.Type.STRUCT, 1); + this.atom.write(output); + output.writeFieldEnd(); + } + if (this.eventType !== null && this.eventType !== undefined) { + output.writeFieldBegin('eventType', Thrift.Type.I32, 2); + output.writeI32(this.eventType); + output.writeFieldEnd(); + } + if (this.eventCreationTime !== null && this.eventCreationTime !== undefined) { + output.writeFieldBegin('eventCreationTime', Thrift.Type.I64, 3); + output.writeI64(this.eventCreationTime); output.writeFieldEnd(); } output.writeFieldStop(); diff --git a/generated/gen-nodejs/quiz_types.js b/generated/gen-nodejs/quiz_types.js new file mode 100644 index 0000000..7d3aaf9 --- /dev/null +++ b/generated/gen-nodejs/quiz_types.js @@ -0,0 +1,892 @@ +// +// Autogenerated by Thrift Compiler (0.9.2) +// +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// +var thrift = require('thrift'); +var Thrift = thrift.Thrift; +var Q = thrift.Q; + +var shared_ttypes = require('./shared_types') + + +var ttypes = module.exports = {}; +if (typeof contentatom === 'undefined') { + contentatom = {}; +} +if (typeof contentatom.quiz === 'undefined') { + contentatom.quiz = {}; +} +contentatom.quiz.QuizAtom = module.exports.QuizAtom = function(args) { + this.id = null; + this.title = null; + this.updatedBy = null; + this.updatedAt = null; + this.createdAt = null; + this.createdBy = null; + this.published = null; + this.quizType = null; + this.defaultColumns = null; + this.content = null; + if (args) { + if (args.id !== undefined) { + this.id = args.id; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field id is unset!'); + } + if (args.title !== undefined) { + this.title = args.title; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field title is unset!'); + } + if (args.updatedBy !== undefined) { + this.updatedBy = args.updatedBy; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field updatedBy is unset!'); + } + if (args.updatedAt !== undefined) { + this.updatedAt = args.updatedAt; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field updatedAt is unset!'); + } + if (args.createdAt !== undefined) { + this.createdAt = args.createdAt; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field createdAt is unset!'); + } + if (args.createdBy !== undefined) { + this.createdBy = args.createdBy; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field createdBy is unset!'); + } + if (args.published !== undefined) { + this.published = args.published; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field published is unset!'); + } + if (args.quizType !== undefined) { + this.quizType = args.quizType; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field quizType is unset!'); + } + if (args.defaultColumns !== undefined) { + this.defaultColumns = args.defaultColumns; + } + if (args.content !== undefined) { + this.content = args.content; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field content is unset!'); + } + } +}; +contentatom.quiz.QuizAtom.prototype = {}; +contentatom.quiz.QuizAtom.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRING) { + this.id = input.readString(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.STRING) { + this.title = input.readString(); + } else { + input.skip(ftype); + } + break; + case 3: + if (ftype == Thrift.Type.STRING) { + this.updatedBy = input.readString(); + } else { + input.skip(ftype); + } + break; + case 4: + if (ftype == Thrift.Type.I64) { + this.updatedAt = input.readI64(); + } else { + input.skip(ftype); + } + break; + case 5: + if (ftype == Thrift.Type.I64) { + this.createdAt = input.readI64(); + } else { + input.skip(ftype); + } + break; + case 6: + if (ftype == Thrift.Type.STRING) { + this.createdBy = input.readString(); + } else { + input.skip(ftype); + } + break; + case 7: + if (ftype == Thrift.Type.BOOL) { + this.published = input.readBool(); + } else { + input.skip(ftype); + } + break; + case 8: + if (ftype == Thrift.Type.STRING) { + this.quizType = input.readString(); + } else { + input.skip(ftype); + } + break; + case 9: + if (ftype == Thrift.Type.I16) { + this.defaultColumns = input.readI16(); + } else { + input.skip(ftype); + } + break; + case 10: + if (ftype == Thrift.Type.STRUCT) { + this.content = new ttypes.ItemContent(); + this.content.read(input); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +contentatom.quiz.QuizAtom.prototype.write = function(output) { + output.writeStructBegin('QuizAtom'); + if (this.id !== null && this.id !== undefined) { + output.writeFieldBegin('id', Thrift.Type.STRING, 1); + output.writeString(this.id); + output.writeFieldEnd(); + } + if (this.title !== null && this.title !== undefined) { + output.writeFieldBegin('title', Thrift.Type.STRING, 2); + output.writeString(this.title); + output.writeFieldEnd(); + } + if (this.updatedBy !== null && this.updatedBy !== undefined) { + output.writeFieldBegin('updatedBy', Thrift.Type.STRING, 3); + output.writeString(this.updatedBy); + output.writeFieldEnd(); + } + if (this.updatedAt !== null && this.updatedAt !== undefined) { + output.writeFieldBegin('updatedAt', Thrift.Type.I64, 4); + output.writeI64(this.updatedAt); + output.writeFieldEnd(); + } + if (this.createdAt !== null && this.createdAt !== undefined) { + output.writeFieldBegin('createdAt', Thrift.Type.I64, 5); + output.writeI64(this.createdAt); + output.writeFieldEnd(); + } + if (this.createdBy !== null && this.createdBy !== undefined) { + output.writeFieldBegin('createdBy', Thrift.Type.STRING, 6); + output.writeString(this.createdBy); + output.writeFieldEnd(); + } + if (this.published !== null && this.published !== undefined) { + output.writeFieldBegin('published', Thrift.Type.BOOL, 7); + output.writeBool(this.published); + output.writeFieldEnd(); + } + if (this.quizType !== null && this.quizType !== undefined) { + output.writeFieldBegin('quizType', Thrift.Type.STRING, 8); + output.writeString(this.quizType); + output.writeFieldEnd(); + } + if (this.defaultColumns !== null && this.defaultColumns !== undefined) { + output.writeFieldBegin('defaultColumns', Thrift.Type.I16, 9); + output.writeI16(this.defaultColumns); + output.writeFieldEnd(); + } + if (this.content !== null && this.content !== undefined) { + output.writeFieldBegin('content', Thrift.Type.STRUCT, 10); + this.content.write(output); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +contentatom.quiz.ItemContent = module.exports.ItemContent = function(args) { + this.quiz = null; + if (args) { + if (args.quiz !== undefined) { + this.quiz = args.quiz; + } + } +}; +contentatom.quiz.ItemContent.prototype = {}; +contentatom.quiz.ItemContent.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRUCT) { + this.quiz = new ttypes.QuizContent(); + this.quiz.read(input); + } else { + input.skip(ftype); + } + break; + case 0: + input.skip(ftype); + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +contentatom.quiz.ItemContent.prototype.write = function(output) { + output.writeStructBegin('ItemContent'); + if (this.quiz !== null && this.quiz !== undefined) { + output.writeFieldBegin('quiz', Thrift.Type.STRUCT, 1); + this.quiz.write(output); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +contentatom.quiz.QuizContent = module.exports.QuizContent = function(args) { + this.questions = null; + this.resultGroups = null; + if (args) { + if (args.questions !== undefined) { + this.questions = args.questions; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field questions is unset!'); + } + if (args.resultGroups !== undefined) { + this.resultGroups = args.resultGroups; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field resultGroups is unset!'); + } + } +}; +contentatom.quiz.QuizContent.prototype = {}; +contentatom.quiz.QuizContent.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.LIST) { + var _size0 = 0; + var _rtmp34; + this.questions = []; + var _etype3 = 0; + _rtmp34 = input.readListBegin(); + _etype3 = _rtmp34.etype; + _size0 = _rtmp34.size; + for (var _i5 = 0; _i5 < _size0; ++_i5) + { + var elem6 = null; + elem6 = new ttypes.Question(); + elem6.read(input); + this.questions.push(elem6); + } + input.readListEnd(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.STRUCT) { + this.resultGroups = new ttypes.ResultGroups(); + this.resultGroups.read(input); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +contentatom.quiz.QuizContent.prototype.write = function(output) { + output.writeStructBegin('QuizContent'); + if (this.questions !== null && this.questions !== undefined) { + output.writeFieldBegin('questions', Thrift.Type.LIST, 1); + output.writeListBegin(Thrift.Type.STRUCT, this.questions.length); + for (var iter7 in this.questions) + { + if (this.questions.hasOwnProperty(iter7)) + { + iter7 = this.questions[iter7]; + iter7.write(output); + } + } + output.writeListEnd(); + output.writeFieldEnd(); + } + if (this.resultGroups !== null && this.resultGroups !== undefined) { + output.writeFieldBegin('resultGroups', Thrift.Type.STRUCT, 2); + this.resultGroups.write(output); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +contentatom.quiz.ResultGroups = module.exports.ResultGroups = function(args) { + this.groups = null; + this.revealAtEnd = null; + if (args) { + if (args.groups !== undefined) { + this.groups = args.groups; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field groups is unset!'); + } + if (args.revealAtEnd !== undefined) { + this.revealAtEnd = args.revealAtEnd; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field revealAtEnd is unset!'); + } + } +}; +contentatom.quiz.ResultGroups.prototype = {}; +contentatom.quiz.ResultGroups.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.LIST) { + var _size8 = 0; + var _rtmp312; + this.groups = []; + var _etype11 = 0; + _rtmp312 = input.readListBegin(); + _etype11 = _rtmp312.etype; + _size8 = _rtmp312.size; + for (var _i13 = 0; _i13 < _size8; ++_i13) + { + var elem14 = null; + elem14 = new ttypes.ResultGroup(); + elem14.read(input); + this.groups.push(elem14); + } + input.readListEnd(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.BOOL) { + this.revealAtEnd = input.readBool(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +contentatom.quiz.ResultGroups.prototype.write = function(output) { + output.writeStructBegin('ResultGroups'); + if (this.groups !== null && this.groups !== undefined) { + output.writeFieldBegin('groups', Thrift.Type.LIST, 1); + output.writeListBegin(Thrift.Type.STRUCT, this.groups.length); + for (var iter15 in this.groups) + { + if (this.groups.hasOwnProperty(iter15)) + { + iter15 = this.groups[iter15]; + iter15.write(output); + } + } + output.writeListEnd(); + output.writeFieldEnd(); + } + if (this.revealAtEnd !== null && this.revealAtEnd !== undefined) { + output.writeFieldBegin('revealAtEnd', Thrift.Type.BOOL, 2); + output.writeBool(this.revealAtEnd); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +contentatom.quiz.ResultGroup = module.exports.ResultGroup = function(args) { + this.title = null; + this.share = null; + this.minScore = null; + if (args) { + if (args.title !== undefined) { + this.title = args.title; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field title is unset!'); + } + if (args.share !== undefined) { + this.share = args.share; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field share is unset!'); + } + if (args.minScore !== undefined) { + this.minScore = args.minScore; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field minScore is unset!'); + } + } +}; +contentatom.quiz.ResultGroup.prototype = {}; +contentatom.quiz.ResultGroup.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRING) { + this.title = input.readString(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.STRING) { + this.share = input.readString(); + } else { + input.skip(ftype); + } + break; + case 3: + if (ftype == Thrift.Type.I16) { + this.minScore = input.readI16(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +contentatom.quiz.ResultGroup.prototype.write = function(output) { + output.writeStructBegin('ResultGroup'); + if (this.title !== null && this.title !== undefined) { + output.writeFieldBegin('title', Thrift.Type.STRING, 1); + output.writeString(this.title); + output.writeFieldEnd(); + } + if (this.share !== null && this.share !== undefined) { + output.writeFieldBegin('share', Thrift.Type.STRING, 2); + output.writeString(this.share); + output.writeFieldEnd(); + } + if (this.minScore !== null && this.minScore !== undefined) { + output.writeFieldBegin('minScore', Thrift.Type.I16, 3); + output.writeI16(this.minScore); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +contentatom.quiz.Question = module.exports.Question = function(args) { + this.questionText = null; + this.assets = null; + this.answers = null; + if (args) { + if (args.questionText !== undefined) { + this.questionText = args.questionText; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field questionText is unset!'); + } + if (args.assets !== undefined) { + this.assets = args.assets; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field assets is unset!'); + } + if (args.answers !== undefined) { + this.answers = args.answers; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field answers is unset!'); + } + } +}; +contentatom.quiz.Question.prototype = {}; +contentatom.quiz.Question.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRING) { + this.questionText = input.readString(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.LIST) { + var _size16 = 0; + var _rtmp320; + this.assets = []; + var _etype19 = 0; + _rtmp320 = input.readListBegin(); + _etype19 = _rtmp320.etype; + _size16 = _rtmp320.size; + for (var _i21 = 0; _i21 < _size16; ++_i21) + { + var elem22 = null; + elem22 = new ttypes.Asset(); + elem22.read(input); + this.assets.push(elem22); + } + input.readListEnd(); + } else { + input.skip(ftype); + } + break; + case 3: + if (ftype == Thrift.Type.LIST) { + var _size23 = 0; + var _rtmp327; + this.answers = []; + var _etype26 = 0; + _rtmp327 = input.readListBegin(); + _etype26 = _rtmp327.etype; + _size23 = _rtmp327.size; + for (var _i28 = 0; _i28 < _size23; ++_i28) + { + var elem29 = null; + elem29 = new ttypes.Answer(); + elem29.read(input); + this.answers.push(elem29); + } + input.readListEnd(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +contentatom.quiz.Question.prototype.write = function(output) { + output.writeStructBegin('Question'); + if (this.questionText !== null && this.questionText !== undefined) { + output.writeFieldBegin('questionText', Thrift.Type.STRING, 1); + output.writeString(this.questionText); + output.writeFieldEnd(); + } + if (this.assets !== null && this.assets !== undefined) { + output.writeFieldBegin('assets', Thrift.Type.LIST, 2); + output.writeListBegin(Thrift.Type.STRUCT, this.assets.length); + for (var iter30 in this.assets) + { + if (this.assets.hasOwnProperty(iter30)) + { + iter30 = this.assets[iter30]; + iter30.write(output); + } + } + output.writeListEnd(); + output.writeFieldEnd(); + } + if (this.answers !== null && this.answers !== undefined) { + output.writeFieldBegin('answers', Thrift.Type.LIST, 3); + output.writeListBegin(Thrift.Type.STRUCT, this.answers.length); + for (var iter31 in this.answers) + { + if (this.answers.hasOwnProperty(iter31)) + { + iter31 = this.answers[iter31]; + iter31.write(output); + } + } + output.writeListEnd(); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +contentatom.quiz.Answer = module.exports.Answer = function(args) { + this.answerText = null; + this.assets = null; + this.correct = null; + this.revealText = null; + if (args) { + if (args.answerText !== undefined) { + this.answerText = args.answerText; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field answerText is unset!'); + } + if (args.assets !== undefined) { + this.assets = args.assets; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field assets is unset!'); + } + if (args.correct !== undefined) { + this.correct = args.correct; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field correct is unset!'); + } + if (args.revealText !== undefined) { + this.revealText = args.revealText; + } + } +}; +contentatom.quiz.Answer.prototype = {}; +contentatom.quiz.Answer.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRING) { + this.answerText = input.readString(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.LIST) { + var _size32 = 0; + var _rtmp336; + this.assets = []; + var _etype35 = 0; + _rtmp336 = input.readListBegin(); + _etype35 = _rtmp336.etype; + _size32 = _rtmp336.size; + for (var _i37 = 0; _i37 < _size32; ++_i37) + { + var elem38 = null; + elem38 = new ttypes.Asset(); + elem38.read(input); + this.assets.push(elem38); + } + input.readListEnd(); + } else { + input.skip(ftype); + } + break; + case 3: + if (ftype == Thrift.Type.BOOL) { + this.correct = input.readBool(); + } else { + input.skip(ftype); + } + break; + case 4: + if (ftype == Thrift.Type.STRING) { + this.revealText = input.readString(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +contentatom.quiz.Answer.prototype.write = function(output) { + output.writeStructBegin('Answer'); + if (this.answerText !== null && this.answerText !== undefined) { + output.writeFieldBegin('answerText', Thrift.Type.STRING, 1); + output.writeString(this.answerText); + output.writeFieldEnd(); + } + if (this.assets !== null && this.assets !== undefined) { + output.writeFieldBegin('assets', Thrift.Type.LIST, 2); + output.writeListBegin(Thrift.Type.STRUCT, this.assets.length); + for (var iter39 in this.assets) + { + if (this.assets.hasOwnProperty(iter39)) + { + iter39 = this.assets[iter39]; + iter39.write(output); + } + } + output.writeListEnd(); + output.writeFieldEnd(); + } + if (this.correct !== null && this.correct !== undefined) { + output.writeFieldBegin('correct', Thrift.Type.BOOL, 3); + output.writeBool(this.correct); + output.writeFieldEnd(); + } + if (this.revealText !== null && this.revealText !== undefined) { + output.writeFieldBegin('revealText', Thrift.Type.STRING, 4); + output.writeString(this.revealText); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +contentatom.quiz.Asset = module.exports.Asset = function(args) { + this.type = null; + this.data = null; + if (args) { + if (args.type !== undefined) { + this.type = args.type; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field type is unset!'); + } + if (args.data !== undefined) { + this.data = args.data; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field data is unset!'); + } + } +}; +contentatom.quiz.Asset.prototype = {}; +contentatom.quiz.Asset.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRING) { + this.type = input.readString(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.STRING) { + this.data = input.readString(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +contentatom.quiz.Asset.prototype.write = function(output) { + output.writeStructBegin('Asset'); + if (this.type !== null && this.type !== undefined) { + output.writeFieldBegin('type', Thrift.Type.STRING, 1); + output.writeString(this.type); + output.writeFieldEnd(); + } + if (this.data !== null && this.data !== undefined) { + output.writeFieldBegin('data', Thrift.Type.STRING, 2); + output.writeString(this.data); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + diff --git a/thrift/atoms/tenfour.thrift b/thrift/atoms/quiz.thrift similarity index 85% rename from thrift/atoms/tenfour.thrift rename to thrift/atoms/quiz.thrift index 290d7a6..a70af41 100644 --- a/thrift/atoms/tenfour.thrift +++ b/thrift/atoms/quiz.thrift @@ -1,18 +1,15 @@ -namespace * tenfour +namespace * contentatom.quiz include "../shared.thrift" -/** date times are reprsented as i64 - epoch millis */ -typedef i64 DateTime - -struct TenfourQuizBuilderAtom { +struct QuizAtom { // do we need to store the ID, seeing as it is replicated(?) in the // content-atom wrapping? 1 : required string id 2 : required string title 3 : required string updatedBy - 4 : required DateTime updatedAt - 5 : required DateTime createdAt + 4 : required shared.DateTime updatedAt + 5 : required shared.DateTime createdAt 6 : required string createdBy 7 : required bool published 8 : required string quizType diff --git a/thrift/contentatom.thrift b/thrift/contentatom.thrift index 71f5857..5bec9ee 100644 --- a/thrift/contentatom.thrift +++ b/thrift/contentatom.thrift @@ -1,5 +1,26 @@ -include "atoms/tenfour.thrift" +include "atoms/quiz.thrift" +include "shared.thrift" -union ContentAtom { - 1: tenfour.TenfourQuizBuilderAtom tenfour +typedef string ContentAtomID + +enum AtomType { QUIZ } + +struct Atom { + 1: required ContentAtomID id + 2: required AtomType atomType + 3: required list labels // required, but may be empty + 4: required string defaultBody + 5: required AtomData data // the atom payload + } + +union AtomData { + 1: quiz.QuizAtom quiz +} + +enum EventType { PUBLISH, UPDATE, TAKEDOWN } + +struct ContentAtomEvent { + 1: required Atom atom + 2: required EventType eventType + 3: required shared.DateTime eventCreationTime } diff --git a/thrift/events.thrift b/thrift/events.thrift deleted file mode 100644 index 6d25548..0000000 --- a/thrift/events.thrift +++ /dev/null @@ -1,22 +0,0 @@ -include "contentatom.thrift" - -typedef string ContentAtomID - -enum EventType { PUBLISH, UPDATE, TAKEDOWN } - -enum AtomType { TENFOUR_QUIZ_BUILDER } - -struct ContentAtomEvent { - - /* this opaque identifier should uniquely identify this content atom - * across all content-atoms of any type (an alternative model might - * be to have the `type+id` be unique) */ - - 1: required ContentAtomID id - - 2: required AtomType atomType - - 3: required EventType eventType - - 4: required contentatom.ContentAtom data - } diff --git a/thrift/shared.thrift b/thrift/shared.thrift index d16b0e7..4685489 100644 --- a/thrift/shared.thrift +++ b/thrift/shared.thrift @@ -1 +1,4 @@ +/** date times are reprsented as i64 - epoch millis */ +typedef i64 DateTime + typedef string OpaqueJson From 461ca4a09cb117a733bc32551cfe9496e28251af Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Wed, 2 Sep 2015 14:57:57 +0100 Subject: [PATCH 13/18] delete generated files no longer needed --- generated/gen-nodejs/content-atom_types.js | 67 -- generated/gen-nodejs/events_types.js | 128 --- generated/gen-nodejs/tenfour_types.js | 889 --------------------- js/main.js | 3 +- 4 files changed, 1 insertion(+), 1086 deletions(-) delete mode 100644 generated/gen-nodejs/content-atom_types.js delete mode 100644 generated/gen-nodejs/events_types.js delete mode 100644 generated/gen-nodejs/tenfour_types.js diff --git a/generated/gen-nodejs/content-atom_types.js b/generated/gen-nodejs/content-atom_types.js deleted file mode 100644 index e778770..0000000 --- a/generated/gen-nodejs/content-atom_types.js +++ /dev/null @@ -1,67 +0,0 @@ -// -// Autogenerated by Thrift Compiler (0.9.2) -// -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// -var thrift = require('thrift'); -var Thrift = thrift.Thrift; -var Q = thrift.Q; - -var tenfour_ttypes = require('./tenfour_types') - - -var ttypes = module.exports = {}; -ContentAtom = module.exports.ContentAtom = function(args) { - this.tenfour = null; - if (args) { - if (args.tenfour !== undefined) { - this.tenfour = args.tenfour; - } - } -}; -ContentAtom.prototype = {}; -ContentAtom.prototype.read = function(input) { - input.readStructBegin(); - while (true) - { - var ret = input.readFieldBegin(); - var fname = ret.fname; - var ftype = ret.ftype; - var fid = ret.fid; - if (ftype == Thrift.Type.STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == Thrift.Type.STRUCT) { - this.tenfour = new tenfour_ttypes.Content(); - this.tenfour.read(input); - } else { - input.skip(ftype); - } - break; - case 0: - input.skip(ftype); - break; - default: - input.skip(ftype); - } - input.readFieldEnd(); - } - input.readStructEnd(); - return; -}; - -ContentAtom.prototype.write = function(output) { - output.writeStructBegin('ContentAtom'); - if (this.tenfour !== null && this.tenfour !== undefined) { - output.writeFieldBegin('tenfour', Thrift.Type.STRUCT, 1); - this.tenfour.write(output); - output.writeFieldEnd(); - } - output.writeFieldStop(); - output.writeStructEnd(); - return; -}; - diff --git a/generated/gen-nodejs/events_types.js b/generated/gen-nodejs/events_types.js deleted file mode 100644 index 3db4c05..0000000 --- a/generated/gen-nodejs/events_types.js +++ /dev/null @@ -1,128 +0,0 @@ -// -// Autogenerated by Thrift Compiler (0.9.2) -// -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// -var thrift = require('thrift'); -var Thrift = thrift.Thrift; -var Q = thrift.Q; - -var contentatom_ttypes = require('./contentatom_types') - - -var ttypes = module.exports = {}; -ttypes.EventType = { - 'PUBLISH' : 0, - 'UPDATE' : 1, - 'TAKEDOWN' : 2 -}; -ttypes.AtomType = { - 'TENFOUR_QUIZ_BUILDER' : 0 -}; -ContentAtomEvent = module.exports.ContentAtomEvent = function(args) { - this.id = null; - this.atomType = null; - this.eventType = null; - this.data = null; - if (args) { - if (args.id !== undefined) { - this.id = args.id; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field id is unset!'); - } - if (args.atomType !== undefined) { - this.atomType = args.atomType; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field atomType is unset!'); - } - if (args.eventType !== undefined) { - this.eventType = args.eventType; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field eventType is unset!'); - } - if (args.data !== undefined) { - this.data = args.data; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field data is unset!'); - } - } -}; -ContentAtomEvent.prototype = {}; -ContentAtomEvent.prototype.read = function(input) { - input.readStructBegin(); - while (true) - { - var ret = input.readFieldBegin(); - var fname = ret.fname; - var ftype = ret.ftype; - var fid = ret.fid; - if (ftype == Thrift.Type.STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == Thrift.Type.STRING) { - this.id = input.readString(); - } else { - input.skip(ftype); - } - break; - case 2: - if (ftype == Thrift.Type.I32) { - this.atomType = input.readI32(); - } else { - input.skip(ftype); - } - break; - case 3: - if (ftype == Thrift.Type.I32) { - this.eventType = input.readI32(); - } else { - input.skip(ftype); - } - break; - case 4: - if (ftype == Thrift.Type.STRUCT) { - this.data = new contentatom_ttypes.ContentAtom(); - this.data.read(input); - } else { - input.skip(ftype); - } - break; - default: - input.skip(ftype); - } - input.readFieldEnd(); - } - input.readStructEnd(); - return; -}; - -ContentAtomEvent.prototype.write = function(output) { - output.writeStructBegin('ContentAtomEvent'); - if (this.id !== null && this.id !== undefined) { - output.writeFieldBegin('id', Thrift.Type.STRING, 1); - output.writeString(this.id); - output.writeFieldEnd(); - } - if (this.atomType !== null && this.atomType !== undefined) { - output.writeFieldBegin('atomType', Thrift.Type.I32, 2); - output.writeI32(this.atomType); - output.writeFieldEnd(); - } - if (this.eventType !== null && this.eventType !== undefined) { - output.writeFieldBegin('eventType', Thrift.Type.I32, 3); - output.writeI32(this.eventType); - output.writeFieldEnd(); - } - if (this.data !== null && this.data !== undefined) { - output.writeFieldBegin('data', Thrift.Type.STRUCT, 4); - this.data.write(output); - output.writeFieldEnd(); - } - output.writeFieldStop(); - output.writeStructEnd(); - return; -}; - diff --git a/generated/gen-nodejs/tenfour_types.js b/generated/gen-nodejs/tenfour_types.js deleted file mode 100644 index 3b02106..0000000 --- a/generated/gen-nodejs/tenfour_types.js +++ /dev/null @@ -1,889 +0,0 @@ -// -// Autogenerated by Thrift Compiler (0.9.2) -// -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -// -var thrift = require('thrift'); -var Thrift = thrift.Thrift; -var Q = thrift.Q; - -var shared_ttypes = require('./shared_types') - - -var ttypes = module.exports = {}; -if (typeof tenfour === 'undefined') { - tenfour = {}; -} -tenfour.TenfourQuizBuilderAtom = module.exports.TenfourQuizBuilderAtom = function(args) { - this.id = null; - this.title = null; - this.updatedBy = null; - this.updatedAt = null; - this.createdAt = null; - this.createdBy = null; - this.published = null; - this.quizType = null; - this.defaultColumns = null; - this.content = null; - if (args) { - if (args.id !== undefined) { - this.id = args.id; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field id is unset!'); - } - if (args.title !== undefined) { - this.title = args.title; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field title is unset!'); - } - if (args.updatedBy !== undefined) { - this.updatedBy = args.updatedBy; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field updatedBy is unset!'); - } - if (args.updatedAt !== undefined) { - this.updatedAt = args.updatedAt; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field updatedAt is unset!'); - } - if (args.createdAt !== undefined) { - this.createdAt = args.createdAt; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field createdAt is unset!'); - } - if (args.createdBy !== undefined) { - this.createdBy = args.createdBy; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field createdBy is unset!'); - } - if (args.published !== undefined) { - this.published = args.published; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field published is unset!'); - } - if (args.quizType !== undefined) { - this.quizType = args.quizType; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field quizType is unset!'); - } - if (args.defaultColumns !== undefined) { - this.defaultColumns = args.defaultColumns; - } - if (args.content !== undefined) { - this.content = args.content; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field content is unset!'); - } - } -}; -tenfour.TenfourQuizBuilderAtom.prototype = {}; -tenfour.TenfourQuizBuilderAtom.prototype.read = function(input) { - input.readStructBegin(); - while (true) - { - var ret = input.readFieldBegin(); - var fname = ret.fname; - var ftype = ret.ftype; - var fid = ret.fid; - if (ftype == Thrift.Type.STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == Thrift.Type.STRING) { - this.id = input.readString(); - } else { - input.skip(ftype); - } - break; - case 2: - if (ftype == Thrift.Type.STRING) { - this.title = input.readString(); - } else { - input.skip(ftype); - } - break; - case 3: - if (ftype == Thrift.Type.STRING) { - this.updatedBy = input.readString(); - } else { - input.skip(ftype); - } - break; - case 4: - if (ftype == Thrift.Type.I64) { - this.updatedAt = input.readI64(); - } else { - input.skip(ftype); - } - break; - case 5: - if (ftype == Thrift.Type.I64) { - this.createdAt = input.readI64(); - } else { - input.skip(ftype); - } - break; - case 6: - if (ftype == Thrift.Type.STRING) { - this.createdBy = input.readString(); - } else { - input.skip(ftype); - } - break; - case 7: - if (ftype == Thrift.Type.BOOL) { - this.published = input.readBool(); - } else { - input.skip(ftype); - } - break; - case 8: - if (ftype == Thrift.Type.STRING) { - this.quizType = input.readString(); - } else { - input.skip(ftype); - } - break; - case 9: - if (ftype == Thrift.Type.I16) { - this.defaultColumns = input.readI16(); - } else { - input.skip(ftype); - } - break; - case 10: - if (ftype == Thrift.Type.STRUCT) { - this.content = new ttypes.ItemContent(); - this.content.read(input); - } else { - input.skip(ftype); - } - break; - default: - input.skip(ftype); - } - input.readFieldEnd(); - } - input.readStructEnd(); - return; -}; - -tenfour.TenfourQuizBuilderAtom.prototype.write = function(output) { - output.writeStructBegin('TenfourQuizBuilderAtom'); - if (this.id !== null && this.id !== undefined) { - output.writeFieldBegin('id', Thrift.Type.STRING, 1); - output.writeString(this.id); - output.writeFieldEnd(); - } - if (this.title !== null && this.title !== undefined) { - output.writeFieldBegin('title', Thrift.Type.STRING, 2); - output.writeString(this.title); - output.writeFieldEnd(); - } - if (this.updatedBy !== null && this.updatedBy !== undefined) { - output.writeFieldBegin('updatedBy', Thrift.Type.STRING, 3); - output.writeString(this.updatedBy); - output.writeFieldEnd(); - } - if (this.updatedAt !== null && this.updatedAt !== undefined) { - output.writeFieldBegin('updatedAt', Thrift.Type.I64, 4); - output.writeI64(this.updatedAt); - output.writeFieldEnd(); - } - if (this.createdAt !== null && this.createdAt !== undefined) { - output.writeFieldBegin('createdAt', Thrift.Type.I64, 5); - output.writeI64(this.createdAt); - output.writeFieldEnd(); - } - if (this.createdBy !== null && this.createdBy !== undefined) { - output.writeFieldBegin('createdBy', Thrift.Type.STRING, 6); - output.writeString(this.createdBy); - output.writeFieldEnd(); - } - if (this.published !== null && this.published !== undefined) { - output.writeFieldBegin('published', Thrift.Type.BOOL, 7); - output.writeBool(this.published); - output.writeFieldEnd(); - } - if (this.quizType !== null && this.quizType !== undefined) { - output.writeFieldBegin('quizType', Thrift.Type.STRING, 8); - output.writeString(this.quizType); - output.writeFieldEnd(); - } - if (this.defaultColumns !== null && this.defaultColumns !== undefined) { - output.writeFieldBegin('defaultColumns', Thrift.Type.I16, 9); - output.writeI16(this.defaultColumns); - output.writeFieldEnd(); - } - if (this.content !== null && this.content !== undefined) { - output.writeFieldBegin('content', Thrift.Type.STRUCT, 10); - this.content.write(output); - output.writeFieldEnd(); - } - output.writeFieldStop(); - output.writeStructEnd(); - return; -}; - -tenfour.ItemContent = module.exports.ItemContent = function(args) { - this.quiz = null; - if (args) { - if (args.quiz !== undefined) { - this.quiz = args.quiz; - } - } -}; -tenfour.ItemContent.prototype = {}; -tenfour.ItemContent.prototype.read = function(input) { - input.readStructBegin(); - while (true) - { - var ret = input.readFieldBegin(); - var fname = ret.fname; - var ftype = ret.ftype; - var fid = ret.fid; - if (ftype == Thrift.Type.STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == Thrift.Type.STRUCT) { - this.quiz = new ttypes.QuizContent(); - this.quiz.read(input); - } else { - input.skip(ftype); - } - break; - case 0: - input.skip(ftype); - break; - default: - input.skip(ftype); - } - input.readFieldEnd(); - } - input.readStructEnd(); - return; -}; - -tenfour.ItemContent.prototype.write = function(output) { - output.writeStructBegin('ItemContent'); - if (this.quiz !== null && this.quiz !== undefined) { - output.writeFieldBegin('quiz', Thrift.Type.STRUCT, 1); - this.quiz.write(output); - output.writeFieldEnd(); - } - output.writeFieldStop(); - output.writeStructEnd(); - return; -}; - -tenfour.QuizContent = module.exports.QuizContent = function(args) { - this.questions = null; - this.resultGroups = null; - if (args) { - if (args.questions !== undefined) { - this.questions = args.questions; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field questions is unset!'); - } - if (args.resultGroups !== undefined) { - this.resultGroups = args.resultGroups; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field resultGroups is unset!'); - } - } -}; -tenfour.QuizContent.prototype = {}; -tenfour.QuizContent.prototype.read = function(input) { - input.readStructBegin(); - while (true) - { - var ret = input.readFieldBegin(); - var fname = ret.fname; - var ftype = ret.ftype; - var fid = ret.fid; - if (ftype == Thrift.Type.STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == Thrift.Type.LIST) { - var _size0 = 0; - var _rtmp34; - this.questions = []; - var _etype3 = 0; - _rtmp34 = input.readListBegin(); - _etype3 = _rtmp34.etype; - _size0 = _rtmp34.size; - for (var _i5 = 0; _i5 < _size0; ++_i5) - { - var elem6 = null; - elem6 = new ttypes.Question(); - elem6.read(input); - this.questions.push(elem6); - } - input.readListEnd(); - } else { - input.skip(ftype); - } - break; - case 2: - if (ftype == Thrift.Type.STRUCT) { - this.resultGroups = new ttypes.ResultGroups(); - this.resultGroups.read(input); - } else { - input.skip(ftype); - } - break; - default: - input.skip(ftype); - } - input.readFieldEnd(); - } - input.readStructEnd(); - return; -}; - -tenfour.QuizContent.prototype.write = function(output) { - output.writeStructBegin('QuizContent'); - if (this.questions !== null && this.questions !== undefined) { - output.writeFieldBegin('questions', Thrift.Type.LIST, 1); - output.writeListBegin(Thrift.Type.STRUCT, this.questions.length); - for (var iter7 in this.questions) - { - if (this.questions.hasOwnProperty(iter7)) - { - iter7 = this.questions[iter7]; - iter7.write(output); - } - } - output.writeListEnd(); - output.writeFieldEnd(); - } - if (this.resultGroups !== null && this.resultGroups !== undefined) { - output.writeFieldBegin('resultGroups', Thrift.Type.STRUCT, 2); - this.resultGroups.write(output); - output.writeFieldEnd(); - } - output.writeFieldStop(); - output.writeStructEnd(); - return; -}; - -tenfour.ResultGroups = module.exports.ResultGroups = function(args) { - this.groups = null; - this.revealAtEnd = null; - if (args) { - if (args.groups !== undefined) { - this.groups = args.groups; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field groups is unset!'); - } - if (args.revealAtEnd !== undefined) { - this.revealAtEnd = args.revealAtEnd; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field revealAtEnd is unset!'); - } - } -}; -tenfour.ResultGroups.prototype = {}; -tenfour.ResultGroups.prototype.read = function(input) { - input.readStructBegin(); - while (true) - { - var ret = input.readFieldBegin(); - var fname = ret.fname; - var ftype = ret.ftype; - var fid = ret.fid; - if (ftype == Thrift.Type.STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == Thrift.Type.LIST) { - var _size8 = 0; - var _rtmp312; - this.groups = []; - var _etype11 = 0; - _rtmp312 = input.readListBegin(); - _etype11 = _rtmp312.etype; - _size8 = _rtmp312.size; - for (var _i13 = 0; _i13 < _size8; ++_i13) - { - var elem14 = null; - elem14 = new ttypes.ResultGroup(); - elem14.read(input); - this.groups.push(elem14); - } - input.readListEnd(); - } else { - input.skip(ftype); - } - break; - case 2: - if (ftype == Thrift.Type.BOOL) { - this.revealAtEnd = input.readBool(); - } else { - input.skip(ftype); - } - break; - default: - input.skip(ftype); - } - input.readFieldEnd(); - } - input.readStructEnd(); - return; -}; - -tenfour.ResultGroups.prototype.write = function(output) { - output.writeStructBegin('ResultGroups'); - if (this.groups !== null && this.groups !== undefined) { - output.writeFieldBegin('groups', Thrift.Type.LIST, 1); - output.writeListBegin(Thrift.Type.STRUCT, this.groups.length); - for (var iter15 in this.groups) - { - if (this.groups.hasOwnProperty(iter15)) - { - iter15 = this.groups[iter15]; - iter15.write(output); - } - } - output.writeListEnd(); - output.writeFieldEnd(); - } - if (this.revealAtEnd !== null && this.revealAtEnd !== undefined) { - output.writeFieldBegin('revealAtEnd', Thrift.Type.BOOL, 2); - output.writeBool(this.revealAtEnd); - output.writeFieldEnd(); - } - output.writeFieldStop(); - output.writeStructEnd(); - return; -}; - -tenfour.ResultGroup = module.exports.ResultGroup = function(args) { - this.title = null; - this.share = null; - this.minScore = null; - if (args) { - if (args.title !== undefined) { - this.title = args.title; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field title is unset!'); - } - if (args.share !== undefined) { - this.share = args.share; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field share is unset!'); - } - if (args.minScore !== undefined) { - this.minScore = args.minScore; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field minScore is unset!'); - } - } -}; -tenfour.ResultGroup.prototype = {}; -tenfour.ResultGroup.prototype.read = function(input) { - input.readStructBegin(); - while (true) - { - var ret = input.readFieldBegin(); - var fname = ret.fname; - var ftype = ret.ftype; - var fid = ret.fid; - if (ftype == Thrift.Type.STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == Thrift.Type.STRING) { - this.title = input.readString(); - } else { - input.skip(ftype); - } - break; - case 2: - if (ftype == Thrift.Type.STRING) { - this.share = input.readString(); - } else { - input.skip(ftype); - } - break; - case 3: - if (ftype == Thrift.Type.I16) { - this.minScore = input.readI16(); - } else { - input.skip(ftype); - } - break; - default: - input.skip(ftype); - } - input.readFieldEnd(); - } - input.readStructEnd(); - return; -}; - -tenfour.ResultGroup.prototype.write = function(output) { - output.writeStructBegin('ResultGroup'); - if (this.title !== null && this.title !== undefined) { - output.writeFieldBegin('title', Thrift.Type.STRING, 1); - output.writeString(this.title); - output.writeFieldEnd(); - } - if (this.share !== null && this.share !== undefined) { - output.writeFieldBegin('share', Thrift.Type.STRING, 2); - output.writeString(this.share); - output.writeFieldEnd(); - } - if (this.minScore !== null && this.minScore !== undefined) { - output.writeFieldBegin('minScore', Thrift.Type.I16, 3); - output.writeI16(this.minScore); - output.writeFieldEnd(); - } - output.writeFieldStop(); - output.writeStructEnd(); - return; -}; - -tenfour.Question = module.exports.Question = function(args) { - this.questionText = null; - this.assets = null; - this.answers = null; - if (args) { - if (args.questionText !== undefined) { - this.questionText = args.questionText; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field questionText is unset!'); - } - if (args.assets !== undefined) { - this.assets = args.assets; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field assets is unset!'); - } - if (args.answers !== undefined) { - this.answers = args.answers; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field answers is unset!'); - } - } -}; -tenfour.Question.prototype = {}; -tenfour.Question.prototype.read = function(input) { - input.readStructBegin(); - while (true) - { - var ret = input.readFieldBegin(); - var fname = ret.fname; - var ftype = ret.ftype; - var fid = ret.fid; - if (ftype == Thrift.Type.STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == Thrift.Type.STRING) { - this.questionText = input.readString(); - } else { - input.skip(ftype); - } - break; - case 2: - if (ftype == Thrift.Type.LIST) { - var _size16 = 0; - var _rtmp320; - this.assets = []; - var _etype19 = 0; - _rtmp320 = input.readListBegin(); - _etype19 = _rtmp320.etype; - _size16 = _rtmp320.size; - for (var _i21 = 0; _i21 < _size16; ++_i21) - { - var elem22 = null; - elem22 = new ttypes.Asset(); - elem22.read(input); - this.assets.push(elem22); - } - input.readListEnd(); - } else { - input.skip(ftype); - } - break; - case 3: - if (ftype == Thrift.Type.LIST) { - var _size23 = 0; - var _rtmp327; - this.answers = []; - var _etype26 = 0; - _rtmp327 = input.readListBegin(); - _etype26 = _rtmp327.etype; - _size23 = _rtmp327.size; - for (var _i28 = 0; _i28 < _size23; ++_i28) - { - var elem29 = null; - elem29 = new ttypes.Answer(); - elem29.read(input); - this.answers.push(elem29); - } - input.readListEnd(); - } else { - input.skip(ftype); - } - break; - default: - input.skip(ftype); - } - input.readFieldEnd(); - } - input.readStructEnd(); - return; -}; - -tenfour.Question.prototype.write = function(output) { - output.writeStructBegin('Question'); - if (this.questionText !== null && this.questionText !== undefined) { - output.writeFieldBegin('questionText', Thrift.Type.STRING, 1); - output.writeString(this.questionText); - output.writeFieldEnd(); - } - if (this.assets !== null && this.assets !== undefined) { - output.writeFieldBegin('assets', Thrift.Type.LIST, 2); - output.writeListBegin(Thrift.Type.STRUCT, this.assets.length); - for (var iter30 in this.assets) - { - if (this.assets.hasOwnProperty(iter30)) - { - iter30 = this.assets[iter30]; - iter30.write(output); - } - } - output.writeListEnd(); - output.writeFieldEnd(); - } - if (this.answers !== null && this.answers !== undefined) { - output.writeFieldBegin('answers', Thrift.Type.LIST, 3); - output.writeListBegin(Thrift.Type.STRUCT, this.answers.length); - for (var iter31 in this.answers) - { - if (this.answers.hasOwnProperty(iter31)) - { - iter31 = this.answers[iter31]; - iter31.write(output); - } - } - output.writeListEnd(); - output.writeFieldEnd(); - } - output.writeFieldStop(); - output.writeStructEnd(); - return; -}; - -tenfour.Answer = module.exports.Answer = function(args) { - this.answerText = null; - this.assets = null; - this.correct = null; - this.revealText = null; - if (args) { - if (args.answerText !== undefined) { - this.answerText = args.answerText; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field answerText is unset!'); - } - if (args.assets !== undefined) { - this.assets = args.assets; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field assets is unset!'); - } - if (args.correct !== undefined) { - this.correct = args.correct; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field correct is unset!'); - } - if (args.revealText !== undefined) { - this.revealText = args.revealText; - } - } -}; -tenfour.Answer.prototype = {}; -tenfour.Answer.prototype.read = function(input) { - input.readStructBegin(); - while (true) - { - var ret = input.readFieldBegin(); - var fname = ret.fname; - var ftype = ret.ftype; - var fid = ret.fid; - if (ftype == Thrift.Type.STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == Thrift.Type.STRING) { - this.answerText = input.readString(); - } else { - input.skip(ftype); - } - break; - case 2: - if (ftype == Thrift.Type.LIST) { - var _size32 = 0; - var _rtmp336; - this.assets = []; - var _etype35 = 0; - _rtmp336 = input.readListBegin(); - _etype35 = _rtmp336.etype; - _size32 = _rtmp336.size; - for (var _i37 = 0; _i37 < _size32; ++_i37) - { - var elem38 = null; - elem38 = new ttypes.Asset(); - elem38.read(input); - this.assets.push(elem38); - } - input.readListEnd(); - } else { - input.skip(ftype); - } - break; - case 3: - if (ftype == Thrift.Type.BOOL) { - this.correct = input.readBool(); - } else { - input.skip(ftype); - } - break; - case 4: - if (ftype == Thrift.Type.STRING) { - this.revealText = input.readString(); - } else { - input.skip(ftype); - } - break; - default: - input.skip(ftype); - } - input.readFieldEnd(); - } - input.readStructEnd(); - return; -}; - -tenfour.Answer.prototype.write = function(output) { - output.writeStructBegin('Answer'); - if (this.answerText !== null && this.answerText !== undefined) { - output.writeFieldBegin('answerText', Thrift.Type.STRING, 1); - output.writeString(this.answerText); - output.writeFieldEnd(); - } - if (this.assets !== null && this.assets !== undefined) { - output.writeFieldBegin('assets', Thrift.Type.LIST, 2); - output.writeListBegin(Thrift.Type.STRUCT, this.assets.length); - for (var iter39 in this.assets) - { - if (this.assets.hasOwnProperty(iter39)) - { - iter39 = this.assets[iter39]; - iter39.write(output); - } - } - output.writeListEnd(); - output.writeFieldEnd(); - } - if (this.correct !== null && this.correct !== undefined) { - output.writeFieldBegin('correct', Thrift.Type.BOOL, 3); - output.writeBool(this.correct); - output.writeFieldEnd(); - } - if (this.revealText !== null && this.revealText !== undefined) { - output.writeFieldBegin('revealText', Thrift.Type.STRING, 4); - output.writeString(this.revealText); - output.writeFieldEnd(); - } - output.writeFieldStop(); - output.writeStructEnd(); - return; -}; - -tenfour.Asset = module.exports.Asset = function(args) { - this.type = null; - this.data = null; - if (args) { - if (args.type !== undefined) { - this.type = args.type; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field type is unset!'); - } - if (args.data !== undefined) { - this.data = args.data; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field data is unset!'); - } - } -}; -tenfour.Asset.prototype = {}; -tenfour.Asset.prototype.read = function(input) { - input.readStructBegin(); - while (true) - { - var ret = input.readFieldBegin(); - var fname = ret.fname; - var ftype = ret.ftype; - var fid = ret.fid; - if (ftype == Thrift.Type.STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == Thrift.Type.STRING) { - this.type = input.readString(); - } else { - input.skip(ftype); - } - break; - case 2: - if (ftype == Thrift.Type.STRING) { - this.data = input.readString(); - } else { - input.skip(ftype); - } - break; - default: - input.skip(ftype); - } - input.readFieldEnd(); - } - input.readStructEnd(); - return; -}; - -tenfour.Asset.prototype.write = function(output) { - output.writeStructBegin('Asset'); - if (this.type !== null && this.type !== undefined) { - output.writeFieldBegin('type', Thrift.Type.STRING, 1); - output.writeString(this.type); - output.writeFieldEnd(); - } - if (this.data !== null && this.data !== undefined) { - output.writeFieldBegin('data', Thrift.Type.STRING, 2); - output.writeString(this.data); - output.writeFieldEnd(); - } - output.writeFieldStop(); - output.writeStructEnd(); - return; -}; - diff --git a/js/main.js b/js/main.js index 0156e5e..f461df3 100644 --- a/js/main.js +++ b/js/main.js @@ -1,3 +1,2 @@ exports.contentAtomTypes = require('../generated/gen-nodejs/contentatom_types'); -exports.eventTypes = require('../generated/gen-nodejs/events_types'); -exports.tenfourTypes = require('../generated/gen-nodejs/tenfour_types'); +exports.quizTypes = require('../generated/gen-nodejs/quiz_types'); From 42981ed64d631396a3250bd733c44b92c76c5179 Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Wed, 2 Sep 2015 15:02:43 +0100 Subject: [PATCH 14/18] use weight for the answers to support multiple correct in the future --- generated/gen-nodejs/quiz_types.js | 18 +++++++++--------- thrift/atoms/quiz.thrift | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/generated/gen-nodejs/quiz_types.js b/generated/gen-nodejs/quiz_types.js index 7d3aaf9..539c5cc 100644 --- a/generated/gen-nodejs/quiz_types.js +++ b/generated/gen-nodejs/quiz_types.js @@ -696,7 +696,7 @@ contentatom.quiz.Question.prototype.write = function(output) { contentatom.quiz.Answer = module.exports.Answer = function(args) { this.answerText = null; this.assets = null; - this.correct = null; + this.weight = null; this.revealText = null; if (args) { if (args.answerText !== undefined) { @@ -709,10 +709,10 @@ contentatom.quiz.Answer = module.exports.Answer = function(args) { } else { throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field assets is unset!'); } - if (args.correct !== undefined) { - this.correct = args.correct; + if (args.weight !== undefined) { + this.weight = args.weight; } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field correct is unset!'); + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field weight is unset!'); } if (args.revealText !== undefined) { this.revealText = args.revealText; @@ -762,8 +762,8 @@ contentatom.quiz.Answer.prototype.read = function(input) { } break; case 3: - if (ftype == Thrift.Type.BOOL) { - this.correct = input.readBool(); + if (ftype == Thrift.Type.I16) { + this.weight = input.readI16(); } else { input.skip(ftype); } @@ -805,9 +805,9 @@ contentatom.quiz.Answer.prototype.write = function(output) { output.writeListEnd(); output.writeFieldEnd(); } - if (this.correct !== null && this.correct !== undefined) { - output.writeFieldBegin('correct', Thrift.Type.BOOL, 3); - output.writeBool(this.correct); + if (this.weight !== null && this.weight !== undefined) { + output.writeFieldBegin('weight', Thrift.Type.I16, 3); + output.writeI16(this.weight); output.writeFieldEnd(); } if (this.revealText !== null && this.revealText !== undefined) { diff --git a/thrift/atoms/quiz.thrift b/thrift/atoms/quiz.thrift index a70af41..ccd8ffb 100644 --- a/thrift/atoms/quiz.thrift +++ b/thrift/atoms/quiz.thrift @@ -47,7 +47,7 @@ struct Question { struct Answer { 1: required string answerText 2: required list assets - 3: required bool correct + 3: required i16 weight 4: optional string revealText } From 3602a97870242b3c67576696ebf0abaf02f08b59 Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Thu, 3 Sep 2015 16:46:41 +0100 Subject: [PATCH 15/18] use ContentChangeDetails in content-atom model --- generated/gen-nodejs/contentatom_types.js | 122 +++++++++++++++++ generated/gen-nodejs/shared_types.js | 153 ++++++++++++++++++++++ js/main.js | 1 + thrift/contentatom.thrift | 20 +++ thrift/shared.thrift | 18 +++ 5 files changed, 314 insertions(+) diff --git a/generated/gen-nodejs/contentatom_types.js b/generated/gen-nodejs/contentatom_types.js index 11d6ff8..faa75ad 100644 --- a/generated/gen-nodejs/contentatom_types.js +++ b/generated/gen-nodejs/contentatom_types.js @@ -26,6 +26,7 @@ Atom = module.exports.Atom = function(args) { this.labels = null; this.defaultBody = null; this.data = null; + this.contentChangeDetails = null; if (args) { if (args.id !== undefined) { this.id = args.id; @@ -52,6 +53,11 @@ Atom = module.exports.Atom = function(args) { } else { throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field data is unset!'); } + if (args.contentChangeDetails !== undefined) { + this.contentChangeDetails = args.contentChangeDetails; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field contentChangeDetails is unset!'); + } } }; Atom.prototype = {}; @@ -117,6 +123,14 @@ Atom.prototype.read = function(input) { input.skip(ftype); } break; + case 6: + if (ftype == Thrift.Type.STRUCT) { + this.contentChangeDetails = new ttypes.ContentChangeDetails(); + this.contentChangeDetails.read(input); + } else { + input.skip(ftype); + } + break; default: input.skip(ftype); } @@ -162,6 +176,11 @@ Atom.prototype.write = function(output) { this.data.write(output); output.writeFieldEnd(); } + if (this.contentChangeDetails !== null && this.contentChangeDetails !== undefined) { + output.writeFieldBegin('contentChangeDetails', Thrift.Type.STRUCT, 6); + this.contentChangeDetails.write(output); + output.writeFieldEnd(); + } output.writeFieldStop(); output.writeStructEnd(); return; @@ -310,3 +329,106 @@ ContentAtomEvent.prototype.write = function(output) { return; }; +ContentChangeDetails = module.exports.ContentChangeDetails = function(args) { + this.lastModified = null; + this.created = null; + this.published = null; + this.revision = null; + if (args) { + if (args.lastModified !== undefined) { + this.lastModified = args.lastModified; + } + if (args.created !== undefined) { + this.created = args.created; + } + if (args.published !== undefined) { + this.published = args.published; + } + if (args.revision !== undefined) { + this.revision = args.revision; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field revision is unset!'); + } + } +}; +ContentChangeDetails.prototype = {}; +ContentChangeDetails.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRUCT) { + this.lastModified = new shared_ttypes.ChangeRecord(); + this.lastModified.read(input); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.STRUCT) { + this.created = new shared_ttypes.ChangeRecord(); + this.created.read(input); + } else { + input.skip(ftype); + } + break; + case 3: + if (ftype == Thrift.Type.STRUCT) { + this.published = new shared_ttypes.ChangeRecord(); + this.published.read(input); + } else { + input.skip(ftype); + } + break; + case 4: + if (ftype == Thrift.Type.I64) { + this.revision = input.readI64(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +ContentChangeDetails.prototype.write = function(output) { + output.writeStructBegin('ContentChangeDetails'); + if (this.lastModified !== null && this.lastModified !== undefined) { + output.writeFieldBegin('lastModified', Thrift.Type.STRUCT, 1); + this.lastModified.write(output); + output.writeFieldEnd(); + } + if (this.created !== null && this.created !== undefined) { + output.writeFieldBegin('created', Thrift.Type.STRUCT, 2); + this.created.write(output); + output.writeFieldEnd(); + } + if (this.published !== null && this.published !== undefined) { + output.writeFieldBegin('published', Thrift.Type.STRUCT, 3); + this.published.write(output); + output.writeFieldEnd(); + } + if (this.revision !== null && this.revision !== undefined) { + output.writeFieldBegin('revision', Thrift.Type.I64, 4); + output.writeI64(this.revision); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + diff --git a/generated/gen-nodejs/shared_types.js b/generated/gen-nodejs/shared_types.js index 69278bd..6548bb9 100644 --- a/generated/gen-nodejs/shared_types.js +++ b/generated/gen-nodejs/shared_types.js @@ -9,3 +9,156 @@ var Q = thrift.Q; var ttypes = module.exports = {}; +ChangeRecord = module.exports.ChangeRecord = function(args) { + this.date = null; + this.user = null; + if (args) { + if (args.date !== undefined) { + this.date = args.date; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field date is unset!'); + } + if (args.user !== undefined) { + this.user = args.user; + } + } +}; +ChangeRecord.prototype = {}; +ChangeRecord.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.I64) { + this.date = input.readI64(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.STRUCT) { + this.user = new ttypes.User(); + this.user.read(input); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +ChangeRecord.prototype.write = function(output) { + output.writeStructBegin('ChangeRecord'); + if (this.date !== null && this.date !== undefined) { + output.writeFieldBegin('date', Thrift.Type.I64, 1); + output.writeI64(this.date); + output.writeFieldEnd(); + } + if (this.user !== null && this.user !== undefined) { + output.writeFieldBegin('user', Thrift.Type.STRUCT, 2); + this.user.write(output); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + +User = module.exports.User = function(args) { + this.email = null; + this.firstName = null; + this.lastName = null; + if (args) { + if (args.email !== undefined) { + this.email = args.email; + } else { + throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field email is unset!'); + } + if (args.firstName !== undefined) { + this.firstName = args.firstName; + } + if (args.lastName !== undefined) { + this.lastName = args.lastName; + } + } +}; +User.prototype = {}; +User.prototype.read = function(input) { + input.readStructBegin(); + while (true) + { + var ret = input.readFieldBegin(); + var fname = ret.fname; + var ftype = ret.ftype; + var fid = ret.fid; + if (ftype == Thrift.Type.STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == Thrift.Type.STRING) { + this.email = input.readString(); + } else { + input.skip(ftype); + } + break; + case 2: + if (ftype == Thrift.Type.STRING) { + this.firstName = input.readString(); + } else { + input.skip(ftype); + } + break; + case 3: + if (ftype == Thrift.Type.STRING) { + this.lastName = input.readString(); + } else { + input.skip(ftype); + } + break; + default: + input.skip(ftype); + } + input.readFieldEnd(); + } + input.readStructEnd(); + return; +}; + +User.prototype.write = function(output) { + output.writeStructBegin('User'); + if (this.email !== null && this.email !== undefined) { + output.writeFieldBegin('email', Thrift.Type.STRING, 1); + output.writeString(this.email); + output.writeFieldEnd(); + } + if (this.firstName !== null && this.firstName !== undefined) { + output.writeFieldBegin('firstName', Thrift.Type.STRING, 2); + output.writeString(this.firstName); + output.writeFieldEnd(); + } + if (this.lastName !== null && this.lastName !== undefined) { + output.writeFieldBegin('lastName', Thrift.Type.STRING, 3); + output.writeString(this.lastName); + output.writeFieldEnd(); + } + output.writeFieldStop(); + output.writeStructEnd(); + return; +}; + diff --git a/js/main.js b/js/main.js index f461df3..ccc5afe 100644 --- a/js/main.js +++ b/js/main.js @@ -1,2 +1,3 @@ exports.contentAtomTypes = require('../generated/gen-nodejs/contentatom_types'); exports.quizTypes = require('../generated/gen-nodejs/quiz_types'); +exports.shared = require('../generated/gen-nodejs/shared_types'); diff --git a/thrift/contentatom.thrift b/thrift/contentatom.thrift index 5bec9ee..920bdac 100644 --- a/thrift/contentatom.thrift +++ b/thrift/contentatom.thrift @@ -11,6 +11,7 @@ struct Atom { 3: required list labels // required, but may be empty 4: required string defaultBody 5: required AtomData data // the atom payload + 6: required ContentChangeDetails contentChangeDetails } union AtomData { @@ -24,3 +25,22 @@ struct ContentAtomEvent { 2: required EventType eventType 3: required shared.DateTime eventCreationTime } + +struct ContentChangeDetails { + + /** the latest change to the content atom */ + 1: optional shared.ChangeRecord lastModified + + /** the atom creation event */ + 2: optional shared.ChangeRecord created + + /** the atom publication event (if published) */ + 3: optional shared.ChangeRecord published + /** + * the revision number of the content. + * + * This value is incremented whenever content is written to the database and can be used to + * ensure message ordering. + */ + 4: required i64 revision +} diff --git a/thrift/shared.thrift b/thrift/shared.thrift index 4685489..272b45d 100644 --- a/thrift/shared.thrift +++ b/thrift/shared.thrift @@ -2,3 +2,21 @@ typedef i64 DateTime typedef string OpaqueJson + +struct ChangeRecord { + + /** when the change occured */ + 1: required DateTime date; + + /** the user that performed the change */ + 2: optional User user; +} + +struct User { + + 1: required string email; + + 2: optional string firstName; + + 3: optional string lastName; +} From 0c63be05691f2ce5f96ef373bc2f254dc84f6fce Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Thu, 3 Sep 2015 17:15:59 +0100 Subject: [PATCH 16/18] polls etc will be separate atom type --- thrift/atoms/quiz.thrift | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/thrift/atoms/quiz.thrift b/thrift/atoms/quiz.thrift index ccd8ffb..9aaee1c 100644 --- a/thrift/atoms/quiz.thrift +++ b/thrift/atoms/quiz.thrift @@ -14,12 +14,7 @@ struct QuizAtom { 7 : required bool published 8 : required string quizType 9 : optional i16 defaultColumns - 10 : required ItemContent content -} - -// will vary depending on item's type -union ItemContent { - 1: QuizContent quiz + 10 : required QuizContent content } struct QuizContent { From 3b393587e63be5380920df0abc21f2d484594852 Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Thu, 3 Sep 2015 17:32:19 +0100 Subject: [PATCH 17/18] remove duplicated content metadata 'quiz' atom type was storing creation time etc which is duplicated at the 'atom' level --- generated/gen-nodejs/quiz_types.js | 128 +---------------------------- thrift/atoms/quiz.thrift | 4 - 2 files changed, 1 insertion(+), 131 deletions(-) diff --git a/generated/gen-nodejs/quiz_types.js b/generated/gen-nodejs/quiz_types.js index 539c5cc..997c56e 100644 --- a/generated/gen-nodejs/quiz_types.js +++ b/generated/gen-nodejs/quiz_types.js @@ -20,10 +20,6 @@ if (typeof contentatom.quiz === 'undefined') { contentatom.quiz.QuizAtom = module.exports.QuizAtom = function(args) { this.id = null; this.title = null; - this.updatedBy = null; - this.updatedAt = null; - this.createdAt = null; - this.createdBy = null; this.published = null; this.quizType = null; this.defaultColumns = null; @@ -39,26 +35,6 @@ contentatom.quiz.QuizAtom = module.exports.QuizAtom = function(args) { } else { throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field title is unset!'); } - if (args.updatedBy !== undefined) { - this.updatedBy = args.updatedBy; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field updatedBy is unset!'); - } - if (args.updatedAt !== undefined) { - this.updatedAt = args.updatedAt; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field updatedAt is unset!'); - } - if (args.createdAt !== undefined) { - this.createdAt = args.createdAt; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field createdAt is unset!'); - } - if (args.createdBy !== undefined) { - this.createdBy = args.createdBy; - } else { - throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.UNKNOWN, 'Required field createdBy is unset!'); - } if (args.published !== undefined) { this.published = args.published; } else { @@ -107,34 +83,6 @@ contentatom.quiz.QuizAtom.prototype.read = function(input) { input.skip(ftype); } break; - case 3: - if (ftype == Thrift.Type.STRING) { - this.updatedBy = input.readString(); - } else { - input.skip(ftype); - } - break; - case 4: - if (ftype == Thrift.Type.I64) { - this.updatedAt = input.readI64(); - } else { - input.skip(ftype); - } - break; - case 5: - if (ftype == Thrift.Type.I64) { - this.createdAt = input.readI64(); - } else { - input.skip(ftype); - } - break; - case 6: - if (ftype == Thrift.Type.STRING) { - this.createdBy = input.readString(); - } else { - input.skip(ftype); - } - break; case 7: if (ftype == Thrift.Type.BOOL) { this.published = input.readBool(); @@ -158,7 +106,7 @@ contentatom.quiz.QuizAtom.prototype.read = function(input) { break; case 10: if (ftype == Thrift.Type.STRUCT) { - this.content = new ttypes.ItemContent(); + this.content = new ttypes.QuizContent(); this.content.read(input); } else { input.skip(ftype); @@ -185,26 +133,6 @@ contentatom.quiz.QuizAtom.prototype.write = function(output) { output.writeString(this.title); output.writeFieldEnd(); } - if (this.updatedBy !== null && this.updatedBy !== undefined) { - output.writeFieldBegin('updatedBy', Thrift.Type.STRING, 3); - output.writeString(this.updatedBy); - output.writeFieldEnd(); - } - if (this.updatedAt !== null && this.updatedAt !== undefined) { - output.writeFieldBegin('updatedAt', Thrift.Type.I64, 4); - output.writeI64(this.updatedAt); - output.writeFieldEnd(); - } - if (this.createdAt !== null && this.createdAt !== undefined) { - output.writeFieldBegin('createdAt', Thrift.Type.I64, 5); - output.writeI64(this.createdAt); - output.writeFieldEnd(); - } - if (this.createdBy !== null && this.createdBy !== undefined) { - output.writeFieldBegin('createdBy', Thrift.Type.STRING, 6); - output.writeString(this.createdBy); - output.writeFieldEnd(); - } if (this.published !== null && this.published !== undefined) { output.writeFieldBegin('published', Thrift.Type.BOOL, 7); output.writeBool(this.published); @@ -230,60 +158,6 @@ contentatom.quiz.QuizAtom.prototype.write = function(output) { return; }; -contentatom.quiz.ItemContent = module.exports.ItemContent = function(args) { - this.quiz = null; - if (args) { - if (args.quiz !== undefined) { - this.quiz = args.quiz; - } - } -}; -contentatom.quiz.ItemContent.prototype = {}; -contentatom.quiz.ItemContent.prototype.read = function(input) { - input.readStructBegin(); - while (true) - { - var ret = input.readFieldBegin(); - var fname = ret.fname; - var ftype = ret.ftype; - var fid = ret.fid; - if (ftype == Thrift.Type.STOP) { - break; - } - switch (fid) - { - case 1: - if (ftype == Thrift.Type.STRUCT) { - this.quiz = new ttypes.QuizContent(); - this.quiz.read(input); - } else { - input.skip(ftype); - } - break; - case 0: - input.skip(ftype); - break; - default: - input.skip(ftype); - } - input.readFieldEnd(); - } - input.readStructEnd(); - return; -}; - -contentatom.quiz.ItemContent.prototype.write = function(output) { - output.writeStructBegin('ItemContent'); - if (this.quiz !== null && this.quiz !== undefined) { - output.writeFieldBegin('quiz', Thrift.Type.STRUCT, 1); - this.quiz.write(output); - output.writeFieldEnd(); - } - output.writeFieldStop(); - output.writeStructEnd(); - return; -}; - contentatom.quiz.QuizContent = module.exports.QuizContent = function(args) { this.questions = null; this.resultGroups = null; diff --git a/thrift/atoms/quiz.thrift b/thrift/atoms/quiz.thrift index 9aaee1c..f33f107 100644 --- a/thrift/atoms/quiz.thrift +++ b/thrift/atoms/quiz.thrift @@ -7,10 +7,6 @@ struct QuizAtom { // content-atom wrapping? 1 : required string id 2 : required string title - 3 : required string updatedBy - 4 : required shared.DateTime updatedAt - 5 : required shared.DateTime createdAt - 6 : required string createdBy 7 : required bool published 8 : required string quizType 9 : optional i16 defaultColumns From f95323b5e7297a3299caf7d4114ed5c3c3600a7d Mon Sep 17 00:00:00 2001 From: Paul Roberts Date: Fri, 4 Sep 2015 14:03:12 +0100 Subject: [PATCH 18/18] minor tweaks from pr --- thrift/contentatom.thrift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thrift/contentatom.thrift b/thrift/contentatom.thrift index 920bdac..092a4d8 100644 --- a/thrift/contentatom.thrift +++ b/thrift/contentatom.thrift @@ -9,7 +9,7 @@ struct Atom { 1: required ContentAtomID id 2: required AtomType atomType 3: required list labels // required, but may be empty - 4: required string defaultBody + 4: required string defaultHtml 5: required AtomData data // the atom payload 6: required ContentChangeDetails contentChangeDetails } @@ -18,7 +18,7 @@ union AtomData { 1: quiz.QuizAtom quiz } -enum EventType { PUBLISH, UPDATE, TAKEDOWN } +enum EventType { UPDATE, TAKEDOWN } struct ContentAtomEvent { 1: required Atom atom