java.lang.reflect.Type Java Examples

The following examples show how to use java.lang.reflect.Type. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TypeUtil.java    From blueocean-plugin with MIT License 7 votes vote down vote up
public Type onParameterizdType(ParameterizedType p, Class sup) {
    Class raw = (Class) p.getRawType();
    if(raw==sup) {
        // p is of the form sup<...>
        return p;
    } else {
        // recursively visit super class/interfaces
        Type r = raw.getGenericSuperclass();
        if(r!=null)
            r = visit(bind(r,raw,p),sup);
        if(r!=null)
            return r;
        for( Type i : raw.getGenericInterfaces() ) {
            r = visit(bind(i,raw,p),sup);
            if(r!=null)  return r;
        }
        return null;
    }
}
 
Example #2
Source File: Input.java    From red5-io with Apache License 2.0 6 votes vote down vote up
@Override
public Object readArray(Type target) {
    log.debug("readArray - target: {}", target);
    Object result = null;
    int count = buf.getInt();
    log.debug("Count: {}", count);
    // To conform to the Input API, we should convert the output into an Array if the Type asks us to.
    Class<?> collection = Collection.class;
    if (target instanceof Class<?>) {
        collection = (Class<?>) target;
    }
    List<Object> resultCollection = new ArrayList<>(count);
    if (collection.isArray()) {
        result = ArrayUtils.getArray(collection.getComponentType(), count);
    } else {
        result = resultCollection;
    }
    storeReference(result); // reference should be stored before reading of objects to get correct refIds
    for (int i = 0; i < count; i++) {
        resultCollection.add(Deserializer.deserialize(this, Object.class));
    }
    if (collection.isArray()) {
        ArrayUtils.fillArray(collection.getComponentType(), result, resultCollection);
    }
    return result;
}
 
Example #3
Source File: MultipartProvider.java    From cxf with Apache License 2.0 6 votes vote down vote up
private <T> DataHandler getHandlerForObject(T obj,
                                        Class<T> cls, Type genericType,
                                        Annotation[] anns,
                                        String mimeType) {
    MediaType mt = JAXRSUtils.toMediaType(mimeType);
    mc.put(ProviderFactory.ACTIVE_JAXRS_PROVIDER_KEY, this);

    MessageBodyWriter<T> r = null;
    try {
        r = mc.getProviders().getMessageBodyWriter(cls, genericType, anns, mt);
    } finally {
        mc.put(ProviderFactory.ACTIVE_JAXRS_PROVIDER_KEY, null);
    }
    if (r == null) {
        org.apache.cxf.common.i18n.Message message =
            new org.apache.cxf.common.i18n.Message("NO_MSG_WRITER",
                                               BUNDLE,
                                               cls);
        LOG.severe(message.toString());
        throw ExceptionUtils.toInternalServerErrorException(null, null);
    }

    return new MessageBodyWriterDataHandler<T>(r, obj, cls, genericType, anns, mt);
}
 
Example #4
Source File: CSVApisUtil.java    From sofa-acts with Apache License 2.0 6 votes vote down vote up
/**
 * get the type of generic
 * @param type
 * @param i
 * @return
 */
public static Class<?> getClass(Type type, int i) {
    if (type instanceof ParameterizedType) {

        return getGenericClass((ParameterizedType) type, i);
    } else if (type instanceof GenericArrayType) {
        return (Class) ((GenericArrayType) type).getGenericComponentType();
    } else if (type instanceof TypeVariable) {
        return getClass(((TypeVariable) type).getBounds()[0], 0);
    } else if (type instanceof WildcardType) {
        WildcardType wuleType = (WildcardType) type;
        if (null != wuleType.getUpperBounds()[0]) {
            return getClass(wuleType.getUpperBounds()[0], 0);
        } else {
            return getClass(wuleType.getLowerBounds()[0], 0);
        }
    } else if (type instanceof Class) {
        return (Class<?>) type;
    } else {
        return (Class<?>) type;
    }
}
 
Example #5
Source File: TypeUtils.java    From ldp4j with Apache License 2.0 6 votes vote down vote up
private String printBounds(String name, Type[] bounds, boolean lower) {
	StringBuilder builder=new StringBuilder();
	builder.append(name);
	if(bounds.length>0) {
		String prefix = lower?"super":"extends";
		builder.append(" ").append(prefix).append(" ");
		for(int i=0;i<bounds.length;i++) {
			if(i>0) {
				builder.append(" & ");
			}
			Type bound = bounds[i];
			builder.append(toString(bound,false));
		}
	}
	return builder.toString();
}
 
