com.google.common.reflect.TypeToken Java Examples

The following examples show how to use com.google.common.reflect.TypeToken. 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: GalleryImagesInner.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Delete a gallery image.
 *
 * @param resourceGroupName The name of the resource group.
 * @param galleryName The name of the Shared Image Gallery in which the Image Definition is to be deleted.
 * @param galleryImageName The name of the gallery Image Definition to be deleted.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the observable for the request
 */
public Observable<ServiceResponse<Void>> deleteWithServiceResponseAsync(String resourceGroupName, String galleryName, String galleryImageName) {
    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 (galleryName == null) {
        throw new IllegalArgumentException("Parameter galleryName is required and cannot be null.");
    }
    if (galleryImageName == null) {
        throw new IllegalArgumentException("Parameter galleryImageName is required and cannot be null.");
    }
    final String apiVersion = "2019-12-01";
    Observable<Response<ResponseBody>> observable = service.delete(this.client.subscriptionId(), resourceGroupName, galleryName, galleryImageName, apiVersion, this.client.acceptLanguage(), this.client.userAgent());
    return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<Void>() { }.getType());
}
 
Example #2
Source File: TableResourcesInner.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Create or update an Azure Cosmos DB Table.
 *
 * @param resourceGroupName Name of an Azure resource group.
 * @param accountName Cosmos DB database account name.
 * @param tableName Cosmos DB table name.
 * @param createUpdateTableParameters The parameters to provide for the current Table.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the observable for the request
 */
public Observable<ServiceResponse<TableGetResultsInner>> createUpdateTableWithServiceResponseAsync(String resourceGroupName, String accountName, String tableName, TableCreateUpdateParameters createUpdateTableParameters) {
    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 (accountName == null) {
        throw new IllegalArgumentException("Parameter accountName is required and cannot be null.");
    }
    if (tableName == null) {
        throw new IllegalArgumentException("Parameter tableName is required and cannot be null.");
    }
    if (createUpdateTableParameters == null) {
        throw new IllegalArgumentException("Parameter createUpdateTableParameters is required and cannot be null.");
    }
    Validator.validate(createUpdateTableParameters);
    final String apiVersion = "2019-08-01";
    Observable<Response<ResponseBody>> observable = service.createUpdateTable(this.client.subscriptionId(), resourceGroupName, accountName, tableName, apiVersion, createUpdateTableParameters, this.client.acceptLanguage(), this.client.userAgent());
    return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken<TableGetResultsInner>() { }.getType());
}
 
Example #3
Source File: CassandraResourcesInner.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Create or update an Azure Cosmos DB Cassandra keyspace.
 *
 * @param resourceGroupName Name of an Azure resource group.
 * @param accountName Cosmos DB database account name.
 * @param keyspaceName Cosmos DB keyspace name.
 * @param createUpdateCassandraKeyspaceParameters The parameters to provide for the current Cassandra keyspace.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the observable for the request
 */
public Observable<ServiceResponse<CassandraKeyspaceGetResultsInner>> createUpdateCassandraKeyspaceWithServiceResponseAsync(String resourceGroupName, String accountName, String keyspaceName, CassandraKeyspaceCreateUpdateParameters createUpdateCassandraKeyspaceParameters) {
    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 (accountName == null) {
        throw new IllegalArgumentException("Parameter accountName is required and cannot be null.");
    }
    if (keyspaceName == null) {
        throw new IllegalArgumentException("Parameter keyspaceName is required and cannot be null.");
    }
    if (createUpdateCassandraKeyspaceParameters == null) {
        throw new IllegalArgumentException("Parameter createUpdateCassandraKeyspaceParameters is required and cannot be null.");
    }
    Validator.validate(createUpdateCassandraKeyspaceParameters);
    final String apiVersion = "2019-08-01";
    Observable<Response<ResponseBody>> observable = service.createUpdateCassandraKeyspace(this.client.subscriptionId(), resourceGroupName, accountName, keyspaceName, apiVersion, createUpdateCassandraKeyspaceParameters, this.client.acceptLanguage(), this.client.userAgent());
    return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken<CassandraKeyspaceGetResultsInner>() { }.getType());
}
 
