我正在尝试使用代理连接到服务器,但我正在创建的对象迫使我创建 Function <? super string, ? extends String>
,但我不知道如何使用它。这是怎么回事Function
工作?他向我询问密码
我的代码:
Function<? super String, ? extends String> pwd = username -> passProxy;
HttpClient httpClientAux = HttpClient.create().tcpConfiguration(tcpClient -> tcpClient.proxy(
proxy -> proxy.type(ProxyProvider.Proxy.HTTP).address(new InetSocketAddress(urlProxy, 8080)).username(usuarioProxy).password(pwd)));
ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClientAux);
this.myWebClient = webClientBuilder.clientConnector(connector).build();
最佳答案
Function
表示一个接受一个参数并产生结果的函数。
函数基本上有两种类型参数,第一个是 INPUT 参数类型,第二个是 OUTPUT 返回类型
Function<? super String, ? extends Integer> checkvalue = (str) -> str.length();
// takes String as parameter and produce length as Integer
就您而言Function <? super string? extends String>
将用户名字符串作为参数并生成密码字符串
有关 Function
的更多信息https://www.baeldung.com/java-8-functional-interfaces
关于spring - 如何使用函数<? super 字符串,?扩展字符串>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60169255/