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:onl.area51.httpd.action.Action.java

default Action wrapif(boolean wrap, Supplier<Action> before, Supplier<Action> after) {
    return wrap ? wrap(before.get(), after.get()) : this;
}

From source file:com.eclecticlogic.pedal.impl.TransactionImpl.java

@Override
public <R> R exec(Supplier<R> block) {
    return _exec(context -> block.get());
}

From source file:io.github.pellse.decorator.GeneratedDecorator.java

@Override
public <D extends I> Decorator<I, D> with(Supplier<D> delegateSupplier) {
    return new GeneratedDecorator<>(this, delegateSupplier.get(), commonDelegateType, generator, classLoader);
}

From source file:svnserver.context.Context.java

@NotNull
public <T extends S> T getOrCreate(@NotNull Class<T> type, @NotNull Supplier<T> supplier) {
    final T result = get(type);
    if (result == null) {
        final T newObj = supplier.get();
        final S oldObj = map.putIfAbsent(type, newObj);
        if (oldObj != null) {
            //noinspection unchecked
            return (T) oldObj;
        }//w  ww.j a  v  a  2  s .c o m
        return newObj;
    }
    return result;
}

From source file:io.bosh.client.internal.AbstractSpringOperations.java

protected final <T> Observable<T> createObservable(Supplier<T> exchange) {
    return Observable.create(subscriber -> {

        try {/*  www.  j  a  va 2  s.  c  om*/
            subscriber.onNext(exchange.get());
            subscriber.onCompleted();
        } catch (HttpStatusCodeException e) {
            subscriber.onError(new DirectorException(e.getMessage(), e));
        }
    });
}

From source file:com.github.dozermapper.core.builder.xml.BeanMappingXMLBuilder.java

/**
 * Loads the collection of streams into memory and parses the XML
 *
 * @param xmlMappingSuppliers collection of streams to xml file/content
 *//*from   www. j a  v a 2 s  .c  om*/
public void loadInputStreams(List<Supplier<InputStream>> xmlMappingSuppliers) {
    for (Supplier<InputStream> supplier : xmlMappingSuppliers) {
        try (InputStream stream = new BufferedInputStream(supplier.get())) {
            load(stream);
        } catch (IOException ex) {
            MappingUtils.throwMappingException(ex);
        }
    }
}

From source file:org.n52.youngs.harvest.KvpCswSource.java

@Override
protected Supplier<? extends Long> getAndStoreRecordCount() {
    Supplier<Long> s = new CswRecordCountSupplier();
    recordCount = Optional.of(s.get());
    return s;//from  w w w .j  a  v a 2s  .  c om
}

From source file:nu.yona.server.analysis.service.InactivityManagementService.java

private <T> T createInactivity(UUID userAnonymizedId, UUID goalId, Supplier<T> existingActivityFinder,
        BiFunction<UserAnonymized, Goal, T> creator, Consumer<T> storer) {
    T existingActivity = existingActivityFinder.get();
    if (existingActivity != null) {
        return existingActivity;
    }//from w w  w.  j a va2  s. c o m
    UserAnonymized userAnonymized = userAnonymizedService.getUserAnonymizedEntity(userAnonymizedId);
    Goal goal = goalService.getGoalEntityForUserAnonymizedId(userAnonymizedId, goalId);
    T inactivityEntity = creator.apply(userAnonymized, goal);

    storer.accept(inactivityEntity);

    return inactivityEntity;
}

From source file:com.github.lburgazzoli.camel.CaseToIncidentProcessor.java

@SuppressWarnings("unchecked")
private <T> boolean setIfDifferent(String fieldName, Supplier<T> oldValue, Supplier<T> newValue,
        Consumer<T> setter) {
    T o = oldValue != null ? oldValue.get() : null;
    T n = newValue != null ? newValue.get() : null;

    if (o instanceof String) {
        o = (T) StringUtils.trimToNull((String) o);
    }/*w  w w  .  ja v  a2s  .  c  o m*/
    if (n instanceof String) {
        n = (T) StringUtils.trimToNull((String) n);
    }

    if (!Objects.equals(o, n)) {
        LOGGER.debug("Update {} -> old: {}, new: {}", fieldName, o, n);
        setter.accept(n);
        return true;
    } else {
        return false;
    }
}

From source file:info.magnolia.services.httputils.HttpService.java

private String resolve(String type, Supplier<String> supp) {
    switch (type) {
    case ConnectionDefinition.TYPE_ENV:
        return System.getenv(supp.get());
    case ConnectionDefinition.TYPE_VALUE:
        return supp.get();
    case ConnectionDefinition.TYPE_PROP:
        return System.getProperty(supp.get());
    default:/*from  w  w w.jav  a2s.c  om*/
        throw new RuntimeException("Invalid value for property.");
    }
}