Example #6
Source File: JsonStream.java    From java with MIT License 6 votes vote down vote up
public static String serialize(boolean escapeUnicode, Type type, Object obj) {
    JsonStream stream = JsonStreamPool.borrowJsonStream();
    try {
        stream.reset(null);
        stream.writeVal(type, obj);
        if (escapeUnicode) {
            return new String(stream.buf, 0, stream.count);
        } else {
            return new String(stream.buf, 0, stream.count, "UTF8");
        }
    } catch (IOException e) {
        throw new JsonException(e);
    } finally {
        JsonStreamPool.returnJsonStream(stream);
    }
}
 
Example #7
Source File: ContextFromVertx.java    From wisdom with Apache License 2.0 6 votes vote down vote up
/**
 * This will give you the request body nicely parsed. You can register your
 * own parsers depending on the request type.
 * <p>
 *
 * @param classOfT The class of the result.
 * @return The parsed request or null if something went wrong.
 */
@Override
public <T> T body(Class<T> classOfT, Type genericType) {
    String rawContentType = request().contentType();

    // If the Content-type: xxx header is not set we return null.
    // we cannot parse that request.
    if (rawContentType == null) {
        return null;
    }

    // If Content-type is application/json; charset=utf-8 we split away the charset
    // application/json
    String contentTypeOnly = HttpUtils.getContentTypeFromContentTypeAndCharacterSetting(
            rawContentType);

    BodyParser parser = services.getContentEngines().getBodyParserEngineForContentType(contentTypeOnly);

    if (parser == null) {
        return null;
    }

    return parser.invoke(this, classOfT, genericType);
}
 
Example #8
Source File: WindowedStream.java    From flink with Apache License 2.0 6 votes vote down vote up
private static String generateFunctionName(Function function) {
	Class<? extends Function> functionClass = function.getClass();
	if (functionClass.isAnonymousClass()) {
		// getSimpleName returns an empty String for anonymous classes
		Type[] interfaces = functionClass.getInterfaces();
		if (interfaces.length == 0) {
			// extends an existing class (like RichMapFunction)
			Class<?> functionSuperClass = functionClass.getSuperclass();
			return functionSuperClass.getSimpleName() + functionClass.getName().substring(functionClass.getEnclosingClass().getName().length());
		} else {
			// implements a Function interface
			Class<?> functionInterface = functionClass.getInterfaces()[0];
			return functionInterface.getSimpleName() + functionClass.getName().substring(functionClass.getEnclosingClass().getName().length());
		}
	} else {
		return functionClass.getSimpleName();
	}
}
 
