本文整理了Java中io.vavr.API.unchecked()
方法的一些代码示例,展示了API.unchecked()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。API.unchecked()
方法的具体详情如下:
包路径:io.vavr.API
类名称:API
方法名:unchecked
[英]Alias for CheckedFunction0#unchecked
[中]CheckedFunction0的别名#未选中
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
private static Optional<String> reveal(ConfigurationContext context, String captured) {
return context.getSecretSources().stream()
.map(source -> unchecked(() -> source.reveal(captured)).apply())
.flatMap(o -> o.map(Stream::of).orElseGet(Stream::empty))
.findFirst();
}
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
private CNode getActualValue(CNode config, ConfigurationContext context) {
return unchecked(() -> config.asMapping().entrySet().stream().findFirst()).apply()
.map(entry -> {
Mapping mapping = new Mapping();
mapping.put(entry.getKey(), revealSourceOrGetValue(entry, context));
return (CNode) mapping;
}).orElse(config);
}
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
private String revealSourceOrGetValue(Map.Entry<String, CNode> entry, ConfigurationContext context) {
String value = unchecked(() -> entry.getValue().asScalar().getValue()).apply();
return SecretSourceResolver.resolve(context, value);
}
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
private GeneratedItems generateFromScript(String script, JenkinsJobManagement management) {
return unchecked(() ->
Try(() -> new JenkinsDslScriptLoader(management).runScript(script))
.getOrElseThrow(t -> new ConfiguratorException(this, "Failed to execute script with hash " + script.hashCode(), t))).apply();
}
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
private String getScriptFromSource(CNode source, ConfigurationContext context, Configurator<ScriptSource> configurator) {
return unchecked(() ->
Try(() -> configurator.configure(source, context))
.getOrElseThrow(t -> new ConfiguratorException(this, "Failed to retrieve job-dsl script", t))
.getScript()).apply();
}
}
代码示例来源:origin: Tristan971/Lyrebird
/**
* Uploads the given media files to Twitter
*
* @param twitter The twitter instance to use for uploading
* @param attachments The media files to upload
*
* @return The uploaded media files Twitter-side ids
*/
private static List<Long> uploadMedias(final Twitter twitter, final List<File> attachments) {
LOG.debug("Uploading media attachments {}", attachments);
return attachments.stream()
.map(unchecked((CheckedFunction1<File, UploadedMedia>) twitter::uploadMedia))
.map(UploadedMedia::getMediaId)
.collect(Collectors.toList());
}
代码示例来源:origin: Tristan971/Lyrebird
@Cacheable("availableVersions")
public List<LyrebirdVersion> getAllVersions() {
final PathMatchingResourcePatternResolver versionsResourcesResolver = new PathMatchingResourcePatternResolver();
try {
final Resource[] versionResources = versionsResourcesResolver.getResources(VERSIONS_PATTERN);
return Arrays.stream(versionResources)
.map(unchecked(Resource::getInputStream))
.map(unchecked(is -> objectMapper.readValue(is, LyrebirdVersion.class)))
.sorted(Comparator.comparing(LyrebirdVersion::getBuildVersion).reversed())
.collect(Collectors.toList());
} catch (final IOException e) {
throw new IllegalStateException("Can not load releases!", e);
}
}
代码示例来源:origin: io.jenkins/configuration-as-code
private static Optional<String> reveal(ConfigurationContext context, String captured) {
return context.getSecretSources().stream()
.map(source -> unchecked(() -> source.reveal(captured)).apply())
.flatMap(o -> o.map(Stream::of).orElseGet(Stream::empty))
.findFirst();
}
代码示例来源:origin: Tristan971/Lyrebird
/**
* Creates a user authentication request on Twitter side
*
* @return a tuple containing the URL for OTP, and the RequestToken to which this OTP will be bound to
*/
public Tuple2<URL, RequestToken> newSession() {
LOG.info("Requesting new Session!");
final RequestToken requestToken = unchecked((CheckedFunction0<RequestToken>) this.twitter::getOAuthRequestToken)
.apply();
LOG.info("Got request token : {}", requestToken);
return Tuple.of(
unchecked((CheckedFunction0<URL>) (() -> new URL(requestToken.getAuthorizationURL()))).apply(),
requestToken
);
}
代码示例来源:origin: Tristan971/Lyrebird
/**
* Deserializes the credited works matching the {@link #CREDITS_RESOURCES_PATH} location pattern.
*
* @param objectMapper The object mapper used for deserialization
* @param pmpr The {@link PathMatchingResourcePatternResolver} used for location pattern matching
*
* @return The list of deserialized credits files
*/
private static List<CreditedWork> loadCreditsFiles(
final ObjectMapper objectMapper,
final PathMatchingResourcePatternResolver pmpr
) {
return Try.of(() -> pmpr.getResources(CREDITS_RESOURCES_PATH))
.toStream()
.flatMap(Stream::of)
.map(unchecked(Resource::getInputStream))
.map(unchecked(cis -> objectMapper.readValue(cis, CreditedWork.class)))
.toJavaList();
}
内容来源于网络,如有侵权,请联系作者删除!