List of usage examples for java.util Collections singletonList
public static <T> List<T> singletonList(T o)
From source file:io.klerch.alexa.state.handler.AlexaSessionStateHandler.java
/** * {@inheritDoc}/*from w w w . j ava2 s. co m*/ */ @Override public void writeModel(final AlexaStateModel model) throws AlexaStateException { Validate.notNull(model, "Model to write must not be null."); writeModels(Collections.singletonList(model)); }
From source file:com.orange.ngsi2.client.Ngsi2Client.java
private Ngsi2Client() { // set default headers for Content-Type and Accept to application/JSON httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_JSON); httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); }
From source file:net.dv8tion.discord.commands.AnimeNewsNetworkCommand.java
@Override public List<String> getUsageInstructions() { return Collections.singletonList(".ann *<search terms>*\n" + "__Example:__ .ann Steins;Gate\n" + " - This will return the AnimeNewsNetwork page for the anime Steins;Gate\n" + "__Example 2:__ .ann Boku no Hero Academia Manga\n" + " - This will return the manga page for Boku no Hero Academia (hopefully)"); }
From source file:org.optaplanner.benchmark.impl.statistic.scorecalculationspeed.ScoreCalculationSpeedProblemStatistic.java
/** * @return never null */ @Override public List<File> getGraphFileList() { return Collections.singletonList(graphFile); }
From source file:com.jivesoftware.os.routing.bird.deployable.TenantRoutingBirdProviderBuilder.java
public ConnectionDescriptorsProvider build(OAuthSigner signer) { HttpClientConfig httpClientConfig = HttpClientConfig.newBuilder().build(); final HttpClient httpClient = new HttpClientFactoryProvider() .createHttpClientFactory(Collections.singletonList(httpClientConfig), false) .createClient(signer, routesHost, routesPort); AtomicLong activeCount = new AtomicLong(); final ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); ConnectionDescriptorsProvider connectionsProvider = (connectionsRequest, expectedReleaseGroup) -> { activeCount.incrementAndGet();//from ww w . ja va2 s . c o m try { LOG.debug("Requesting connections:{}", connectionsRequest); String postEntity; try { postEntity = mapper.writeValueAsString(connectionsRequest); } catch (JsonProcessingException e) { LOG.error("Error serializing request parameters object to a string. Object " + "was " + connectionsRequest + " " + e.getMessage()); return null; } HttpResponse response; try { response = httpClient.postJson(routesPath, postEntity, null); } catch (HttpClientException e) { LOG.error( "Error posting query request to server. The entity posted was {} and the endpoint posted to was {}", new Object[] { postEntity, routesPath }, e); return null; } int statusCode = response.getStatusCode(); if (statusCode >= 200 && statusCode < 300) { byte[] responseBody = response.getResponseBody(); try { ConnectionDescriptorsResponse connectionDescriptorsResponse = mapper.readValue(responseBody, ConnectionDescriptorsResponse.class); if (!connectionsRequest.getRequestUuid() .equals(connectionDescriptorsResponse.getRequestUuid())) { LOG.warn("Request UUIDs are misaligned, request:{} response:{}", connectionsRequest, connectionDescriptorsResponse); } if (connectionDescriptorsResponse.getReturnCode() >= 0 && expectedReleaseGroup != null && !expectedReleaseGroup.equals(connectionDescriptorsResponse.getReleaseGroup())) { String responseEntity = new String(responseBody, StandardCharsets.UTF_8); LOG.warn( "Release group changed, active:{} request:{} requestEntity:{} responseEntity:{} response:{}", activeCount.get(), connectionsRequest, postEntity, responseEntity, connectionDescriptorsResponse); } LOG.debug("Request:{} ConnectionDescriptors:{}", connectionsRequest, connectionDescriptorsResponse); return connectionDescriptorsResponse; } catch (IOException x) { LOG.error("Failed to deserialize response:" + new String(responseBody) + " " + x.getMessage()); return null; } } return null; } finally { activeCount.decrementAndGet(); } }; return connectionsProvider; }
From source file:com.hp.autonomy.hod.client.api.developer.ApplicationServiceImpl.java
@Override public void create(final AuthenticationToken<EntityType.Developer, TokenType.HmacSha1> token, final String domain, final String name, final String description) throws HodErrorException { final Map<String, List<String>> body = new LinkedHashMap<>(); body.put("application_name", Collections.singletonList(name)); body.put("description", Collections.singletonList(description)); final Request<Void, String> request = new Request<>(Request.Verb.POST, pathForDomain(domain) + "/v1", null, body);/*from w ww. j a v a2 s . com*/ final String signature = hmac.generateToken(request, token); backend.create(signature, domain, name, description); }
From source file:com.axibase.tsd.driver.jdbc.content.ContentMetadata.java
public ContentMetadata(String scheme, String sql, String connectionId, int statementId) throws AtsdException, IOException { metadataList = StringUtils.isNoneEmpty(scheme) ? buildMetadataList(scheme) : Collections.<ColumnMetaData>emptyList(); sign = new Signature(metadataList, sql, Collections.<AvaticaParameter>emptyList(), null, CursorFactory.LIST, StatementType.SELECT);/* w ww . j a v a 2s . c om*/ list = Collections.unmodifiableList( Collections.singletonList(MetaResultSet.create(connectionId, statementId, false, sign, null))); }
From source file:com.orange.cepheus.broker.RemoteRegistrationsTest.java
@Before public void setup() { MockitoAnnotations.initMocks(this); httpHeaders.setContentType(MediaType.APPLICATION_JSON); httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); }
From source file:example.xmlbeam.XmlBeamHttpMessageConverter.java
@Override public List<MediaType> getSupportedMediaTypes() { return Collections.singletonList(MediaType.APPLICATION_XML); }
From source file:org.moserp.infrastructure.gateway.filter.ResponseLinksMapperTest.java
@Test public void testFixLink() throws Exception { ServiceRouteMapper mapper = new ModuleServiceMapper(); DiscoveryClient discoveryClient = mock(DiscoveryClient.class); ResponseLinksMapper responseLinksMapper = new ResponseLinksMapper(mapper, discoveryClient); when(discoveryClient.getServices()).thenReturn(Collections.singletonList("service-module")); responseLinksMapper.fillServices();// w w w . jav a2 s . co m assertEquals("http://localhost:8080/api/service/entity", responseLinksMapper.fixLink("http://service-module/entity")); }