Example #9
Source File: TemplateXmlMessageBodyWriter.java    From SeaCloudsPlatform with Apache License 2.0 6 votes vote down vote up
@Override
public long getSize(ITemplate template, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
    if (template.getText()!=null){
        String agreementData;
        try {
            agreementData = (xmlParser == null)?
                    defaultParser.getSerializedData(template.getText()):
                        xmlParser.getSerializedData(template.getText());
            serializedData =  (new String(HEADER + agreementData)).getBytes();
        } catch (ParserException e) {
            catchedException = e;
        } 
    }else {
        logger.error("Error marshalling data agreement text is null");
        throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
    return  serializedData.length;
}
 
Example #10
Source File: TwitterAdsTargetingApiImpl.java    From twitter4j-ads with MIT License 6 votes vote down vote up
@SuppressWarnings("Duplicates")
@Override
public List<TwitterAppStore> searchAppStoreCategories(String q, Optional<TwitterOSType> osType) throws TwitterException {
    List<HttpParameter> params = new ArrayList<>();
    if (TwitterAdUtil.isNotNullOrEmpty(q)) {
        params.add(new HttpParameter(PARAM_Q, q));
    }
    if (osType != null && osType.isPresent()) {
        params.add(new HttpParameter(PARAM_OS_TYPE, osType.get().name()));
    }

    final String baseUrl = twitterAdsClient.getBaseAdsAPIUrl() + PATH_TARGETING_CRITERIA_APP_STORE_CATEGORIES;
    final HttpResponse httpResponse = twitterAdsClient.getRequest(baseUrl, params.toArray(new HttpParameter[params.size()]));
    try {
        final Type type = new TypeToken<BaseAdsListResponse<TwitterAppStore>>() {
        }.getType();

        final BaseAdsListResponse<TwitterAppStore> baseAdsListResponse =
                constructBaseAdsListResponse(httpResponse, httpResponse.asString(), type);
        return baseAdsListResponse == null ? Collections.<TwitterAppStore>emptyList() : baseAdsListResponse.getData();
    } catch (IOException e) {
        throw new TwitterException("Failed to parse response for app store categories");
    }
}
 
Example #11
Source File: FormEncoder.java    From feign-form with Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void encode (Object object, Type bodyType, RequestTemplate template) throws EncodeException {
  String contentTypeValue = getContentTypeValue(template.headers());
  val contentType = ContentType.of(contentTypeValue);
  if (!processors.containsKey(contentType)) {
    delegate.encode(object, bodyType, template);
    return;
  }

  Map<String, Object> data;
  if (MAP_STRING_WILDCARD.equals(bodyType)) {
    data = (Map<String, Object>) object;
  } else if (isUserPojo(bodyType)) {
    data = toMap(object);
  } else {
    delegate.encode(object, bodyType, template);
    return;
  }

  val charset = getCharset(contentTypeValue);
  processors.get(contentType).process(template, charset, data);
}
 
Example #12
Source File: JaxbConverter.java    From conf4j with MIT License 6 votes vote down vote up
@Override
public String toString(Type type, T value, Map<String, String> attributes) {
    requireNonNull(type, "type cannot be null");

    if (value == null) {
        return null;
    }

    @SuppressWarnings("unchecked")
    JaxbPool jaxbPool = getJaxbPool((Class<T>) type);
    try (Handle<Marshaller> handle = jaxbPool.borrowMarshaller()) {
        Marshaller marshaller = handle.get();
        StringWriter stringWriter = new StringWriter();
        marshaller.marshal(value, stringWriter);
        return stringWriter.toString();
    } catch (JAXBException e) {
        throw new IllegalArgumentException("Unable to convert " + value.getClass().getName() + " to xml using jaxb", e);
    }
}
 
Example #13
Source File: VarInsnNodeSerializer.java    From maple-ir with GNU General Public License v3.0 5 votes vote down vote up
@Override
public JsonElement serialize(VarInsnNode src, Type typeOfSrc, JsonSerializationContext context) {
	JsonObject object = new JsonObject();
    object.add("opcode", context.serialize(src.getOpcode()));
    object.add("var", context.serialize(src.var));
    return object;
}
 
Example #14
Source File: AccessApi.java    From nifi-api-client-java with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves the access configuration for this NiFi (asynchronously)
 * 
 * @param callback The callback to be executed when the API call finishes
 * @return The request call
 * @throws ApiException If fail to process the API call, e.g. serializing the request body object
 */
public com.squareup.okhttp.Call getLoginConfigAsync(final ApiCallback<AccessConfigurationEntity> callback) throws ApiException {

    ProgressResponseBody.ProgressListener progressListener = null;
    ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

    if (callback != null) {
        progressListener = new ProgressResponseBody.ProgressListener() {
            @Override
            public void update(long bytesRead, long contentLength, boolean done) {
                callback.onDownloadProgress(bytesRead, contentLength, done);
            }
        };

        progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
            @Override
            public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                callback.onUploadProgress(bytesWritten, contentLength, done);
            }
        };
    }

    com.squareup.okhttp.Call call = getLoginConfigCall(progressListener, progressRequestListener);
    Type localVarReturnType = new TypeToken<AccessConfigurationEntity>(){}.getType();
    apiClient.executeAsync(call, localVarReturnType, callback);
    return call;
}
 
Example #15
Source File: VodClient.java    From tencentcloud-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 *该接口用于修改关键词的应用场景、标签,关键词本身不可修改,如需修改,可删除重建。
 * @param req ModifyWordSampleRequest
 * @return ModifyWordSampleResponse
 * @throws TencentCloudSDKException
 */
public ModifyWordSampleResponse ModifyWordSample(ModifyWordSampleRequest req) throws TencentCloudSDKException{
    JsonResponseModel<ModifyWordSampleResponse> rsp = null;
    try {
            Type type = new TypeToken<JsonResponseModel<ModifyWordSampleResponse>>() {
            }.getType();
            rsp  = gson.fromJson(this.internalRequest(req, "ModifyWordSample"), type);
    } catch (JsonSyntaxException e) {
        throw new TencentCloudSDKException(e.getMessage());
    }
    return rsp.response;
}
 
