ex
Fork of mbed-os-example-mbed5-blinky by
Diff: dcs-sdk-java-master/app/src/main/java/com/baidu/duer/dcs/http/builder/GetBuilder.java
- Revision:
- 49:b9eb462f36a9
- Parent:
- 48:c7ee67edcf1d
- Child:
- 50:9ecaa144d1f3
--- a/dcs-sdk-java-master/app/src/main/java/com/baidu/duer/dcs/http/builder/GetBuilder.java Tue Jul 18 16:56:22 2017 +0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2017 Baidu, Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.baidu.duer.dcs.http.builder;
-
-import android.net.Uri;
-
-import com.baidu.duer.dcs.http.request.GetRequest;
-import com.baidu.duer.dcs.http.request.RequestCall;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * get请求构建
- * <p>
- * Created by guxiuzhong@baidu.com on 2017/5/15.
- */
-public class GetBuilder extends OkHttpRequestBuilder<GetBuilder> implements HasParamInterface {
- @Override
- public RequestCall build() {
- if (params != null) {
- url = appendParams(url, params);
- }
- return new GetRequest(url, tag, params, headers, id).build();
- }
-
- /**
- * 添加参数到url上
- *
- * @param url url 请求的url
- * @param params params 参数集合
- * @return url 拼接后的url
- */
- protected String appendParams(String url, Map<String, String> params) {
- if (url == null || params == null || params.isEmpty()) {
- return url;
- }
- Uri.Builder builder = Uri.parse(url).buildUpon();
- Set<String> keys = params.keySet();
- Iterator<String> iterator = keys.iterator();
- while (iterator.hasNext()) {
- String key = iterator.next();
- builder.appendQueryParameter(key, params.get(key));
- }
- return builder.build().toString();
- }
-
-
- @Override
- public GetBuilder params(Map<String, String> params) {
- this.params = params;
- return this;
- }
-
- @Override
- public GetBuilder addParams(String key, String val) {
- if (this.params == null) {
- params = new LinkedHashMap<>();
- }
- params.put(key, val);
- return this;
- }
-}
\ No newline at end of file