Example #4
Source File: RunsInner.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Patch the run properties.
 *
 * @param resourceGroupName The name of the resource group to which the container registry belongs.
 * @param registryName The name of the container registry.
 * @param runId The run ID.
 * @param isArchiveEnabled The value that indicates whether archiving is enabled or not.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the observable for the request
 */
public Observable<ServiceResponse<RunInner>> updateWithServiceResponseAsync(String resourceGroupName, String registryName, String runId, Boolean isArchiveEnabled) {
    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 (registryName == null) {
        throw new IllegalArgumentException("Parameter registryName is required and cannot be null.");
    }
    if (runId == null) {
        throw new IllegalArgumentException("Parameter runId is required and cannot be null.");
    }
    final String apiVersion = "2018-09-01";
    RunUpdateParameters runUpdateParameters = new RunUpdateParameters();
    runUpdateParameters.withIsArchiveEnabled(isArchiveEnabled);
    Observable<Response<ResponseBody>> observable = service.update(this.client.subscriptionId(), resourceGroupName, registryName, runId, apiVersion, this.client.acceptLanguage(), runUpdateParameters, this.client.userAgent());
    return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken<RunInner>() { }.getType());
}
 
Example #5
Source File: GDPlayerData.java    From GriefDefender with MIT License 6 votes vote down vote up
public int getPvpCombatTimeRemaining() {
    final Player player = this.getSubject().getOnlinePlayer();
    if (this.lastPvpTimestamp == null || player == null) {
        return 0;
    }

    final Instant now = Instant.now();
    int combatTimeout = 0;
    if (GDOptions.isOptionEnabled(Options.PVP_COMBAT_TIMEOUT)) {
        combatTimeout = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), player, Options.PVP_COMBAT_TIMEOUT);
    }
    if (combatTimeout <= 0) {
        return 0;
    }

    if (this.lastPvpTimestamp.plusSeconds(combatTimeout).isBefore(now)) {
        this.lastPvpTimestamp = null;
        return 0;
    }

    final int duration = (int) Duration.between(this.lastPvpTimestamp, now).getSeconds();
    return combatTimeout - duration;
}
 
Example #6
Source File: ConnectServer.java    From AndroidWallet with GNU General Public License v3.0 6 votes vote down vote up
/**
 * get_full_accounts
 *
 * @throws NetworkStatusException
 */
public Object get_full_accounts(String names_or_id, boolean subscribe) throws NetworkStatusException, IndexOutOfBoundsException {
    Call callObject = new Call();
    callObject.id = mnCallId.getAndIncrement();
    callObject.method = "call";
    callObject.params = new ArrayList<>();
    callObject.params.add(mDatabaseId);
    callObject.params.add(CALL_GET_FULL_ACCOUNTS);

    List<Object> listParams = new ArrayList<>();
    List<String> listNameOrIds = new ArrayList<>();
    listNameOrIds.add(names_or_id);
    listParams.add(listNameOrIds);
    listParams.add(subscribe);
    callObject.params.add(listParams);

    ReplyObjectProcess<Reply<List<List<Object>>>> replyObject = new ReplyObjectProcess<>(new com.google.gson.reflect.TypeToken<Reply<List<List<Object>>>>() {
    }.getType());
    Reply<List<List<Object>>> reply = sendForReply(callObject, replyObject);

    return reply.result.size() > 0 ? global_config_object.getInstance().getGsonBuilder().create().toJson(reply.result.get(0).get(1)) : reply.result;
}
 
Example #7
Source File: AdditionalPropertiesSerializer.java    From botbuilder-java with MIT License 6 votes vote down vote up
/**
 * Gets a module wrapping this serializer as an adapter for the Jackson
 * ObjectMapper.
 *
 * @param mapper the object mapper for default serializations
 * @return a simple module to be plugged onto Jackson ObjectMapper.
 */