Example #16
Source File: FlowApi.java    From nifi-api-client-java with Apache License 2.0 5 votes vote down vote up
/**
 * Schedule or unschedule comopnents in the specified Process Group. (asynchronously)
 * 
 * @param id The process group id. (required)
 * @param body The request to schedule or unschedule. If the comopnents in the request are not specified, all authorized components will be considered. (required)
 * @param callback The callback to be executed when the API call finishes
 * @return The request call
 * @throws ApiException If fail to process the API call, e.g. serializing the request body object
 */
public com.squareup.okhttp.Call scheduleComponentsAsync(String id, ScheduleComponentsEntity body, final ApiCallback<ScheduleComponentsEntity> callback) throws ApiException {

    ProgressResponseBody.ProgressListener progressListener = null;
    ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

    if (callback != null) {
        progressListener = new ProgressResponseBody.ProgressListener() {
            @Override
            public void update(long bytesRead, long contentLength, boolean done) {
                callback.onDownloadProgress(bytesRead, contentLength, done);
            }
        };

        progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
            @Override
            public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                callback.onUploadProgress(bytesWritten, contentLength, done);
            }
        };
    }

    com.squareup.okhttp.Call call = scheduleComponentsCall(id, body, progressListener, progressRequestListener);
    Type localVarReturnType = new TypeToken<ScheduleComponentsEntity>(){}.getType();
    apiClient.executeAsync(call, localVarReturnType, callback);
    return call;
}
 
Example #17
Source File: OpenFeignFieldLevelEncryptionEncoderTest.java    From client-encryption-java with MIT License 5 votes vote down vote up
@Test
public void testEncode_ShouldEncryptRequestPayloadAndAddEncryptionHttpHeaders_WhenRequestedInConfig() throws Exception {

    // GIVEN
    FieldLevelEncryptionConfig config = getTestFieldLevelEncryptionConfigBuilder()
            .withEncryptionPath("$.foo", "$.encryptedFoo")
            .withIvHeaderName("x-iv")
            .withEncryptedKeyHeaderName("x-encrypted-key")
            .withOaepPaddingDigestAlgorithmHeaderName("x-oaep-padding-digest-algorithm")
            .withEncryptionCertificateFingerprintHeaderName("x-encryption-certificate-fingerprint")
            .withEncryptionKeyFingerprintHeaderName("x-encryption-key-fingerprint")
            .build();
    Type type = mock(Type.class);
    Encoder delegate = mock(Encoder.class);
    Object object = mock(Object.class);
    RequestTemplate request = mock(RequestTemplate.class);
    when(request.body()).thenReturn("{\"foo\":\"bar\"}".getBytes());

    // WHEN
    OpenFeignFieldLevelEncryptionEncoder instanceUnderTest = new OpenFeignFieldLevelEncryptionEncoder(config, delegate);
    instanceUnderTest.encode(object, type, request);

    // THEN
    verify(delegate).encode(object, type, request);
    verify(request).body();
    ArgumentCaptor<String> encryptedPayloadCaptor = ArgumentCaptor.forClass(String.class);
    verify(request).body(encryptedPayloadCaptor.capture());
    verify(request).header(eq("Content-Length"), anyString());
    String encryptedPayload = encryptedPayloadCaptor.getValue();
    assertFalse(encryptedPayload.contains("foo"));
    assertTrue(encryptedPayload.contains("encryptedFoo"));
    verify(request).header(eq("x-iv"), anyString());
    verify(request).header(eq("x-encrypted-key"), anyString());
    verify(request).header("x-oaep-padding-digest-algorithm", "SHA256");
    verify(request).header("x-encryption-certificate-fingerprint", "80810fc13a8319fcf0e2ec322c82a4c304b782cc3ce671176343cfe8160c2279");
    verify(request).header("x-encryption-key-fingerprint", "761b003c1eade3a5490e5000d37887baa5e6ec0e226c07706e599451fc032a79");
}
 
Example #18
Source File: DayuClient.java    From tencentcloud-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 *删除七层转发规则
 * @param req DeleteL7RulesRequest
 * @return DeleteL7RulesResponse
 * @throws TencentCloudSDKException
 */
