Add "wrapper" type methods to FunctionInspector
These can be used to more reliably discover whether the user has declared a function with flux types or "bare" POJOs. They then pave the way to supporting single valued types in a special way. Also consolidate and simplify the logic in FunctionInspector
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud-function.version>1.0.0.BUILD-SNAPSHOT</spring-cloud-function.version>
|
||||
<wrapper.version>1.0.1.RELEASE</wrapper.version>
|
||||
<wrapper.version>1.0.2.RELEASE</wrapper.version>
|
||||
<reactor.version>3.0.7.BUILD-SNAPSHOT</reactor.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.example;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class LowercaseConfiguration {
|
||||
|
||||
@Bean
|
||||
public Function<Flux<Foo>, Flux<Bar>> lowercase() {
|
||||
return flux -> flux.log().map(value -> new Bar(value.lowercase()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,11 +37,6 @@ public class SampleApplication {
|
||||
return () -> Flux.fromArray(new Bar[] { new Bar("foo"), new Bar("bar") }).log();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<Foo>, Flux<Bar>> lowercase() {
|
||||
return flux -> flux.log().map(value -> new Bar(value.lowercase()));
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(SampleApplication.class, args);
|
||||
}
|
||||
|
||||
@@ -52,4 +52,11 @@ public class SampleApplicationTests {
|
||||
String.class)).isEqualTo("[{\"value\":\"FOO\"}]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lowercase() {
|
||||
assertThat(new TestRestTemplate().postForObject(
|
||||
"http://localhost:" + port + "/lowercase", "[{\"value\":\"Foo\"}]",
|
||||
String.class)).isEqualTo("[{\"value\":\"foo\"}]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user