Advertisement
NLinker

Image entity generated by thrift

Apr 11th, 2016
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 24.09 KB | None | 0 0
  1. /**
  2.  * Autogenerated by Thrift Compiler (0.9.1)
  3.  *
  4.  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  5.  *  @generated
  6. ```
  7.  * Some comment...
  8. struct Image {
  9.   1: string uri,              //url to the images
  10.   2: optional string title,..
  11.   3: required int width,
  12.   4: required int height,
  13.   5: required Size size,
  14. }
  15. ```
  16.  */
  17. package serializers.thrift.media;
  18.  
  19. import org.apache.thrift.scheme.IScheme;
  20. import org.apache.thrift.scheme.SchemeFactory;
  21. import org.apache.thrift.scheme.StandardScheme;
  22.  
  23. import org.apache.thrift.scheme.TupleScheme;
  24. import org.apache.thrift.protocol.TTupleProtocol;
  25. import org.apache.thrift.protocol.TProtocolException;
  26. import org.apache.thrift.EncodingUtils;
  27. import org.apache.thrift.TException;
  28. import org.apache.thrift.async.AsyncMethodCallback;
  29. import org.apache.thrift.server.AbstractNonblockingServer.*;
  30. import java.util.List;
  31. import java.util.ArrayList;
  32. import java.util.Map;
  33. import java.util.HashMap;
  34. import java.util.EnumMap;
  35. import java.util.Set;
  36. import java.util.HashSet;
  37. import java.util.EnumSet;
  38. import java.util.Collections;
  39. import java.util.BitSet;
  40. import java.nio.ByteBuffer;
  41. import java.util.Arrays;
  42. import org.slf4j.Logger;
  43. import org.slf4j.LoggerFactory;
  44.  
  45. /**
  46.  * Some comment...
  47.  */
  48. public class Image implements org.apache.thrift.TBase<Image, Image._Fields>, java.io.Serializable, Cloneable, Comparable<Image> {
  49.   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Image");
  50.  
  51.   private static final org.apache.thrift.protocol.TField URI_FIELD_DESC = new org.apache.thrift.protocol.TField("uri", org.apache.thrift.protocol.TType.STRING, (short)1);
  52.   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);
  53.   private static final org.apache.thrift.protocol.TField WIDTH_FIELD_DESC = new org.apache.thrift.protocol.TField("width", org.apache.thrift.protocol.TType.I32, (short)3);
  54.   private static final org.apache.thrift.protocol.TField HEIGHT_FIELD_DESC = new org.apache.thrift.protocol.TField("height", org.apache.thrift.protocol.TType.I32, (short)4);
  55.   private static final org.apache.thrift.protocol.TField SIZE_FIELD_DESC = new org.apache.thrift.protocol.TField("size", org.apache.thrift.protocol.TType.I32, (short)5);
  56.  
  57.   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
  58.   static {
  59.     schemes.put(StandardScheme.class, new ImageStandardSchemeFactory());
  60.     schemes.put(TupleScheme.class, new ImageTupleSchemeFactory());
  61.   }
  62.  
  63.   private String uri; // required
  64.   private String title; // optional
  65.   private int width; // required
  66.   private int height; // required
  67.   private Size size; // required
  68.  
  69.   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  70.   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
  71.     URI((short)1, "uri"),
  72.     TITLE((short)2, "title"),
  73.     WIDTH((short)3, "width"),
  74.     HEIGHT((short)4, "height"),
  75.     /**
  76.      *
  77.      * @see Size
  78.      */
  79.     SIZE((short)5, "size");
  80.  
  81.     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
  82.  
  83.     static {
  84.       for (_Fields field : EnumSet.allOf(_Fields.class)) {
  85.         byName.put(field.getFieldName(), field);
  86.       }
  87.     }
  88.  
  89.     /**
  90.      * Find the _Fields constant that matches fieldId, or null if its not found.
  91.      */
  92.     public static _Fields findByThriftId(int fieldId) {
  93.       switch(fieldId) {
  94.         case 1: // URI
  95.           return URI;
  96.         case 2: // TITLE
  97.           return TITLE;
  98.         case 3: // WIDTH
  99.           return WIDTH;
  100.         case 4: // HEIGHT
  101.           return HEIGHT;
  102.         case 5: // SIZE
  103.           return SIZE;
  104.         default:
  105.           return null;
  106.       }
  107.     }
  108.  
  109.     /**
  110.      * Find the _Fields constant that matches fieldId, throwing an exception
  111.      * if it is not found.
  112.      */
  113.     public static _Fields findByThriftIdOrThrow(int fieldId) {
  114.       _Fields fields = findByThriftId(fieldId);
  115.       if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
  116.       return fields;
  117.     }
  118.  
  119.     /**
  120.      * Find the _Fields constant that matches name, or null if its not found.
  121.      */
  122.     public static _Fields findByName(String name) {
  123.       return byName.get(name);
  124.     }
  125.  
  126.     private final short _thriftId;
  127.     private final String _fieldName;
  128.  
  129.     _Fields(short thriftId, String fieldName) {
  130.       _thriftId = thriftId;
  131.       _fieldName = fieldName;
  132.     }
  133.  
  134.     public short getThriftFieldId() {
  135.       return _thriftId;
  136.     }
  137.  
  138.     public String getFieldName() {
  139.       return _fieldName;
  140.     }
  141.   }
  142.  
  143.   // isset id assignments
  144.   private static final int __WIDTH_ISSET_ID = 0;
  145.   private static final int __HEIGHT_ISSET_ID = 1;
  146.   private byte __isset_bitfield = 0;
  147.   private _Fields optionals[] = {_Fields.TITLE};
  148.   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  149.   static {
  150.     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
  151.     tmpMap.put(_Fields.URI, new org.apache.thrift.meta_data.FieldMetaData("uri", org.apache.thrift.TFieldRequirementType.DEFAULT,
  152.         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
  153.     tmpMap.put(_Fields.TITLE, new org.apache.thrift.meta_data.FieldMetaData("title", org.apache.thrift.TFieldRequirementType.OPTIONAL,
  154.         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
  155.     tmpMap.put(_Fields.WIDTH, new org.apache.thrift.meta_data.FieldMetaData("width", org.apache.thrift.TFieldRequirementType.REQUIRED,
  156.         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32        , "int")));
  157.     tmpMap.put(_Fields.HEIGHT, new org.apache.thrift.meta_data.FieldMetaData("height", org.apache.thrift.TFieldRequirementType.REQUIRED,
  158.         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32        , "int")));
  159.     tmpMap.put(_Fields.SIZE, new org.apache.thrift.meta_data.FieldMetaData("size", org.apache.thrift.TFieldRequirementType.REQUIRED,
  160.         new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, Size.class)));
  161.     metaDataMap = Collections.unmodifiableMap(tmpMap);
  162.     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Image.class, metaDataMap);
  163.   }
  164.  
  165.   public Image() {
  166.   }
  167.  
  168.   public Image(
  169.     String uri,
  170.     int width,
  171.     int height,
  172.     Size size)
  173.   {
  174.     this();
  175.     this.uri = uri;
  176.     this.width = width;
  177.     setWidthIsSet(true);
  178.     this.height = height;
  179.     setHeightIsSet(true);
  180.     this.size = size;
  181.   }
  182.  
  183.   /**
  184.    * Performs a deep copy on <i>other</i>.
  185.    */
  186.   public Image(Image other) {
  187.     __isset_bitfield = other.__isset_bitfield;
  188.     if (other.isSetUri()) {
  189.       this.uri = other.uri;
  190.     }
  191.     if (other.isSetTitle()) {
  192.       this.title = other.title;
  193.     }
  194.     this.width = other.width;
  195.     this.height = other.height;
  196.     if (other.isSetSize()) {
  197.       this.size = other.size;
  198.     }
  199.   }
  200.  
  201.   public Image deepCopy() {
  202.     return new Image(this);
  203.   }
  204.  
  205.   @Override
  206.   public void clear() {
  207.     this.uri = null;
  208.     this.title = null;
  209.     setWidthIsSet(false);
  210.     this.width = 0;
  211.     setHeightIsSet(false);
  212.     this.height = 0;
  213.     this.size = null;
  214.   }
  215.  
  216.   public String getUri() {
  217.     return this.uri;
  218.   }
  219.  
  220.   public Image setUri(String uri) {
  221.     this.uri = uri;
  222.     return this;
  223.   }
  224.  
  225.   public void unsetUri() {
  226.     this.uri = null;
  227.   }
  228.  
  229.   /** Returns true if field uri is set (has been assigned a value) and false otherwise */
  230.   public boolean isSetUri() {
  231.     return this.uri != null;
  232.   }
  233.  
  234.   public void setUriIsSet(boolean value) {
  235.     if (!value) {
  236.       this.uri = null;
  237.     }
  238.   }
  239.  
  240.   public String getTitle() {
  241.     return this.title;
  242.   }
  243.  
  244.   public Image setTitle(String title) {
  245.     this.title = title;
  246.     return this;
  247.   }
  248.  
  249.   public void unsetTitle() {
  250.     this.title = null;
  251.   }
  252.  
  253.   /** Returns true if field title is set (has been assigned a value) and false otherwise */
  254.   public boolean isSetTitle() {
  255.     return this.title != null;
  256.   }
  257.  
  258.   public void setTitleIsSet(boolean value) {
  259.     if (!value) {
  260.       this.title = null;
  261.     }
  262.   }
  263.  
  264.   public int getWidth() {
  265.     return this.width;
  266.   }
  267.  
  268.   public Image setWidth(int width) {
  269.     this.width = width;
  270.     setWidthIsSet(true);
  271.     return this;
  272.   }
  273.  
  274.   public void unsetWidth() {
  275.     __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __WIDTH_ISSET_ID);
  276.   }
  277.  
  278.   /** Returns true if field width is set (has been assigned a value) and false otherwise */
  279.   public boolean isSetWidth() {
  280.     return EncodingUtils.testBit(__isset_bitfield, __WIDTH_ISSET_ID);
  281.   }
  282.  
  283.   public void setWidthIsSet(boolean value) {
  284.     __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __WIDTH_ISSET_ID, value);
  285.   }
  286.  
  287.   public int getHeight() {
  288.     return this.height;
  289.   }
  290.  
  291.   public Image setHeight(int height) {
  292.     this.height = height;
  293.     setHeightIsSet(true);
  294.     return this;
  295.   }
  296.  
  297.   public void unsetHeight() {
  298.     __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __HEIGHT_ISSET_ID);
  299.   }
  300.  
  301.   /** Returns true if field height is set (has been assigned a value) and false otherwise */
  302.   public boolean isSetHeight() {
  303.     return EncodingUtils.testBit(__isset_bitfield, __HEIGHT_ISSET_ID);
  304.   }
  305.  
  306.   public void setHeightIsSet(boolean value) {
  307.     __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __HEIGHT_ISSET_ID, value);
  308.   }
  309.  
  310.   /**
  311.    *
  312.    * @see Size
  313.    */
  314.   public Size getSize() {
  315.     return this.size;
  316.   }
  317.  
  318.   /**
  319.    *
  320.    * @see Size
  321.    */
  322.   public Image setSize(Size size) {
  323.     this.size = size;
  324.     return this;
  325.   }
  326.  
  327.   public void unsetSize() {
  328.     this.size = null;
  329.   }
  330.  
  331.   /** Returns true if field size is set (has been assigned a value) and false otherwise */
  332.   public boolean isSetSize() {
  333.     return this.size != null;
  334.   }
  335.  
  336.   public void setSizeIsSet(boolean value) {
  337.     if (!value) {
  338.       this.size = null;
  339.     }
  340.   }
  341.  
  342.   public void setFieldValue(_Fields field, Object value) {
  343.     switch (field) {
  344.     case URI:
  345.       if (value == null) {
  346.         unsetUri();
  347.       } else {
  348.         setUri((String)value);
  349.       }
  350.       break;
  351.  
  352.     case TITLE:
  353.       if (value == null) {
  354.         unsetTitle();
  355.       } else {
  356.         setTitle((String)value);
  357.       }
  358.       break;
  359.  
  360.     case WIDTH:
  361.       if (value == null) {
  362.         unsetWidth();
  363.       } else {
  364.         setWidth((Integer)value);
  365.       }
  366.       break;
  367.  
  368.     case HEIGHT:
  369.       if (value == null) {
  370.         unsetHeight();
  371.       } else {
  372.         setHeight((Integer)value);
  373.       }
  374.       break;
  375.  
  376.     case SIZE:
  377.       if (value == null) {
  378.         unsetSize();
  379.       } else {
  380.         setSize((Size)value);
  381.       }
  382.       break;
  383.  
  384.     }
  385.   }
  386.  
  387.   public Object getFieldValue(_Fields field) {
  388.     switch (field) {
  389.     case URI:
  390.       return getUri();
  391.  
  392.     case TITLE:
  393.       return getTitle();
  394.  
  395.     case WIDTH:
  396.       return Integer.valueOf(getWidth());
  397.  
  398.     case HEIGHT:
  399.       return Integer.valueOf(getHeight());
  400.  
  401.     case SIZE:
  402.       return getSize();
  403.  
  404.     }
  405.     throw new IllegalStateException();
  406.   }
  407.  
  408.   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  409.   public boolean isSet(_Fields field) {
  410.     if (field == null) {
  411.       throw new IllegalArgumentException();
  412.     }
  413.  
  414.     switch (field) {
  415.     case URI:
  416.       return isSetUri();
  417.     case TITLE:
  418.       return isSetTitle();
  419.     case WIDTH:
  420.       return isSetWidth();
  421.     case HEIGHT:
  422.       return isSetHeight();
  423.     case SIZE:
  424.       return isSetSize();
  425.     }
  426.     throw new IllegalStateException();
  427.   }
  428.  
  429.   @Override
  430.   public boolean equals(Object that) {
  431.     if (that == null)
  432.       return false;
  433.     if (that instanceof Image)
  434.       return this.equals((Image)that);
  435.     return false;
  436.   }
  437.  
  438.   public boolean equals(Image that) {
  439.     if (that == null)
  440.       return false;
  441.  
  442.     boolean this_present_uri = true && this.isSetUri();
  443.     boolean that_present_uri = true && that.isSetUri();
  444.     if (this_present_uri || that_present_uri) {
  445.       if (!(this_present_uri && that_present_uri))
  446.         return false;
  447.       if (!this.uri.equals(that.uri))
  448.         return false;
  449.     }
  450.  
  451.     boolean this_present_title = true && this.isSetTitle();
  452.     boolean that_present_title = true && that.isSetTitle();
  453.     if (this_present_title || that_present_title) {
  454.       if (!(this_present_title && that_present_title))
  455.         return false;
  456.       if (!this.title.equals(that.title))
  457.         return false;
  458.     }
  459.  
  460.     boolean this_present_width = true;
  461.     boolean that_present_width = true;
  462.     if (this_present_width || that_present_width) {
  463.       if (!(this_present_width && that_present_width))
  464.         return false;
  465.       if (this.width != that.width)
  466.         return false;
  467.     }
  468.  
  469.     boolean this_present_height = true;
  470.     boolean that_present_height = true;
  471.     if (this_present_height || that_present_height) {
  472.       if (!(this_present_height && that_present_height))
  473.         return false;
  474.       if (this.height != that.height)
  475.         return false;
  476.     }
  477.  
  478.     boolean this_present_size = true && this.isSetSize();
  479.     boolean that_present_size = true && that.isSetSize();
  480.     if (this_present_size || that_present_size) {
  481.       if (!(this_present_size && that_present_size))
  482.         return false;
  483.       if (!this.size.equals(that.size))
  484.         return false;
  485.     }
  486.  
  487.     return true;
  488.   }
  489.  
  490.   @Override
  491.   public int hashCode() {
  492.     return 0;
  493.   }
  494.  
  495.   @Override
  496.   public int compareTo(Image other) {
  497.     if (!getClass().equals(other.getClass())) {
  498.       return getClass().getName().compareTo(other.getClass().getName());
  499.     }
  500.  
  501.     int lastComparison = 0;
  502.  
  503.     lastComparison = Boolean.valueOf(isSetUri()).compareTo(other.isSetUri());
  504.     if (lastComparison != 0) {
  505.       return lastComparison;
  506.     }
  507.     if (isSetUri()) {
  508.       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.uri, other.uri);
  509.       if (lastComparison != 0) {
  510.         return lastComparison;
  511.       }
  512.     }
  513.     lastComparison = Boolean.valueOf(isSetTitle()).compareTo(other.isSetTitle());
  514.     if (lastComparison != 0) {
  515.       return lastComparison;
  516.     }
  517.     if (isSetTitle()) {
  518.       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.title, other.title);
  519.       if (lastComparison != 0) {
  520.         return lastComparison;
  521.       }
  522.     }
  523.     lastComparison = Boolean.valueOf(isSetWidth()).compareTo(other.isSetWidth());
  524.     if (lastComparison != 0) {
  525.       return lastComparison;
  526.     }
  527.     if (isSetWidth()) {
  528.       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.width, other.width);
  529.       if (lastComparison != 0) {
  530.         return lastComparison;
  531.       }
  532.     }
  533.     lastComparison = Boolean.valueOf(isSetHeight()).compareTo(other.isSetHeight());
  534.     if (lastComparison != 0) {
  535.       return lastComparison;
  536.     }
  537.     if (isSetHeight()) {
  538.       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.height, other.height);
  539.       if (lastComparison != 0) {
  540.         return lastComparison;
  541.       }
  542.     }
  543.     lastComparison = Boolean.valueOf(isSetSize()).compareTo(other.isSetSize());
  544.     if (lastComparison != 0) {
  545.       return lastComparison;
  546.     }
  547.     if (isSetSize()) {
  548.       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.size, other.size);
  549.       if (lastComparison != 0) {
  550.         return lastComparison;
  551.       }
  552.     }
  553.     return 0;
  554.   }
  555.  
  556.   public _Fields fieldForId(int fieldId) {
  557.     return _Fields.findByThriftId(fieldId);
  558.   }
  559.  
  560.   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
  561.     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
  562.   }
  563.  
  564.   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
  565.     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
  566.   }
  567.  
  568.   @Override
  569.   public String toString() {
  570.     StringBuilder sb = new StringBuilder("Image(");
  571.     boolean first = true;
  572.  
  573.     sb.append("uri:");
  574.     if (this.uri == null) {
  575.       sb.append("null");
  576.     } else {
  577.       sb.append(this.uri);
  578.     }
  579.     first = false;
  580.     if (isSetTitle()) {
  581.       if (!first) sb.append(", ");
  582.       sb.append("title:");
  583.       if (this.title == null) {
  584.         sb.append("null");
  585.       } else {
  586.         sb.append(this.title);
  587.       }
  588.       first = false;
  589.     }
  590.     if (!first) sb.append(", ");
  591.     sb.append("width:");
  592.     sb.append(this.width);
  593.     first = false;
  594.     if (!first) sb.append(", ");
  595.     sb.append("height:");
  596.     sb.append(this.height);
  597.     first = false;
  598.     if (!first) sb.append(", ");
  599.     sb.append("size:");
  600.     if (this.size == null) {
  601.       sb.append("null");
  602.     } else {
  603.       sb.append(this.size);
  604.     }
  605.     first = false;
  606.     sb.append(")");
  607.     return sb.toString();
  608.   }
  609.  
  610.   public void validate() throws org.apache.thrift.TException {
  611.     // check for required fields
  612.     // alas, we cannot check 'width' because it's a primitive and you chose the non-beans generator.
  613.     // alas, we cannot check 'height' because it's a primitive and you chose the non-beans generator.
  614.     if (size == null) {
  615.       throw new org.apache.thrift.protocol.TProtocolException("Required field 'size' was not present! Struct: " + toString());
  616.     }
  617.     // check for sub-struct validity
  618.   }
  619.  
  620.   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
  621.     try {
  622.       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
  623.     } catch (org.apache.thrift.TException te) {
  624.       throw new java.io.IOException(te);
  625.     }
  626.   }
  627.  
  628.   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
  629.     try {
  630.       // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
  631.       __isset_bitfield = 0;
  632.       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
  633.     } catch (org.apache.thrift.TException te) {
  634.       throw new java.io.IOException(te);
  635.     }
  636.   }
  637.  
  638.   private static class ImageStandardSchemeFactory implements SchemeFactory {
  639.     public ImageStandardScheme getScheme() {
  640.       return new ImageStandardScheme();
  641.     }
  642.   }
  643.  
  644.   private static class ImageStandardScheme extends StandardScheme<Image> {
  645.  
  646.     public void read(org.apache.thrift.protocol.TProtocol iprot, Image struct) throws org.apache.thrift.TException {
  647.       org.apache.thrift.protocol.TField schemeField;
  648.       iprot.readStructBegin();
  649.       while (true)
  650.       {
  651.         schemeField = iprot.readFieldBegin();
  652.         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
  653.           break;
  654.         }
  655.         switch (schemeField.id) {
  656.           case 1: // URI
  657.             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
  658.               struct.uri = iprot.readString();
  659.               struct.setUriIsSet(true);
  660.             } else {
  661.               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  662.             }
  663.             break;
  664.           case 2: // TITLE
  665.             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
  666.               struct.title = iprot.readString();
  667.               struct.setTitleIsSet(true);
  668.             } else {
  669.               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  670.             }
  671.             break;
  672.           case 3: // WIDTH
  673.             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
  674.               struct.width = iprot.readI32();
  675.               struct.setWidthIsSet(true);
  676.             } else {
  677.               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  678.             }
  679.             break;
  680.           case 4: // HEIGHT
  681.             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
  682.               struct.height = iprot.readI32();
  683.               struct.setHeightIsSet(true);
  684.             } else {
  685.               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  686.             }
  687.             break;
  688.           case 5: // SIZE
  689.             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
  690.               struct.size = Size.findByValue(iprot.readI32());
  691.               struct.setSizeIsSet(true);
  692.             } else {
  693.               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  694.             }
  695.             break;
  696.           default:
  697.             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
  698.         }
  699.         iprot.readFieldEnd();
  700.       }
  701.       iprot.readStructEnd();
  702.  
  703.       // check for required fields of primitive type, which can't be checked in the validate method
  704.       if (!struct.isSetWidth()) {
  705.         throw new org.apache.thrift.protocol.TProtocolException("Required field 'width' was not found in serialized data! Struct: " + toString());
  706.       }
  707.       if (!struct.isSetHeight()) {
  708.         throw new org.apache.thrift.protocol.TProtocolException("Required field 'height' was not found in serialized data! Struct: " + toString());
  709.       }
  710.       struct.validate();
  711.     }
  712.  
  713.     public void write(org.apache.thrift.protocol.TProtocol oprot, Image struct) throws org.apache.thrift.TException {
  714.       struct.validate();
  715.  
  716.       oprot.writeStructBegin(STRUCT_DESC);
  717.       if (struct.uri != null) {
  718.         oprot.writeFieldBegin(URI_FIELD_DESC);
  719.         oprot.writeString(struct.uri);
  720.         oprot.writeFieldEnd();
  721.       }
  722.       if (struct.title != null) {
  723.         if (struct.isSetTitle()) {
  724.           oprot.writeFieldBegin(TITLE_FIELD_DESC);
  725.           oprot.writeString(struct.title);
  726.           oprot.writeFieldEnd();
  727.         }
  728.       }
  729.       oprot.writeFieldBegin(WIDTH_FIELD_DESC);
  730.       oprot.writeI32(struct.width);
  731.       oprot.writeFieldEnd();
  732.       oprot.writeFieldBegin(HEIGHT_FIELD_DESC);
  733.       oprot.writeI32(struct.height);
  734.       oprot.writeFieldEnd();
  735.       if (struct.size != null) {
  736.         oprot.writeFieldBegin(SIZE_FIELD_DESC);
  737.         oprot.writeI32(struct.size.getValue());
  738.         oprot.writeFieldEnd();
  739.       }
  740.       oprot.writeFieldStop();
  741.       oprot.writeStructEnd();
  742.     }
  743.  
  744.   }
  745.  
  746.   private static class ImageTupleSchemeFactory implements SchemeFactory {
  747.     public ImageTupleScheme getScheme() {
  748.       return new ImageTupleScheme();
  749.     }
  750.   }
  751.  
  752.   private static class ImageTupleScheme extends TupleScheme<Image> {
  753.  
  754.     @Override
  755.     public void write(org.apache.thrift.protocol.TProtocol prot, Image struct) throws org.apache.thrift.TException {
  756.       TTupleProtocol oprot = (TTupleProtocol) prot;
  757.       oprot.writeI32(struct.width);
  758.       oprot.writeI32(struct.height);
  759.       oprot.writeI32(struct.size.getValue());
  760.       BitSet optionals = new BitSet();
  761.       if (struct.isSetUri()) {
  762.         optionals.set(0);
  763.       }
  764.       if (struct.isSetTitle()) {
  765.         optionals.set(1);
  766.       }
  767.       oprot.writeBitSet(optionals, 2);
  768.       if (struct.isSetUri()) {
  769.         oprot.writeString(struct.uri);
  770.       }
  771.       if (struct.isSetTitle()) {
  772.         oprot.writeString(struct.title);
  773.       }
  774.     }
  775.  
  776.     @Override
  777.     public void read(org.apache.thrift.protocol.TProtocol prot, Image struct) throws org.apache.thrift.TException {
  778.       TTupleProtocol iprot = (TTupleProtocol) prot;
  779.       struct.width = iprot.readI32();
  780.       struct.setWidthIsSet(true);
  781.       struct.height = iprot.readI32();
  782.       struct.setHeightIsSet(true);
  783.       struct.size = Size.findByValue(iprot.readI32());
  784.       struct.setSizeIsSet(true);
  785.       BitSet incoming = iprot.readBitSet(2);
  786.       if (incoming.get(0)) {
  787.         struct.uri = iprot.readString();
  788.         struct.setUriIsSet(true);
  789.       }
  790.       if (incoming.get(1)) {
  791.         struct.title = iprot.readString();
  792.         struct.setTitleIsSet(true);
  793.       }
  794.     }
  795.   }
  796.  
  797. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement