diff options
Diffstat (limited to 'jaxrs_client_utils/src/main/java/com/yahoo/vespa/jaxrs/client/LocalPassThroughJaxRsStrategy.java')
-rw-r--r-- | jaxrs_client_utils/src/main/java/com/yahoo/vespa/jaxrs/client/LocalPassThroughJaxRsStrategy.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/jaxrs_client_utils/src/main/java/com/yahoo/vespa/jaxrs/client/LocalPassThroughJaxRsStrategy.java b/jaxrs_client_utils/src/main/java/com/yahoo/vespa/jaxrs/client/LocalPassThroughJaxRsStrategy.java new file mode 100644 index 00000000000..280842ae4db --- /dev/null +++ b/jaxrs_client_utils/src/main/java/com/yahoo/vespa/jaxrs/client/LocalPassThroughJaxRsStrategy.java @@ -0,0 +1,23 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.jaxrs.client; + +import java.io.IOException; +import java.util.function.Function; + +/** + * A {@link JaxRsStrategy} that does not use the network, only forwards calls to a local object. + * + * @author <a href="mailto:bakksjo@yahoo-inc.com">Oyvind Bakksjo</a> + */ +public class LocalPassThroughJaxRsStrategy<T> implements JaxRsStrategy<T> { + private final T api; + + public LocalPassThroughJaxRsStrategy(final T api) { + this.api = api; + } + + @Override + public <R> R apply(final Function<T, R> function) throws IOException { + return function.apply(api); + } +} |