gpt4 book ai didi

com.weibo.yar.YarResponse类的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 18:38:31 26 4
gpt4 key购买 nike

本文整理了Java中com.weibo.yar.YarResponse类的一些代码示例,展示了YarResponse类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YarResponse类的具体详情如下:
包路径:com.weibo.yar.YarResponse
类名称:YarResponse

YarResponse介绍

暂无

代码示例

代码示例来源:origin: weibocom/motan

public static YarResponse convert(Response response, String packagerName) {
  YarResponse yarResponse = new YarResponse();
  yarResponse.setId(response.getRequestId());
  yarResponse.setPackagerName(packagerName);
  if (response.getException() != null) {
    if (response.getException() instanceof MotanBizException) {
      yarResponse.setError(response.getException().getCause().getMessage());
    } else {
      yarResponse.setError(response.getException().getMessage());
    }
  } else {
    yarResponse.setRet(response.getValue());
  }
  return yarResponse;
}

代码示例来源:origin: weibocom/motan

public static Response convert(YarResponse yarResponse) {
  DefaultResponse response = new DefaultResponse();
  response.setRequestId(yarResponse.getId());
  response.setValue(yarResponse.getRet());
  if (StringUtils.isNotBlank(yarResponse.getError())) {
    response.setException(new MotanBizException(yarResponse.getError()));
  }
  return response;
}

代码示例来源:origin: weibocom/motan

public static YarResponse buildDefaultErrorResponse(String errMsg, String packagerName) {
  YarResponse yarResponse = new YarResponse();
  yarResponse.setPackagerName(packagerName);
  yarResponse.setError(errMsg);
  yarResponse.setStatus("500");
  return yarResponse;
}

代码示例来源:origin: com.weibo/yar-java

@SuppressWarnings("rawtypes")
public static YarResponse buildResponse(byte[] responseBytes) throws IOException {
  if (responseBytes == null) {
    throw new YarException("response bytes is null");
  }
  Map contentMap = fetchContent(responseBytes);
  YarResponse response = new YarResponse();
  response.setPackagerName((String) contentMap.get("ext-packagerName"));
  if (contentMap.containsKey("i")) {
    response.setId(((Number) contentMap.get("i")).longValue());
  }
  if (contentMap.containsKey("s")) {
    response.setStatus(contentMap.get("s").toString());
  }
  if (contentMap.containsKey("o")) {
    response.setOutput(contentMap.get("o"));
  }
  if (contentMap.containsKey("e")) {
    response.setError(contentMap.get("e").toString());
  }
  if (contentMap.containsKey("r")) {
    response.setRet(contentMap.get("r"));
  }
  return response;
}

代码示例来源:origin: com.weibo/yar-java

public static byte[] toProtocolBytes(YarResponse response) throws IOException {
  if (response == null) {
    throw new YarException("YarResponse is null");
  }
  Map<String, Object> responseMap = new HashMap<String, Object>();
  responseMap.put("i", response.getId());
  responseMap.put("s", response.getStatus());
  if (response.getRet() != null) {
    responseMap.put("r", response.getRet());
  }
  if (response.getOutput() != null) {
    responseMap.put("o", response.getOutput());
  }
  if (response.getError() != null) {
    responseMap.put("e", response.getError());
  }
  String packagerName = response.getPackagerName();
  return toProtocolBytes(response.getId(), packagerName, responseMap);
}

代码示例来源:origin: com.weibo/yar-java

protected <E> E buildResponse(byte[] responseBytes, Class<E> responseClass) throws IOException {
  YarResponse yarResponse = YarProtocol.buildResponse(responseBytes);
  if (yarResponse == null || yarResponse.getError() != null) {
    throw new YarException(yarResponse == null ? "yar response is null" : yarResponse.getError());
  }
  E value = yarResponse.getValue(responseClass);
  return value;
}

代码示例来源:origin: com.weibo/yar-java

private YarResponse process(YarRequest request) {
  YarResponse response = new YarResponse();
  response.setId(request.getId());
  response.setPackagerName(request.getPackagerName());
  JSONObject jo = new JSONObject();
  jo.put("key", "test");
  response.setRet(jo);
  return response;
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com