public static SimpleModule getModule(final ObjectMapper mapper) {
    SimpleModule module = new SimpleModule();
    module.setSerializerModifier(new BeanSerializerModifier() {
        @Override
        public JsonSerializer<?> modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer<?> serializer) {
            for (Class<?> c : TypeToken.of(beanDesc.getBeanClass()).getTypes().classes().rawTypes()) {
                if (c.isAssignableFrom(Object.class)) {
                    continue;
                }
                Field[] fields = c.getDeclaredFields();
                for (Field field : fields) {
                    if ("additionalProperties".equalsIgnoreCase(field.getName())) {
                        JsonProperty property = field.getAnnotation(JsonProperty.class);
                        if (property != null && property.value().isEmpty()) {
                            return new AdditionalPropertiesSerializer(beanDesc.getBeanClass(), serializer, mapper);
                        }
                    }
                }
            }
            return serializer;
        }
    });
    return module;
}
 
Example #8
Source File: ServerBlobAuditingPoliciesInner.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Creates or updates a server's blob auditing policy.
 *
 * @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 serverName The name of the server.
 * @param parameters Properties of blob auditing policy
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the observable for the request
 */
public Observable<ServiceResponse<ServerBlobAuditingPolicyInner>> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String serverName, ServerBlobAuditingPolicyInner parameters) {
    if (resourceGroupName == null) {
        throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.");
    }
    if (serverName == null) {
        throw new IllegalArgumentException("Parameter serverName 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.");
    }
    Validator.validate(parameters);
    final String blobAuditingPolicyName = "default";
    final String apiVersion = "2017-03-01-preview";
    Observable<Response<ResponseBody>> observable = service.createOrUpdate(resourceGroupName, serverName, blobAuditingPolicyName, this.client.subscriptionId(), parameters, apiVersion, this.client.acceptLanguage(), this.client.userAgent());
    return client.getAzureClient().getPutOrPatchResultAsync(observable, new TypeToken<ServerBlobAuditingPolicyInner>() { }.getType());
}
 
Example #9
Source File: LogAnalyticsInner.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Export logs that show Api requests made by this subscription in the given time window to show throttling activities.
 *
 * @param location The location upon which virtual-machine-sizes is queried.
 * @param parameters Parameters supplied to the LogAnalytics getRequestRateByInterval Api.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the observable for the request
 */
public Observable<ServiceResponse<LogAnalyticsOperationResultInner>> exportRequestRateByIntervalWithServiceResponseAsync(String location, RequestRateByIntervalInput parameters) {
    if (location == null) {
        throw new IllegalArgumentException("Parameter location 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.");
    }
    Validator.validate(parameters);
    final String apiVersion = "2019-12-01";
    Observable<Response<ResponseBody>> observable = service.exportRequestRateByInterval(location, this.client.subscriptionId(), parameters, apiVersion, this.client.acceptLanguage(), this.client.userAgent());
    return client.getAzureClient().getPostOrDeleteResultAsync(observable, new LongRunningOperationOptions().withFinalStateVia(LongRunningFinalState.AZURE_ASYNC_OPERATION), new TypeToken<LogAnalyticsOperationResultInner>() { }.getType());
}
 
Example #10
Source File: RegistriesInner.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Updates the policies for the specified container registry.
 *
 * @param resourceGroupName The name of the resource group to which the container registry belongs.
 * @param registryName The name of the container registry.
 * @param registryPoliciesUpdateParameters The parameters for updating policies of a container registry.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the observable for the request
 */
public Observable<ServiceResponse<RegistryPoliciesInner>> updatePoliciesWithServiceResponseAsync(String resourceGroupName, String registryName, RegistryPoliciesInner registryPoliciesUpdateParameters) {
    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 (registryName == null) {
        throw new IllegalArgumentException("Parameter registryName is required and cannot be null.");
    }
    if (registryPoliciesUpdateParameters == null) {
        throw new IllegalArgumentException("Parameter registryPoliciesUpdateParameters is required and cannot be null.");
    }
    Validator.validate(registryPoliciesUpdateParameters);
    final String apiVersion = "2017-10-01";
    Observable<Response<ResponseBody>> observable = service.updatePolicies(this.client.subscriptionId(), resourceGroupName, registryName, apiVersion, registryPoliciesUpdateParameters, this.client.acceptLanguage(), this.client.userAgent());
    return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken<RegistryPoliciesInner>() { }.getType());
}
 
Example #11
Source File: DatabasesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<ImportExportResponseInner> beginCreateImportOperationDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<ImportExportResponseInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(201, new TypeToken<ImportExportResponseInner>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #12
Source File: EndpointsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<DeleteOperationResultInner> deleteDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<DeleteOperationResultInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<DeleteOperationResultInner>() { }.getType())
            .register(204, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #13
Source File: ExpressRouteCircuitAuthorizationsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<ExpressRouteCircuitAuthorizationInner> beginCreateOrUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<ExpressRouteCircuitAuthorizationInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<ExpressRouteCircuitAuthorizationInner>() { }.getType())
            .register(201, new TypeToken<ExpressRouteCircuitAuthorizationInner>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #14
Source File: SimpleParserRegistry.java    From helper with MIT License 5 votes vote down vote up
@Nonnull
@Override
public <T> Optional<ArgumentParser<T>> find(@Nonnull TypeToken<T> type) {
    Objects.requireNonNull(type, "type");
    List<ArgumentParser<?>> parsers = this.parsers.get(type);
    if (parsers == null || parsers.isEmpty()) {
        return Optional.empty();
    }

    //noinspection unchecked
    return Optional.of((ArgumentParser<T>) parsers.get(0));
}
 
Example #15
Source File: PrivateEndpointConnectionsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<PrivateEndpointConnectionInner> beginCreateOrUpdateDelegate(Response<ResponseBody> response) throws ErrorResponseException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<PrivateEndpointConnectionInner, ErrorResponseException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<PrivateEndpointConnectionInner>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(ErrorResponseException.class)
            .build(response);
}
 
Example #16
Source File: ManagedRestorableDroppedDatabaseBackupShortTermRetentionPoliciesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<ManagedBackupShortTermRetentionPolicyInner> beginUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<ManagedBackupShortTermRetentionPolicyInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<ManagedBackupShortTermRetentionPolicyInner>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #17
Source File: TwitterAdsMediaApiImpl.java    From twitter4j-ads with MIT License 5 votes vote down vote up
@Override
public BaseAdsResponse<TwitterAccountMedia> getAccountMediaById(String accountId, String accountMediaId) throws TwitterException {
    TwitterAdUtil.ensureNotNull(accountId, ACCOUNT_ID);
    TwitterAdUtil.ensureNotNull(accountMediaId, "Account Media Id");

    final String baseUrl = twitterAdsClient.getBaseAdsAPIUrl() + PREFIX_ACCOUNTS_URI + accountId + PATH_ACCOUNT_MEDIA + "/" + accountMediaId;
    final Type type = new TypeToken<BaseAdsResponse<TwitterAccountMedia>>() {
    }.getType();
    return twitterAdsClient.executeHttpRequest(baseUrl, null, type, HttpVerb.GET);
}
 
Example #18
Source File: GDPlayerData.java    From GriefDefender with MIT License 5 votes vote down vote up
public double getInternalEconomyBlockCost() {
    final Double value = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Double.class), this.getSubject(), Options.ECONOMY_BLOCK_COST);
    if (value == null) {
        return Options.ECONOMY_BLOCK_COST.getDefaultValue();
    }
    return value;
}
 
Example #19
Source File: VaultsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<VaultInner> updateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<VaultInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<VaultInner>() { }.getType())
            .register(201, new TypeToken<VaultInner>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #20
Source File: GerritApi.java    From copybara with Apache License 2.0 5 votes vote down vote up
public Map<String, ActionInfo> getActions(String changeId, String revision)
    throws RepoException, ValidationException {
  try (ProfilerTask ignore = profiler.start("gerrit_get_actions")) {
    return transport.get("/changes/" +  changeId + "/revisions/" +  revision + "/actions",
        new TypeToken<Map<String, ActionInfo>>() {}.getType());
  }
}
 
Example #21
Source File: PolicySetDefinitionsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<PolicySetDefinitionInner> createOrUpdateAtManagementGroupDelegate(Response<ResponseBody> response) throws ErrorResponseException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<PolicySetDefinitionInner, ErrorResponseException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<PolicySetDefinitionInner>() { }.getType())
            .register(201, new TypeToken<PolicySetDefinitionInner>() { }.getType())
            .registerError(ErrorResponseException.class)
            .build(response);
}
 