public DeleteL7RulesResponse DeleteL7Rules(DeleteL7RulesRequest req) throws TencentCloudSDKException{
    JsonResponseModel<DeleteL7RulesResponse> rsp = null;
    try {
            Type type = new TypeToken<JsonResponseModel<DeleteL7RulesResponse>>() {
            }.getType();
            rsp  = gson.fromJson(this.internalRequest(req, "DeleteL7Rules"), type);
    } catch (JsonSyntaxException e) {
        throw new TencentCloudSDKException(e.getMessage());
    }
    return rsp.response;
}
 
Example #19
Source File: ClassRepository.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Type getSuperclass() {
    Type superclass = this.superclass;
    if (superclass == null) { // lazily initialize superclass
        Reifier r = getReifier(); // obtain visitor
        // Extract superclass subtree from AST and reify
        getTree().getSuperclass().accept(r);
        // extract result from visitor and cache it
        superclass = r.getResult();
        this.superclass = superclass;
    }
    return superclass; // return cached result
}
 
Example #20
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
public boolean isHolder(Class<?> cls, Type type) {
    for (AbstractServiceConfiguration c : serviceConfigurations) {
        Boolean b = c.isHolder(cls, type);
        if (b != null) {
            return b.booleanValue();
        }
    }
    return false;
}
 
Example #21
Source File: MongodbClient.java    From tencentcloud-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 *本接口(ModifyDBInstanceSpec)用于调整MongoDB云数据库实例配置。接口支持的售卖规格,可从查询云数据库的售卖规格(DescribeSpecInfo)获取。
 * @param req ModifyDBInstanceSpecRequest
 * @return ModifyDBInstanceSpecResponse
 * @throws TencentCloudSDKException
 */
public ModifyDBInstanceSpecResponse ModifyDBInstanceSpec(ModifyDBInstanceSpecRequest req) throws TencentCloudSDKException{
    JsonResponseModel<ModifyDBInstanceSpecResponse> rsp = null;
    try {
            Type type = new TypeToken<JsonResponseModel<ModifyDBInstanceSpecResponse>>() {
            }.getType();
            rsp  = gson.fromJson(this.internalRequest(req, "ModifyDBInstanceSpec"), type);
    } catch (JsonSyntaxException e) {
        throw new TencentCloudSDKException(e.getMessage());
    }
    return rsp.response;
}
 
Example #22
Source File: IaiClient.java    From tencentcloud-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 *删除该人员库及包含的所有的人员。同时,人员对应的所有人脸信息将被删除。若某人员同时存在多个人员库中,该人员不会被删除,但属于该人员库中的自定义描述字段信息会被删除,属于其他人员库的自定义描述字段信息不受影响。

 * @param req DeleteGroupRequest
 * @return DeleteGroupResponse
 * @throws TencentCloudSDKException
 */
public DeleteGroupResponse DeleteGroup(DeleteGroupRequest req) throws TencentCloudSDKException{
    JsonResponseModel<DeleteGroupResponse> rsp = null;
    try {
            Type type = new TypeToken<JsonResponseModel<DeleteGroupResponse>>() {
            }.getType();
            rsp  = gson.fromJson(this.internalRequest(req, "DeleteGroup"), type);
    } catch (JsonSyntaxException e) {
        throw new TencentCloudSDKException(e.getMessage());
    }
    return rsp.response;
}
 
Example #23
Source File: MediaTypeExtension.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public T readFrom(final Class<T> type, final Type genericType, final Annotation[] annotations,
        final MediaType mediaType, final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream)
        throws IOException, WebApplicationException {
    final MessageBodyReader<T> reader = readers.get(mediaTypeWithoutParams(mediaType));
    if (reader != null) {
        return reader.readFrom(type, genericType, annotations, mediaType, httpHeaders, entityStream);
    } else {
        throw new InternalServerErrorException("unsupported media type");
    }
}
 
Example #24
Source File: ClusterApi.java    From huaweicloud-cs-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * 查询指定用户配额信息 (asynchronously)
 * 
 * @param projectId project id, 用于不同project取token. (required)
 * @param userId 用户ID (required)
 * @param callback The callback to be executed when the API call finishes
 * @return The request call
 * @throws ApiException If fail to process the API call, e.g. serializing the request body object
 */
