Advertisement
NLinker

Image entity generated by protostuff

Apr 11th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.77 KB | None | 0 0
  1. // Generated by http://code.google.com/p/protostuff/ ... DO NOT EDIT!
  2. // Generated from proto
  3. /*
  4.  
  5. message Image {
  6.   required string uri = 1;      //url to the thumbnail
  7.   optional string title = 2;    //used in the html ALT
  8.   required int32 width = 3;     // of the image
  9.   required int32 height = 4;    // of the image
  10.   enum Size {
  11.     SMALL = 0;
  12.     LARGE = 1;
  13.   }
  14.   required Size size = 5;       // of the image (in relative terms, provided by cnbc for example)
  15. }
  16.  
  17. */
  18.  
  19. package serializers.protobuf.media;
  20.  
  21. import javax.annotation.Generated;
  22. import java.io.Externalizable;
  23. import java.io.IOException;
  24. import java.io.ObjectInput;
  25. import java.io.ObjectOutput;
  26. import java.util.Objects;
  27.  
  28. import io.protostuff.GraphIOUtil;
  29. import io.protostuff.Input;
  30. import io.protostuff.Message;
  31. import io.protostuff.Output;
  32. import io.protostuff.Schema;
  33.  
  34. import io.protostuff.UninitializedMessageException;
  35. @Generated("java_bean")
  36. public final class Image implements Externalizable, Message<Image>, Schema<Image>
  37. {
  38.     @Generated("java_bean")
  39.     public enum Size implements io.protostuff.EnumLite<Size>
  40.     {
  41.         SMALL(0),
  42.         LARGE(1);
  43.        
  44.         public final int number;
  45.        
  46.         private Size (int number)
  47.         {
  48.             this.number = number;
  49.         }
  50.        
  51.         public int getNumber()
  52.         {
  53.             return number;
  54.         }
  55.        
  56.         public static Size valueOf(int number)
  57.         {
  58.             switch(number)
  59.             {
  60.                 case 0: return SMALL;
  61.                 case 1: return LARGE;
  62.                 default: return null;
  63.             }
  64.         }
  65.     }
  66.  
  67.  
  68.     public static Schema<Image> getSchema()
  69.     {
  70.         return DEFAULT_INSTANCE;
  71.     }
  72.  
  73.     public static Image getDefaultInstance()
  74.     {
  75.         return DEFAULT_INSTANCE;
  76.     }
  77.  
  78.     static final Image DEFAULT_INSTANCE = new Image();
  79.  
  80.    
  81.     private String uri;
  82.     private String title;
  83.     private Integer width;
  84.     private Integer height;
  85.     private Size size;
  86.  
  87.     public Image()
  88.     {
  89.  
  90.     }
  91.  
  92.     public Image(
  93.         String uri,
  94.         Integer width,
  95.         Integer height,
  96.         Size size
  97.     )
  98.     {
  99.         this.uri = uri;
  100.         this.width = width;
  101.         this.height = height;
  102.         this.size = size;
  103.     }
  104.  
  105.     // getters and setters
  106.  
  107.     // uri
  108.  
  109.     public String getUri()
  110.     {
  111.         return uri;
  112.     }
  113.  
  114.  
  115.     public Image setUri(String uri)
  116.     {
  117.         this.uri = uri;
  118.         return this;
  119.     }
  120.  
  121.     // title
  122.  
  123.     public String getTitle()
  124.     {
  125.         return title;
  126.     }
  127.  
  128.  
  129.     public Image setTitle(String title)
  130.     {
  131.         this.title = title;
  132.         return this;
  133.     }
  134.  
  135.     // width
  136.  
  137.     public Integer getWidth()
  138.     {
  139.         return width;
  140.     }
  141.  
  142.  
  143.     public Image setWidth(Integer width)
  144.     {
  145.         this.width = width;
  146.         return this;
  147.     }
  148.  
  149.     // height
  150.  
  151.     public Integer getHeight()
  152.     {
  153.         return height;
  154.     }
  155.  
  156.  
  157.     public Image setHeight(Integer height)
  158.     {
  159.         this.height = height;
  160.         return this;
  161.     }
  162.  
  163.     // size
  164.  
  165.     public Size getSize()
  166.     {
  167.         return size;
  168.     }
  169.  
  170.  
  171.     public Image setSize(Size size)
  172.     {
  173.         this.size = size;
  174.         return this;
  175.     }
  176.  
  177.     @Override
  178.     public boolean equals(Object obj) {
  179.         if (this == obj) {
  180.             return true;
  181.         }
  182.         if (obj == null || this.getClass() != obj.getClass()) {
  183.             return false;
  184.         }
  185.         final Image that = (Image) obj;
  186.         return
  187.                 Objects.equals(this.uri, that.uri) &&
  188.                 Objects.equals(this.title, that.title) &&
  189.                 Objects.equals(this.width, that.width) &&
  190.                 Objects.equals(this.height, that.height) &&
  191.                 Objects.equals(this.size, that.size);
  192.     }
  193.  
  194.     @Override
  195.     public int hashCode() {
  196.         return Objects.hash(uri, title, width, height, size);
  197.     }
  198.  
  199.     @Override
  200.     public String toString() {
  201.         return "Image{" +
  202.                     "uri=" + uri +
  203.                     ", title=" + title +
  204.                     ", width=" + width +
  205.                     ", height=" + height +
  206.                     ", size=" + size +
  207.                 '}';
  208.     }
  209.     // java serialization
  210.  
  211.     public void readExternal(ObjectInput in) throws IOException
  212.     {
  213.         GraphIOUtil.mergeDelimitedFrom(in, this, this);
  214.     }
  215.  
  216.     public void writeExternal(ObjectOutput out) throws IOException
  217.     {
  218.         GraphIOUtil.writeDelimitedTo(out, this, this);
  219.     }
  220.  
  221.     // message method
  222.  
  223.     public Schema<Image> cachedSchema()
  224.     {
  225.         return DEFAULT_INSTANCE;
  226.     }
  227.  
  228.     // schema methods
  229.  
  230.     public Image newMessage()
  231.     {
  232.         return new Image();
  233.     }
  234.  
  235.     public Class<Image> typeClass()
  236.     {
  237.         return Image.class;
  238.     }
  239.  
  240.     public String messageName()
  241.     {
  242.         return Image.class.getSimpleName();
  243.     }
  244.  
  245.     public String messageFullName()
  246.     {
  247.         return Image.class.getName();
  248.     }
  249.  
  250.     public boolean isInitialized(Image message)
  251.     {
  252.         return
  253.             message.uri != null
  254.             && message.width != null
  255.             && message.height != null
  256.             && message.size != null;
  257.     }
  258.  
  259.     public void mergeFrom(Input input, Image message) throws IOException
  260.     {
  261.         for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  262.         {
  263.             switch(number)
  264.             {
  265.                 case 0:
  266.                     return;
  267.                 case 1:
  268.                     message.uri = input.readString();
  269.                     break;
  270.                 case 2:
  271.                     message.title = input.readString();
  272.                     break;
  273.                 case 3:
  274.                     message.width = input.readInt32();
  275.                     break;
  276.                 case 4:
  277.                     message.height = input.readInt32();
  278.                     break;
  279.                 case 5:
  280.                     message.size = Size.valueOf(input.readEnum());
  281.                     break;
  282.  
  283.                 default:
  284.                     input.handleUnknownField(number, this);
  285.             }  
  286.         }
  287.     }
  288.  
  289.  
  290.     public void writeTo(Output output, Image message) throws IOException
  291.     {
  292.         if(message.uri == null)
  293.             throw new UninitializedMessageException(message);
  294.         output.writeString(1, message.uri, false);
  295.  
  296.         if(message.title != null)
  297.             output.writeString(2, message.title, false);
  298.  
  299.         if(message.width == null)
  300.             throw new UninitializedMessageException(message);
  301.         output.writeInt32(3, message.width, false);
  302.  
  303.         if(message.height == null)
  304.             throw new UninitializedMessageException(message);
  305.         output.writeInt32(4, message.height, false);
  306.  
  307.         if(message.size == null)
  308.             throw new UninitializedMessageException(message);
  309.         output.writeEnum(5, message.size.number, false);
  310.     }
  311.  
  312.     public String getFieldName(int number)
  313.     {
  314.         switch(number)
  315.         {
  316.             case 1: return "uri";
  317.             case 2: return "title";
  318.             case 3: return "width";
  319.             case 4: return "height";
  320.             case 5: return "size";
  321.             default: return null;
  322.         }
  323.     }
  324.  
  325.     public int getFieldNumber(String name)
  326.     {
  327.         final Integer number = __fieldMap.get(name);
  328.         return number == null ? 0 : number.intValue();
  329.     }
  330.  
  331.     private static final java.util.HashMap<String,Integer> __fieldMap = new java.util.HashMap<String,Integer>();
  332.     static
  333.     {
  334.         __fieldMap.put("uri", 1);
  335.         __fieldMap.put("title", 2);
  336.         __fieldMap.put("width", 3);
  337.         __fieldMap.put("height", 4);
  338.         __fieldMap.put("size", 5);
  339.     }
  340.    
  341.  
  342. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement