Example usage for java.util.function Supplier get

List of usage examples for java.util.function Supplier get

Introduction

In this page you can find the example usage for java.util.function Supplier get.

Prototype

T get();

Source Link

Document

Gets a result.

Usage

From source file:org.springframework.boot.test.context.assertj.AssertProviderApplicationContextInvocationHandler.java

private Object getContextOrStartupFailure(Supplier<?> contextSupplier) {
    try {/* w  w w .j av a  2  s  . co  m*/
        return contextSupplier.get();
    } catch (RuntimeException ex) {
        return ex;
    }
}

From source file:org.springframework.cloud.function.web.flux.FunctionController.java

private Flux<?> supplier(Supplier<Flux<?>> supplier) {
    Flux<?> result = supplier.get();
    if (logger.isDebugEnabled()) {
        logger.debug("Handled GET with supplier");
    }//from   ww  w  . j  av  a 2s  .  com
    return debug ? result.log() : result;
}

From source file:org.springframework.cloud.function.web.source.SupplierExporter.java

private Flux<ClientResponse> forward(Supplier<Flux<Object>> supplier, String name) {
    return supplier.get().flatMap(value -> {
        String destination = this.destinationResolver.destination(supplier, name, value);
        if (this.debug) {
            logger.info("Posting to: " + destination);
        }//from   www .  j a v  a2s  .c  o m
        return post(uri(destination), destination, value);
    });
}

From source file:org.springframework.cloud.gcp.data.spanner.core.SpannerTemplate.java

private void applySaveMutations(Supplier<List<Mutation>> mutationsSupplier, Iterable entities,
        Set<String> includeProperties) {
    maybeEmitEvent(new BeforeSaveEvent(entities, includeProperties));
    List<Mutation> mutations = mutationsSupplier.get();
    applyMutations(mutations);/* ww  w  . j  a  va 2  s.c o m*/
    maybeEmitEvent(new AfterSaveEvent(mutations, entities, includeProperties));
}

From source file:org.springframework.cloud.gcp.data.spanner.core.SpannerTemplate.java

private void resolveChildEntity(Object entity, Set<String> includeProperties) {
    SpannerPersistentEntity spannerPersistentEntity = this.mappingContext
            .getPersistentEntity(entity.getClass());
    PersistentPropertyAccessor accessor = spannerPersistentEntity.getPropertyAccessor(entity);
    spannerPersistentEntity.doWithInterleavedProperties(
            (PropertyHandler<SpannerPersistentProperty>) (spannerPersistentProperty) -> {
                if (includeProperties != null
                        && !includeProperties.contains(spannerPersistentEntity.getName())) {
                    return;
                }//from   w ww.j  a  v  a 2  s  .  c o  m
                Class childType = spannerPersistentProperty.getColumnInnerType();
                SpannerPersistentEntity childPersistentEntity = this.mappingContext
                        .getPersistentEntity(childType);

                Supplier<List> getChildrenEntitiesFunc = () -> queryAndResolveChildren(childType,
                        SpannerStatementQueryExecutor.getChildrenRowsQuery(
                                this.spannerSchemaUtils.getKey(entity), childPersistentEntity,
                                this.spannerEntityProcessor.getWriteConverter()),
                        null);

                accessor.setProperty(spannerPersistentProperty,
                        spannerPersistentProperty.isLazyInterleaved()
                                ? ConversionUtils.wrapSimpleLazyProxy(getChildrenEntitiesFunc, List.class)
                                : getChildrenEntitiesFunc.get());
            });
}

From source file:org.springframework.cloud.gcp.data.spanner.core.SpannerTemplate.java

private <A> A doWithOrWithoutTransactionContext(Function<TransactionContext, A> funcWithTransactionContext,
        Supplier<A> funcWithoutTransactionContext) {
    TransactionContext txContext = getTransactionContext();
    return (txContext != null) ? funcWithTransactionContext.apply(txContext)
            : funcWithoutTransactionContext.get();
}

From source file:org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.java

/**
 * Logs the {@link String message} supplied by the given {@link Supplier} at debug level.
 *
 * @param message {@link Supplier} containing the {@link String message} and arguments to log.
 * @see org.apache.commons.logging.Log#isDebugEnabled()
 * @see org.apache.commons.logging.Log#debug(Object)
 * @see #getLog()/*  w ww . j a  v a  2s .  c  o m*/
 */
protected void logDebug(Supplier<String> message) {
    Optional.ofNullable(getLog()).filter(Log::isDebugEnabled).ifPresent(log -> log.debug(message.get()));
}

From source file:org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.java

/**
 * Logs the {@link String message} supplied by the given {@link Supplier} at info level.
 *
 * @param message {@link Supplier} containing the {@link String message} and arguments to log.
 * @see org.apache.commons.logging.Log#isInfoEnabled()
 * @see org.apache.commons.logging.Log#info(Object)
 * @see #getLog()/*  www . j a  v  a2  s  . c  om*/
 */
protected void logInfo(Supplier<String> message) {
    Optional.ofNullable(getLog()).filter(Log::isInfoEnabled).ifPresent(log -> log.info(message.get()));
}

From source file:org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.java

/**
 * Logs the {@link String message} supplied by the given {@link Supplier} at warning level.
 *
 * @param message {@link Supplier} containing the {@link String message} and arguments to log.
 * @see org.apache.commons.logging.Log#isWarnEnabled()
 * @see org.apache.commons.logging.Log#warn(Object)
 * @see #getLog()//from w ww  . jav a 2 s  .  com
 */
protected void logWarning(Supplier<String> message) {
    Optional.ofNullable(getLog()).filter(Log::isWarnEnabled).ifPresent(log -> log.info(message.get()));
}

From source file:org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.java

/**
 * Logs the {@link String message} supplied by the given {@link Supplier} at error level.
 *
 * @param message {@link Supplier} containing the {@link String message} and arguments to log.
 * @see org.apache.commons.logging.Log#isErrorEnabled()
 * @see org.apache.commons.logging.Log#error(Object)
 * @see #getLog()//from w  ww. j  ava  2  s.c om
 */
protected void logError(Supplier<String> message) {
    Optional.ofNullable(getLog()).filter(Log::isWarnEnabled).ifPresent(log -> log.info(message.get()));
}