public com.squareup.okhttp.Call getUserQuotaAsync(String projectId, String userId, final ApiCallback<QueryUserQuotaResponse> callback) throws ApiException {

    ProgressResponseBody.ProgressListener progressListener = null;
    ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

    if (callback != null) {
        progressListener = new ProgressResponseBody.ProgressListener() {
            @Override
            public void update(long bytesRead, long contentLength, boolean done) {
                callback.onDownloadProgress(bytesRead, contentLength, done);
            }
        };

        progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
            @Override
            public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                callback.onUploadProgress(bytesWritten, contentLength, done);
            }
        };
    }

    com.squareup.okhttp.Call call = getUserQuotaValidateBeforeCall(projectId, userId, progressListener, progressRequestListener);
    Type localVarReturnType = new TypeToken<QueryUserQuotaResponse>(){}.getType();
    apiClient.executeAsync(call, localVarReturnType, callback);
    return call;
}
 
Example #25
Source File: HelperTest.java    From type-parser with MIT License 5 votes vote down vote up
@Test
public void canDecideTargetTypeIsEqualToListOfStringWhenTargetTypeIsListOfString() throws Exception {
    // given
    Type type = new GenericType<List<String>>() {}.getType();
    Helper helper = new Helper(new TargetType(type)) {};

    // when

    assertThat(helper.isTargetTypeEqualTo(new GenericType<List<String>>() {})).isTrue();
}
 
Example #26
Source File: TwitterAdsAccountApiImpl.java    From twitter4j-ads with MIT License 5 votes vote down vote up
@Override
public BaseAdsListResponseIterable<PromotableUser> getPromotableUsers(String accountId, boolean withDeleted) throws TwitterException {
    TwitterAdUtil.ensureNotNull(accountId, "accountId");
    final List<HttpParameter> params = new ArrayList<>();
    params.add(new HttpParameter(PARAM_WITH_DELETED, withDeleted));

    final String baseUrl = twitterAdsClient.getBaseAdsAPIUrl() + PREFIX_ACCOUNTS_URI + accountId + PATH_PROMOTABLE_USERS;
    final Type type = new TypeToken<BaseAdsListResponse<PromotableUser>>() {
    }.getType();

    return twitterAdsClient.executeHttpListRequest(baseUrl, params, type);
}
 
Example #27
Source File: VodClient.java    From tencentcloud-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
   ** 对媒体禁播后,除了点播控制台预览,其他场景访问视频各种资源的 URL(原始文件、转码输出文件、截图等)均会返回 403。
禁播/解禁操作全网生效时间约 5~10 分钟。
   * @param req ForbidMediaDistributionRequest
   * @return ForbidMediaDistributionResponse
   * @throws TencentCloudSDKException
   */
  public ForbidMediaDistributionResponse ForbidMediaDistribution(ForbidMediaDistributionRequest req) throws TencentCloudSDKException{
      JsonResponseModel<ForbidMediaDistributionResponse> rsp = null;
      try {
              Type type = new TypeToken<JsonResponseModel<ForbidMediaDistributionResponse>>() {
              }.getType();
              rsp  = gson.fromJson(this.internalRequest(req, "ForbidMediaDistribution"), type);
      } catch (JsonSyntaxException e) {
          throw new TencentCloudSDKException(e.getMessage());
      }
      return rsp.response;
  }
 
Example #28
Source File: RestTemplate.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
		ParameterizedTypeReference<T> responseType, Map<String, ?> uriVariables) throws RestClientException {

	Type type = responseType.getType();
	RequestCallback requestCallback = httpEntityCallback(requestEntity, type);
	ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(type);
	return execute(url, method, requestCallback, responseExtractor, uriVariables);
}
 
Example #29
Source File: PartnersClient.java    From tencentcloud-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 *代理商可查询自己及名下代客所有业务明细
 * @param req DescribeAgentBillsRequest
 * @return DescribeAgentBillsResponse
 * @throws TencentCloudSDKException
 */
public DescribeAgentBillsResponse DescribeAgentBills(DescribeAgentBillsRequest req) throws TencentCloudSDKException{
    JsonResponseModel<DescribeAgentBillsResponse> rsp = null;
    try {
            Type type = new TypeToken<JsonResponseModel<DescribeAgentBillsResponse>>() {
            }.getType();
            rsp  = gson.fromJson(this.internalRequest(req, "DescribeAgentBills"), type);
    } catch (JsonSyntaxException e) {
        throw new TencentCloudSDKException(e.getMessage());
    }
    return rsp.response;
}
 
Example #30
Source File: ObjectMapperCallable.java    From spring-cloud-formula with Apache License 2.0 5 votes vote down vote up
@Override
public Object call() throws Exception {
    Type type = method.getGenericReturnType();

    JavaType t = objectMapper.constructType(type);
    return objectMapper.readValue(result, t);
}