List of usage examples for java.util.function Supplier get
T get();
From source file:io.appium.java_client.ios.IOSAlertTest.java
@Test public void acceptAlertTest() { Supplier<Boolean> acceptAlert = () -> { driver.findElement(MobileBy.AccessibilityId(iOSAutomationText)).click(); waiting.until(alertIsPresent()); driver.switchTo().alert().accept(); return true; };/*from w w w . ja va2s. co m*/ assertTrue(acceptAlert.get()); }
From source file:io.appium.java_client.ios.IOSAlertTest.java
@Test public void dismissAlertTest() { Supplier<Boolean> dismissAlert = () -> { driver.findElement(MobileBy.AccessibilityId(iOSAutomationText)).click(); waiting.until(alertIsPresent()); driver.switchTo().alert().dismiss(); return true; };// w w w . j av a2s .co m assertTrue(dismissAlert.get()); }
From source file:fi.helsinki.opintoni.service.AvatarImageService.java
private String getAvatarImageUrl(Supplier<String> defaultAvatarUrlSupplier, Long userId) { UserSettings userSettings = userSettingsRepository.findByUserId(userId); return userSettings.hasAvatarImage() ? uriBuilder.getUserAvatarUrlByOodiPersonId(userSettings.user.oodiPersonId) : defaultAvatarUrlSupplier.get(); }
From source file:com.savoirtech.logging.slf4j.json.logger.AbstractJsonLogger.java
@Override public JsonLogger map(String key, Supplier<Map> map) { try {//from ww w . ja v a 2s . com jsonObject.add(key, gson.toJsonTree(map.get())); } catch (Exception e) { jsonObject.add(key, gson.toJsonTree(formatException(e))); } return this; }
From source file:com.savoirtech.logging.slf4j.json.logger.AbstractJsonLogger.java
@Override public JsonLogger json(String key, Supplier<JsonElement> jsonElement) { try {//from w w w. ja v a2 s.co m jsonObject.add(key, jsonElement.get()); } catch (Exception e) { jsonObject.add(key, gson.toJsonTree(formatException(e))); } return this; }
From source file:com.savoirtech.logging.slf4j.json.logger.AbstractJsonLogger.java
@Override public JsonLogger list(String key, Supplier<List> list) { try {//from w w w.j av a 2 s . c o m jsonObject.add(key, gson.toJsonTree(list.get())); } catch (Exception e) { jsonObject.add(key, gson.toJsonTree(formatException(e))); } return this; }
From source file:com.savoirtech.logging.slf4j.json.logger.AbstractJsonLogger.java
@Override public JsonLogger message(Supplier<String> message) { try {//from ww w . j av a 2s . c o m jsonObject.add("message", gson.toJsonTree(message.get())); } catch (Exception e) { jsonObject.add("message", gson.toJsonTree(formatException(e))); } return this; }
From source file:org.n52.youngs.harvest.PoxCswSource.java
@Override protected Supplier<? extends Long> getAndStoreRecordCount() { Supplier<Long> s = new CswRecordCountSupplier(); if (!recordCount.isPresent()) { recordCount = Optional.of(s.get()); }/* w w w . ja v a2 s .c o m*/ return s; }
From source file:spring.travel.site.services.HttpClient.java
private <T> CompletableFuture<T> execute(Supplier<Request> requestSupplier, Consumer<Request> requestConsumer, ResponseMapper<T> responseMapper) { CompletableFuture<T> future = new CompletableFuture<>(); try {//w ww. j av a 2 s . co m Request request = requestSupplier.get(); requestConsumer.accept(request); asyncHttpClient.executeRequest(request, new AsyncCompletionHandler<T>() { @Override public T onCompleted(Response response) throws Exception { T t = responseMapper.map(response); future.complete(t); return t; } @Override public void onThrowable(Throwable t) { future.completeExceptionally(t); } }); } catch (Exception e) { future.completeExceptionally(e); } return future; }
From source file:org.shredzone.cilla.plugin.tumblr.TumblrPublicationServiceImpl.java
/** * Converts a {@link Page} to a {@link TextPost}. * * @param page// ww w .j ava 2 s.c om * {@link Page} to convert from * @param post * {@link TextPost} to convert into */ private void pageToPost(Page page, TextPost post) { try { Supplier<LinkBuilder> linkBuilderSupplier = () -> linkService.linkTo().page(page).external(); String url = linkBuilderSupplier.get().toString(); StringBuilder sb = new StringBuilder(); sb.append(textFormatter.format(page.getTeaser(), linkBuilderSupplier)); sb.append("<p><a href=").append(URLEncoder.encode(url, "utf8")).append('>').append(url) .append("</a></p>"); post.setDate(page.getPublication()); post.setTitle(page.getTitle()); post.setBody(sb.toString()); post.setState(tumblrState); List<String> tags = new ArrayList<>(); tags.addAll(page.getCategories().stream().map(Category::getName).collect(toList())); tags.addAll(page.getTags().stream().map(Tag::getName).collect(toList())); if (tumblrAutotags != null && !tumblrAutotags.isEmpty()) { tags.addAll(AUTOTAG_SEPARATOR.splitAsStream(tumblrAutotags).map(String::trim).collect(toList())); } post.setTags(tags); } catch (UnsupportedEncodingException ex) { // Should never happen, as utf8 is standard throw new InternalError(ex); } }