Example #22
Source File: BloodEffect.java    From UltimateCore with MIT License 5 votes vote down vote up
@Override
public BloodEffect deserialize(TypeToken<?> type, ConfigurationNode node) throws ObjectMappingException {
    Vector3d coffset = node.getNode("center-offset").getValue(TypeToken.of(Vector3d.class));
    Vector3d poffset = node.getNode("particle-offset").getValue(TypeToken.of(Vector3d.class));
    BlockState state = Serializers.BLOCKSTATE.deserialize(TypeToken.of(BlockState.class), node.getNode("blockstate"));
    int count = node.getNode("count").getInt();
    boolean enabled = node.getNode("enabled").getBoolean();
    return new BloodEffect(enabled, state, coffset, poffset, count);
}
 
Example #23
Source File: HttpOperations.java    From riptide with MIT License 5 votes vote down vote up
@Nonnull
@Override
public <T> ResponseEntity<T> exchange(final String url, final HttpMethod method,
        @Nullable final HttpEntity<?> entity, final ParameterizedTypeReference<T> responseType,
        final Map<String, ?> uriVariables) {

    @SuppressWarnings("unchecked") final TypeToken<T> type = (TypeToken) TypeToken.of(responseType.getType());
    return exchange(url, method, entity, type, extract(url, uriVariables));
}
 
Example #24
Source File: ApiConfigValidatorTest.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testArrayOfArraysParameter() throws Exception {
  config.getApiClassConfig().getMethods()
      .get(methodToEndpointMethod(TestEndpoint.class.getMethod("getResultNoParams")))
      .addParameter("param", null, false, null, TypeToken.of(Integer[][].class));

  try {
    validator.validate(config);
    fail("Expected NestedCollectionException.");
  } catch (NestedCollectionException expected) {
  }
}
 
Example #25
Source File: PlayerFilter.java    From Web-API with MIT License 5 votes vote down vote up
public PlayerFilter(WebHook hook, ConfigurationNode config) {
    super(hook, config);

    try {
        players = config.getList(TypeToken.of(String.class));
    } catch (ObjectMappingException e) {
        e.printStackTrace();
    }
}
 
Example #26
Source File: NetworkWatchersInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<VerificationIPFlowResultInner> beginVerifyIPFlowDelegate(Response<ResponseBody> response) throws ErrorResponseException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<VerificationIPFlowResultInner, ErrorResponseException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<VerificationIPFlowResultInner>() { }.getType())
            .register(202, new TypeToken<VerificationIPFlowResultInner>() { }.getType())
            .registerError(ErrorResponseException.class)
            .build(response);
}
 
Example #27
Source File: MaterialDeserializerTests.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void test_air()
{
    Map<String, Material> map = gson.fromJson("{ \"mat\": \"air\" }", new TypeToken<Map<String, Material>>() {}.getType());

    Material mat = map.get("mat");
    assertNotNull(mat);
    assertSame(Material.AIR, mat);
}
 
Example #28
Source File: DriftClientBinder.java    From drift with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static <T> TypeLiteral<DriftClient<T>> driftClientTypeLiteral(Class<T> clientInterface)
{
    Type javaType = new TypeToken<DriftClient<T>>() {}
            .where(new TypeParameter<T>() {}, TypeToken.of(clientInterface))
            .getType();
    return (TypeLiteral<DriftClient<T>>) TypeLiteral.get(javaType);
}
 
Example #29
Source File: VirtualNetworkGatewayConnectionsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<VirtualNetworkGatewayConnectionInner> beginCreateOrUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<VirtualNetworkGatewayConnectionInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<VirtualNetworkGatewayConnectionInner>() { }.getType())
            .register(201, new TypeToken<VirtualNetworkGatewayConnectionInner>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #30
Source File: DefaultHttpJsonResponseTest.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void shouldDeserializeResponseToGivenType() throws Exception {
  final String responseBody =
      DtoFactory.getInstance().toJson(new JsonArrayImpl<>(singletonList("element")));
  final DefaultHttpJsonResponse response = new DefaultHttpJsonResponse(responseBody, 200);

  assertEquals(
      response.as(Set.class, new TypeToken<Set<String>>() {}.getType()), singleton("element"));
}