本文整理汇总了Java中com.google.common.reflect.TypeToken类的典型用法代码示例。如果您正苦于以下问题:Java TypeToken类的具体用法?Java TypeToken怎么用?Java TypeToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeToken类属于com.google.common.reflect包,在下文中一共展示了TypeToken类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rawTypes
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
@Test public void rawTypes() throws NoSuchMethodException {
assertThat(getRawType(String.class)).isSameAs(String.class);
Type listOfString = new TypeToken<List<String>>() {}.getType();
assertThat(getRawType(listOfString)).isSameAs(List.class);
Type stringArray = new TypeToken<String[]>() {}.getType();
assertThat(getRawType(stringArray)).isSameAs(String[].class);
Type wild = ((ParameterizedType) new TypeToken<List<? extends CharSequence>>() {
}.getType()).getActualTypeArguments()[0];
assertThat(getRawType(wild)).isSameAs(CharSequence.class);
Type wildParam = ((ParameterizedType) new TypeToken<List<? extends List<String>>>() {
}.getType()).getActualTypeArguments()[0];
assertThat(getRawType(wildParam)).isSameAs(List.class);
Type typeVar = A.class.getDeclaredMethod("method").getGenericReturnType();
assertThat(getRawType(typeVar)).isSameAs(Object.class);
}
示例2: deleteWithServiceResponseAsync
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
/**
* Deletes an existing CDN endpoint with the specified endpoint name under the specified subscription, resource group and profile.
*
* @param resourceGroupName Name of the Resource group within the Azure subscription.
* @param profileName Name of the CDN profile which is unique within the resource group.
* @param endpointName Name of the endpoint under the profile which is unique globally.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<Void>> deleteWithServiceResponseAsync(String resourceGroupName, String profileName, String endpointName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (profileName == null) {
throw new IllegalArgumentException("Parameter profileName is required and cannot be null.");
}
if (endpointName == null) {
throw new IllegalArgumentException("Parameter endpointName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
Observable<Response<ResponseBody>> observable = service.delete(resourceGroupName, profileName, endpointName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<Void>() { }.getType());
}
示例3: testOptionalMapping
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
@Test
public void testOptionalMapping() {
Map<String, Object> map = new HashMap<>();
map.put("simple", 1);
map.put("optionalString", "testString");
Map<String, String> beanMap = new HashMap<>();
beanMap.put("name", "testName");
map.put("optionalBean", beanMap);
FixtureTemplate fixture = FixtureTemplateWrapper.wrap(map, null, null);
OptionalTest result = (OptionalTest) converter.convert(fixture, TypeToken.of(OptionalTest.class));
assertEquals(1, result.simple.get());
assertEquals("testString", result.optionalString.get());
assertEquals("testName", result.optionalBean.get().name.get());
}
示例4: applyArtifactsWithServiceResponseAsync
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
/**
* Apply artifacts to virtual machine. This operation can take a while to complete.
*
* @param resourceGroupName The name of the resource group.
* @param labName The name of the lab.
* @param name The name of the virtual machine.
* @param artifacts The list of artifacts to apply.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<Void>> applyArtifactsWithServiceResponseAsync(String resourceGroupName, String labName, String name, List<ArtifactInstallPropertiesInner> artifacts) {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (labName == null) {
throw new IllegalArgumentException("Parameter labName is required and cannot be null.");
}
if (name == null) {
throw new IllegalArgumentException("Parameter name is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
Validator.validate(artifacts);
ApplyArtifactsRequest applyArtifactsRequest = new ApplyArtifactsRequest();
applyArtifactsRequest.withArtifacts(artifacts);
Observable<Response<ResponseBody>> observable = service.applyArtifacts(this.client.subscriptionId(), resourceGroupName, labName, name, this.client.apiVersion(), this.client.acceptLanguage(), applyArtifactsRequest, this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<Void>() { }.getType());
}
示例5: startWithServiceResponseAsync
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
/**
* Starts a streaming job. Once a job is started it will start processing input events and produce output.
*
* @param resourceGroupName The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
* @param jobName The name of the streaming job.
* @param startJobParameters Parameters applicable to a start streaming job operation.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<Void>> startWithServiceResponseAsync(String resourceGroupName, String jobName, StartStreamingJobParametersInner startJobParameters) {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (jobName == null) {
throw new IllegalArgumentException("Parameter jobName is required and cannot be null.");
}
Validator.validate(startJobParameters);
final String apiVersion = "2016-03-01";
Observable<Response<ResponseBody>> observable = service.start(this.client.subscriptionId(), resourceGroupName, jobName, startJobParameters, apiVersion, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<Void>() { }.getType());
}
示例6: deleteWithServiceResponseAsync
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
/**
* Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone.
*
* @param resourceGroupName The name of the resource group.
* @param zoneName The name of the DNS zone (without a terminating dot).
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<ZoneDeleteResultInner>> deleteWithServiceResponseAsync(String resourceGroupName, String zoneName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (zoneName == null) {
throw new IllegalArgumentException("Parameter zoneName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
final String ifMatch = null;
Observable<Response<ResponseBody>> observable = service.delete(resourceGroupName, zoneName, this.client.subscriptionId(), ifMatch, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<ZoneDeleteResultInner>() { }.getType());
}
示例7: createOrUpdateWithServiceResponseAsync
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
/**
* Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent.
*
* @param resourceGroupName Name of the resource group within the azure subscription.
* @param namespaceName The Namespace name
* @param parameters Parameters for creating a namespace resource.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<NamespaceResourceInner>> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String namespaceName, NamespaceCreateOrUpdateParametersInner parameters) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (namespaceName == null) {
throw new IllegalArgumentException("Parameter namespaceName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (parameters == null) {
throw new IllegalArgumentException("Parameter parameters is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
Validator.validate(parameters);
Observable<Response<ResponseBody>> observable = service.createOrUpdate(resourceGroupName, namespaceName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken<NamespaceResourceInner>() { }.getType());
}
示例8: startWithServiceResponseAsync
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
/**
* Starts an existing CDN endpoint that is on a stopped state.
*
* @param resourceGroupName Name of the Resource group within the Azure subscription.
* @param profileName Name of the CDN profile which is unique within the resource group.
* @param endpointName Name of the endpoint under the profile which is unique globally.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<EndpointInner>> startWithServiceResponseAsync(String resourceGroupName, String profileName, String endpointName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (profileName == null) {
throw new IllegalArgumentException("Parameter profileName is required and cannot be null.");
}
if (endpointName == null) {
throw new IllegalArgumentException("Parameter endpointName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
Observable<Response<ResponseBody>> observable = service.start(resourceGroupName, profileName, endpointName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<EndpointInner>() { }.getType());
}
示例9: resetWithServiceResponseAsync
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
/**
* Resets the primary of the virtual network gateway in the specified resource group.
*
* @param resourceGroupName The name of the resource group.
* @param virtualNetworkGatewayName The name of the virtual network gateway.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<VirtualNetworkGatewayInner>> resetWithServiceResponseAsync(String resourceGroupName, String virtualNetworkGatewayName) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (virtualNetworkGatewayName == null) {
throw new IllegalArgumentException("Parameter virtualNetworkGatewayName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
final String apiVersion = "2017-08-01";
final String gatewayVip = null;
Observable<Response<ResponseBody>> observable = service.reset(resourceGroupName, virtualNetworkGatewayName, this.client.subscriptionId(), gatewayVip, apiVersion, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<VirtualNetworkGatewayInner>() { }.getType());
}
示例10: getFlowLogStatusWithServiceResponseAsync
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
/**
* Queries status of flow log on a specified resource.
*
* @param resourceGroupName The name of the network watcher resource group.
* @param networkWatcherName The name of the network watcher resource.
* @param targetResourceId The target resource where getting the flow logging status.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<FlowLogInformationInner>> getFlowLogStatusWithServiceResponseAsync(String resourceGroupName, String networkWatcherName, String targetResourceId) {
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (networkWatcherName == null) {
throw new IllegalArgumentException("Parameter networkWatcherName is required and cannot be null.");
}
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (targetResourceId == null) {
throw new IllegalArgumentException("Parameter targetResourceId is required and cannot be null.");
}
final String apiVersion = "2017-08-01";
FlowLogStatusParameters parameters = new FlowLogStatusParameters();
parameters.withTargetResourceId(targetResourceId);
Observable<Response<ResponseBody>> observable = service.getFlowLogStatus(resourceGroupName, networkWatcherName, this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), parameters, this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<FlowLogInformationInner>() { }.getType());
}
示例11: createOrUpdateWithServiceResponseAsync
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
/**
* Create or replace an existing environment. This operation can take a while to complete.
*
* @param resourceGroupName The name of the resource group.
* @param labName The name of the lab.
* @param userName The name of the user profile.
* @param name The name of the environment.
* @param dtlEnvironment An environment, which is essentially an ARM template deployment.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponse<DtlEnvironmentInner>> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String labName, String userName, String name, DtlEnvironmentInner dtlEnvironment) {
if (this.client.subscriptionId() == null) {
throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null.");
}
if (resourceGroupName == null) {
throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
}
if (labName == null) {
throw new IllegalArgumentException("Parameter labName is required and cannot be null.");
}
if (userName == null) {
throw new IllegalArgumentException("Parameter userName is required and cannot be null.");
}
if (name == null) {
throw new IllegalArgumentException("Parameter name is required and cannot be null.");
}
if (dtlEnvironment == null) {
throw new IllegalArgumentException("Parameter dtlEnvironment is required and cannot be null.");
}
if (this.client.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
Validator.validate(dtlEnvironment);
Observable<Response<ResponseBody>> observable = service.createOrUpdate(this.client.subscriptionId(), resourceGroupName, labName, userName, name, dtlEnvironment, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken<DtlEnvironmentInner>() { }.getType());
}
示例12: beginCreateDelegate
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
private ServiceResponseWithHeaders<BatchAccountInner, BatchAccountCreateHeadersInner> beginCreateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<BatchAccountInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<BatchAccountInner>() { }.getType())
.register(202, new TypeToken<Void>() { }.getType())
.registerError(CloudException.class)
.buildWithHeaders(response, BatchAccountCreateHeadersInner.class);
}
示例13: beginPauseDataWarehouseDelegate
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
private ServiceResponse<Void> beginPauseDataWarehouseDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<Void, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<Void>() { }.getType())
.register(202, new TypeToken<Void>() { }.getType())
.registerError(CloudException.class)
.build(response);
}
示例14: testThatIntArraysCanBeSerialised
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
@Test
public void testThatIntArraysCanBeSerialised() throws ObjectMappingException {
int[] array = { 4, -2 };
TestConfigurationLoader tcl = getArrayTestLoader();
ConfigurationNode cn = tcl.createEmptyNode().setValue(new TypeToken<int[]>() {}, array);
List<Integer> ls = cn.getList(TypeToken.of(Integer.class));
Assert.assertTrue(ls.contains(4));
Assert.assertTrue(ls.contains(-2));
}
示例15: getVnetConnectionGatewayDelegate
import com.google.common.reflect.TypeToken; //导入依赖的package包/类
private ServiceResponse<VnetGatewayInner> getVnetConnectionGatewayDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
return this.client.restClient().responseBuilderFactory().<VnetGatewayInner, CloudException>newInstance(this.client.serializerAdapter())
.register(200, new TypeToken<VnetGatewayInner>() { }.getType())
.register(404, new TypeToken<Void>() { }.getType())
.registerError(CloudException.class)
.build(response);
}