Пример #1
0
  public static class Builder {
    private String _url = null;
    private Boolean _got_url = false;

    public Builder url(String value) {
      this._url = value;
      this._got_url = true;
      return this;
    }

    private String _title = null;
    private Boolean _got_title = false;

    public Builder title(String value) {
      this._title = value;
      this._got_title = true;
      return this;
    }

    private String _keywords = null;
    private Boolean _got_keywords = false;

    public Builder keywords(String value) {
      this._keywords = value;
      this._got_keywords = true;
      return this;
    }

    private List<RecommendTypeParam> _types = Utilities.makeList();
    private Boolean _got_types = false;

    public Builder types(List<RecommendTypeParam> value) {
      this._types = value;
      this._got_types = true;
      return this;
    }

    public RecommendParam build() {
      if (!_got_url)
        throw new IllegalStateException(
            "Required field 'url' was not found for struct RecommendParam");
      if (!_got_types)
        throw new IllegalStateException(
            "Required field 'types' was not found for struct RecommendParam");
      return new RecommendParam(
          this._url,
          Option.make(this._got_title, this._title),
          Option.make(this._got_keywords, this._keywords),
          this._types);
    }
  }
Пример #2
0
 public RecommendParam decode(TProtocol _iprot) throws org.apache.thrift.TException {
   Builder builder = new Builder();
   String url = null;
   String title = null;
   String keywords = null;
   List<RecommendTypeParam> types = Utilities.makeList();
   Boolean _done = false;
   _iprot.readStructBegin();
   while (!_done) {
     TField _field = _iprot.readFieldBegin();
     if (_field.type == TType.STOP) {
       _done = true;
     } else {
       switch (_field.id) {
         case 1: /* url */
           switch (_field.type) {
             case TType.STRING:
               String url_item;
               url_item = _iprot.readString();
               url = url_item;
               break;
             default:
               TProtocolUtil.skip(_iprot, _field.type);
           }
           builder.url(url);
           break;
         case 2: /* title */
           switch (_field.type) {
             case TType.STRING:
               String title_item;
               title_item = _iprot.readString();
               title = title_item;
               break;
             default:
               TProtocolUtil.skip(_iprot, _field.type);
           }
           builder.title(title);
           break;
         case 3: /* keywords */
           switch (_field.type) {
             case TType.STRING:
               String keywords_item;
               keywords_item = _iprot.readString();
               keywords = keywords_item;
               break;
             default:
               TProtocolUtil.skip(_iprot, _field.type);
           }
           builder.keywords(keywords);
           break;
         case 4: /* types */
           switch (_field.type) {
             case TType.LIST:
               List<RecommendTypeParam> types_item;
               TList _list_types_item = _iprot.readListBegin();
               types_item = new ArrayList<RecommendTypeParam>();
               int _i_types_item = 0;
               RecommendTypeParam _types_item_element;
               while (_i_types_item < _list_types_item.size) {
                 _types_item_element = RecommendTypeParam.decode(_iprot);
                 types_item.add(_types_item_element);
                 _i_types_item += 1;
               }
               _iprot.readListEnd();
               types = types_item;
               break;
             default:
               TProtocolUtil.skip(_iprot, _field.type);
           }
           builder.types(types);
           break;
         default:
           TProtocolUtil.skip(_iprot, _field.type);
       }
       _iprot.readFieldEnd();
     }
   }
   _iprot.readStructEnd();
   try {
     return builder.build();
   } catch (IllegalStateException stateEx) {
     throw new TProtocolException(stateEx.getMessage());
   }
 }