javax.ws.rs.core.GenericType#getRawType()源码实例Demo

下面列出了javax.ws.rs.core.GenericType#getRawType() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openapi-generator   文件: ApiClient.java
/**
 * Deserialize response body to Java object according to the Content-Type.
 * @param <T> Type
 * @param response Response
 * @param returnType Return type
 * @return Deserialize object
 * @throws ApiException API exception
 */
@SuppressWarnings("unchecked")
public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException {
  if (response == null || returnType == null) {
    return null;
  }

  if ("byte[]".equals(returnType.toString())) {
    // Handle binary response (byte array).
    return (T) response.readEntity(byte[].class);
  } else if (returnType.getRawType() == File.class) {
    // Handle file downloading.
    T file = (T) downloadFileFromResponse(response);
    return file;
  }

  String contentType = null;
  List<Object> contentTypes = response.getHeaders().get("Content-Type");
  if (contentTypes != null && !contentTypes.isEmpty())
    contentType = String.valueOf(contentTypes.get(0));

  // read the entity stream multiple times
  response.bufferEntity();

  return response.readEntity(returnType);
}
 
源代码2 项目: openapi-generator   文件: ApiClient.java
/**
 * Deserialize response body to Java object according to the Content-Type.
 * @param <T> Type
 * @param response Response
 * @param returnType Return type
 * @return Deserialize object
 * @throws ApiException API exception
 */
@SuppressWarnings("unchecked")
public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException {
  if (response == null || returnType == null) {
    return null;
  }

  if ("byte[]".equals(returnType.toString())) {
    // Handle binary response (byte array).
    return (T) response.readEntity(byte[].class);
  } else if (returnType.getRawType() == File.class) {
    // Handle file downloading.
    T file = (T) downloadFileFromResponse(response);
    return file;
  }

  String contentType = null;
  List<Object> contentTypes = response.getHeaders().get("Content-Type");
  if (contentTypes != null && !contentTypes.isEmpty())
    contentType = String.valueOf(contentTypes.get(0));

  // read the entity stream multiple times
  response.bufferEntity();

  return response.readEntity(returnType);
}
 
源代码3 项目: connect-java-sdk   文件: ApiClient.java
/**
 * Deserialize response body to Java object according to the Content-Type.
 * @param <T> Type
 * @param response Response
 * @param returnType Return type
 * @return Deserialize object
 * @throws ApiException API exception
 */
@SuppressWarnings("unchecked")
public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException {
  if (response == null || returnType == null) {
    return null;
  }

  if ("byte[]".equals(returnType.toString())) {
    // Handle binary response (byte array).
    return (T) response.readEntity(byte[].class);
  } else if (returnType.getRawType() == File.class) {
    // Handle file downloading.
    T file = (T) downloadFileFromResponse(response);
    return file;
  }

  String contentType = null;
  List<Object> contentTypes = response.getHeaders().get("Content-Type");
  if (contentTypes != null && !contentTypes.isEmpty())
    contentType = String.valueOf(contentTypes.get(0));
  if (contentType == null)
    throw new ApiException(500, "missing Content-Type in response");

  return response.readEntity(returnType);
}
 
源代码4 项目: cyberduck   文件: ApiClient.java
/**
 * Deserialize response body to Java object according to the Content-Type.
 * @param <T> Type
 * @param response Response
 * @param returnType Return type
 * @return Deserialize object
 * @throws ApiException API exception
 */
@SuppressWarnings("unchecked")
public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException {
  if (response == null || returnType == null) {
    return null;
  }

  if ("byte[]".equals(returnType.toString())) {
    // Handle binary response (byte array).
    return (T) response.readEntity(byte[].class);
  } else if (returnType.getRawType() == File.class) {
    // Handle file downloading.
    T file = (T) downloadFileFromResponse(response);
    return file;
  }

  String contentType = null;
  List<Object> contentTypes = response.getHeaders().get("Content-Type");
  if (contentTypes != null && !contentTypes.isEmpty())
    contentType = String.valueOf(contentTypes.get(0));

  return response.readEntity(returnType);
}
 
源代码5 项目: cyberduck   文件: ApiClient.java
/**
 * Deserialize response body to Java object according to the Content-Type.
 * @param <T> Type
 * @param response Response
 * @param returnType Return type
 * @return Deserialize object
 * @throws ApiException API exception
 */
@SuppressWarnings("unchecked")
public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException {
  if (response == null || returnType == null) {
    return null;
  }

  if ("byte[]".equals(returnType.toString())) {
    // Handle binary response (byte array).
    return (T) response.readEntity(byte[].class);
  } else if (returnType.getRawType() == File.class) {
    // Handle file downloading.
    T file = (T) downloadFileFromResponse(response);
    return file;
  }

  String contentType = null;
  List<Object> contentTypes = response.getHeaders().get("Content-Type");
  if (contentTypes != null && !contentTypes.isEmpty())
    contentType = String.valueOf(contentTypes.get(0));

  return response.readEntity(returnType);
}
 
源代码6 项目: cxf   文件: WebClient.java
/**
 * Does HTTP invocation and returns types response object
 * @param httpMethod HTTP method
 * @param body request body, can be null
 * @param responseType generic response type
 * @return typed object, can be null. Response status code and headers
 *         can be obtained too, see Client.getResponse()
 */
public <T> T invoke(String httpMethod, Object body, GenericType<T> responseType) {
    @SuppressWarnings("unchecked")
    Class<T> responseClass = (Class<T>)responseType.getRawType();
    Response r = doInvoke(httpMethod, body, null, responseClass, responseType.getType());
    return castResponse(r, responseClass);
}
 
 方法所在类
 同类方法