.map(fn -> fn.apply(conf, binder, registryRef)) .collect(Collectors.toList()); securityRoutes.forEach(it -> clientList.add(it.client));
LocalTimeCodec.instance); hierarchy(cluster.getClass(), type -> bind.apply(type, cstr.keyspace(), cluster)); hierarchy(session.getClass(), type -> bind.apply(type, cstr.keyspace(), session)); bind.apply(MappingManager.class, cstr.keyspace(), manager); bind.apply(Datastore.class, cstr.keyspace(), new Datastore(manager));
/** * * Apply this function and run the given action in case of exception. * * @param type Exception filter. * @param action Action to run when exception occurs. * @param <X> Exception type. * @return A new function. */ default <X extends Throwable> Function3<V1, V2, V3, R> onFailure(Class<X> type, java.util.function.Consumer<X> action) { return (v1, v2, v3) -> fnOnFailure(() -> tryApply(v1, v2, v3), type, action); }
/** * A function that remember/cache previous executions. * * @return A memo function. */ default Function3<V1, V2, V3, R> memoized() { if (this instanceof Memoized) { return this; } Map<Object, R> cache = new HashMap<>(); return (Function3<V1, V2, V3, R> & Memoized) (v1, v2, v3) -> memo(cache, Arrays.asList(v1, v2, v3), () -> tryApply(v1, v2, v3)); } }
public <V> Value<V> apply(Throwing.Function3<R1, R2, R3, V> fn) { return Try.apply(() -> { try (R1 r1 = this.r1.get(); R2 r2 = this.r2.get(); R3 r3 = this.r3.get()) { return fn.apply(r1, r2, r3); } }); }
/** * Apply this function and wrap any resulting exception. * * @param wrapper Exception wrapper. * @return A new function. */ default Function3<V1, V2, V3, R> wrap( java.util.function.Function<Throwable, Exception> wrapper) { return (v1, v2, v3) -> fnWrap(() -> tryApply(v1, v2, v3), wrapper); }
/** * Apply this function or recover from it in case of exception. * * @param fn Exception recover. * @return A new function. */ default Function3<V1, V2, V3, R> recover(java.util.function.Function<Throwable, R> fn) { return recover(Throwable.class, fn); }
/** * Apply this function and unwrap any resulting exception. Useful to get clean/shorter stacktrace. * * @param type Exception to unwrap. * @param <X> Exception type. * @return A new function. */ default <X extends Throwable> Function3<V1, V2, V3, R> unwrap(Class<? extends X> type) { return (v1, v2, v3) -> fnUnwrap(() -> tryApply(v1, v2, v3), type); }
/** * Apply this function and run the given action in case of exception. * * @param action Action to run when exception occurs. * @return A new function. */ default Function3<V1, V2, V3, R> onFailure(java.util.function.Consumer<Throwable> action) { return onFailure(Throwable.class, action); }
/** * Apply this function and returns the given default value in case of exception. * * @param defaultValue Exceptional default value. * @return A new function. */ default Function3<V1, V2, V3, R> orElse(Supplier<R> defaultValue) { return (v1, v2, v3) -> fn(() -> tryApply(v1, v2, v3), defaultValue); }
/** * Apply this function to the given argument and produces a result. * * @param v1 Input argument. * @param v2 Input argument. * @param v3 Input argument. * @return Result. */ default R apply(V1 v1, V2 v2, V3 v3) { return fn(() -> tryApply(v1, v2, v3)); }
@Override public void handle(final Request req, final Response rsp, final Chain chain) throws Throwable { Object input = supplier.apply(req, rsp, chain); Object output = Try .apply(() -> mapper.map(input)) .recover(ClassCastException.class, input) .get(); rsp.send(output); chain.next(req, rsp); }
/** * Apply this function or recover from a specific exception in case of exception. * * @param type Exception filter. * @param fn Exception recover. * @param <X> Exception type. * @return A new function. */ default <X extends Throwable> Function3<V1, V2, V3, R> recover(Class<? extends X> type, java.util.function.Function<X, R> fn) { return (v1, v2, v3) -> fnRecover(() -> tryApply(v1, v2, v3), type, fn); }
/** * Apply this function and returns the given default value in case of exception. * * @param defaultValue Exceptional default value. * @return A new function. */ default Function3<V1, V2, V3, R> orElse(R defaultValue) { return orElse(() -> defaultValue); }
conf.getString("couchbase.cluster.username"), conf.getString("couchbase.cluster.password")); bind.apply(ClusterManager.class, dbname, clusterManager); log.debug(" bucket opened: {}", name); bind.apply(Bucket.class, name, bucket); AsyncBucket async = bucket.async(); bind.apply(AsyncBucket.class, name, async); bind.apply(Repository.class, name, repo); bind.apply(AsyncRepository.class, name, asyncrepo); bind.apply(AsyncDatastore.class, name, asyncds); bind.apply(Datastore.class, name, new DatastoreImpl(asyncds)); bind.apply(Bucket.class, "session", cluster.openBucket(session, password.apply(session)));
LocalTimeCodec.instance); hierarchy(cluster.getClass(), type -> bind.apply(type, cstr.keyspace(), cluster)); hierarchy(session.getClass(), type -> bind.apply(type, cstr.keyspace(), session)); bind.apply(MappingManager.class, cstr.keyspace(), manager); bind.apply(Datastore.class, cstr.keyspace(), new Datastore(manager));
@Override public void handle(final Request req, final Response rsp, final Chain chain) throws Throwable { Object input = supplier.apply(req, rsp, chain); Object output = Try .apply(() -> mapper.map(input)) .recover(ClassCastException.class, input) .get(); rsp.send(output); chain.next(req, rsp); }