Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
1bd52bc4
Commit
1bd52bc4
authored
Jul 20, 2018
by
Dmytro Nosan
Committed by
Stephane Nicoll
Aug 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add PropertyMapper.from(value)
See gh-13837
parent
dd9209c7
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
62 additions
and
27 deletions
+62
-27
BasicBatchConfigurer.java
...mework/boot/autoconfigure/batch/BasicBatchConfigurer.java
+1
-1
ConcurrentKafkaListenerContainerFactoryConfigurer.java
...ka/ConcurrentKafkaListenerContainerFactoryConfigurer.java
+2
-3
TomcatWebServerFactoryCustomizer.java
...figure/web/embedded/TomcatWebServerFactoryCustomizer.java
+1
-1
UndertowWebServerFactoryCustomizer.java
...gure/web/embedded/UndertowWebServerFactoryCustomizer.java
+1
-1
MultipartProperties.java
...k/boot/autoconfigure/web/servlet/MultipartProperties.java
+4
-4
PropertyMapper.java
...ringframework/boot/context/properties/PropertyMapper.java
+12
-0
TaskExecutorBuilder.java
...va/org/springframework/boot/task/TaskExecutorBuilder.java
+7
-8
TaskSchedulerBuilder.java
...a/org/springframework/boot/task/TaskSchedulerBuilder.java
+2
-2
WebServiceTemplateBuilder.java
...rk/boot/webservices/client/WebServiceTemplateBuilder.java
+5
-6
PropertyMapperTests.java
...ramework/boot/context/properties/PropertyMapperTests.java
+27
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java
View file @
1bd52bc4
...
@@ -122,7 +122,7 @@ public class BasicBatchConfigurer implements BatchConfigurer {
...
@@ -122,7 +122,7 @@ public class BasicBatchConfigurer implements BatchConfigurer {
protected
JobRepository
createJobRepository
()
throws
Exception
{
protected
JobRepository
createJobRepository
()
throws
Exception
{
JobRepositoryFactoryBean
factory
=
new
JobRepositoryFactoryBean
();
JobRepositoryFactoryBean
factory
=
new
JobRepositoryFactoryBean
();
PropertyMapper
map
=
PropertyMapper
.
get
();
PropertyMapper
map
=
PropertyMapper
.
get
();
map
.
from
(
()
->
this
.
dataSource
).
to
(
factory:
:
setDataSource
);
map
.
from
(
this
.
dataSource
).
to
(
factory:
:
setDataSource
);
map
.
from
(
this
::
determineIsolationLevel
).
whenNonNull
()
map
.
from
(
this
::
determineIsolationLevel
).
whenNonNull
()
.
to
(
factory:
:
setIsolationLevelForCreate
);
.
to
(
factory:
:
setIsolationLevelForCreate
);
map
.
from
(
this
.
properties
::
getTablePrefix
).
whenHasText
()
map
.
from
(
this
.
properties
::
getTablePrefix
).
whenHasText
()
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java
View file @
1bd52bc4
...
@@ -85,9 +85,8 @@ public class ConcurrentKafkaListenerContainerFactoryConfigurer {
...
@@ -85,9 +85,8 @@ public class ConcurrentKafkaListenerContainerFactoryConfigurer {
PropertyMapper
map
=
PropertyMapper
.
get
();
PropertyMapper
map
=
PropertyMapper
.
get
();
Listener
properties
=
this
.
properties
.
getListener
();
Listener
properties
=
this
.
properties
.
getListener
();
map
.
from
(
properties:
:
getConcurrency
).
whenNonNull
().
to
(
factory:
:
setConcurrency
);
map
.
from
(
properties:
:
getConcurrency
).
whenNonNull
().
to
(
factory:
:
setConcurrency
);
map
.
from
(()
->
this
.
messageConverter
).
whenNonNull
()
map
.
from
(
this
.
messageConverter
).
whenNonNull
().
to
(
factory:
:
setMessageConverter
);
.
to
(
factory:
:
setMessageConverter
);
map
.
from
(
this
.
replyTemplate
).
whenNonNull
().
to
(
factory:
:
setReplyTemplate
);
map
.
from
(()
->
this
.
replyTemplate
).
whenNonNull
().
to
(
factory:
:
setReplyTemplate
);
map
.
from
(
properties:
:
getType
).
whenEqualTo
(
Listener
.
Type
.
BATCH
)
map
.
from
(
properties:
:
getType
).
whenEqualTo
(
Listener
.
Type
.
BATCH
)
.
toCall
(()
->
factory
.
setBatchListener
(
true
));
.
toCall
(()
->
factory
.
setBatchListener
(
true
));
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java
View file @
1bd52bc4
...
@@ -84,7 +84,7 @@ public class TomcatWebServerFactoryCustomizer implements
...
@@ -84,7 +84,7 @@ public class TomcatWebServerFactoryCustomizer implements
tomcatProperties
.
getMaxThreads
()));
tomcatProperties
.
getMaxThreads
()));
propertyMapper
.
from
(
tomcatProperties:
:
getMinSpareThreads
).
when
(
this
::
isPositive
)
propertyMapper
.
from
(
tomcatProperties:
:
getMinSpareThreads
).
when
(
this
::
isPositive
)
.
to
((
minSpareThreads
)
->
customizeMinThreads
(
factory
,
minSpareThreads
));
.
to
((
minSpareThreads
)
->
customizeMinThreads
(
factory
,
minSpareThreads
));
propertyMapper
.
from
(
()
->
determineMaxHttpHeaderSize
()
).
when
(
this
::
isPositive
)
propertyMapper
.
from
(
this
::
determineMaxHttpHeaderSize
).
when
(
this
::
isPositive
)
.
to
((
maxHttpHeaderSize
)
->
customizeMaxHttpHeaderSize
(
factory
,
.
to
((
maxHttpHeaderSize
)
->
customizeMaxHttpHeaderSize
(
factory
,
maxHttpHeaderSize
));
maxHttpHeaderSize
));
propertyMapper
.
from
(
tomcatProperties:
:
getMaxSwallowSize
).
whenNonNull
()
propertyMapper
.
from
(
tomcatProperties:
:
getMaxSwallowSize
).
whenNonNull
()
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java
View file @
1bd52bc4
...
@@ -81,7 +81,7 @@ public class UndertowWebServerFactoryCustomizer implements
...
@@ -81,7 +81,7 @@ public class UndertowWebServerFactoryCustomizer implements
.
to
(
factory:
:
setAccessLogSuffix
);
.
to
(
factory:
:
setAccessLogSuffix
);
propertyMapper
.
from
(
accesslogProperties:
:
isRotate
)
propertyMapper
.
from
(
accesslogProperties:
:
isRotate
)
.
to
(
factory:
:
setAccessLogRotate
);
.
to
(
factory:
:
setAccessLogRotate
);
propertyMapper
.
from
(
()
->
getOrDeduceUseForwardHeaders
()
)
propertyMapper
.
from
(
this
::
getOrDeduceUseForwardHeaders
)
.
to
(
factory:
:
setUseForwardHeaders
);
.
to
(
factory:
:
setUseForwardHeaders
);
propertyMapper
.
from
(
properties:
:
getMaxHttpHeaderSize
).
when
(
this
::
isPositive
)
propertyMapper
.
from
(
properties:
:
getMaxHttpHeaderSize
).
when
(
this
::
isPositive
)
.
to
((
maxHttpHeaderSize
)
->
customizeMaxHttpHeaderSize
(
factory
,
.
to
((
maxHttpHeaderSize
)
->
customizeMaxHttpHeaderSize
(
factory
,
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/MultipartProperties.java
View file @
1bd52bc4
...
@@ -138,10 +138,10 @@ public class MultipartProperties {
...
@@ -138,10 +138,10 @@ public class MultipartProperties {
public
MultipartConfigElement
createMultipartConfig
()
{
public
MultipartConfigElement
createMultipartConfig
()
{
MultipartConfigFactory
factory
=
new
MultipartConfigFactory
();
MultipartConfigFactory
factory
=
new
MultipartConfigFactory
();
PropertyMapper
map
=
PropertyMapper
.
get
().
alwaysApplyingWhenNonNull
();
PropertyMapper
map
=
PropertyMapper
.
get
().
alwaysApplyingWhenNonNull
();
map
.
from
(
()
->
this
.
fileSizeThreshold
).
to
(
factory:
:
setFileSizeThreshold
);
map
.
from
(
this
.
fileSizeThreshold
).
to
(
factory:
:
setFileSizeThreshold
);
map
.
from
(
()
->
this
.
location
).
whenHasText
().
to
(
factory:
:
setLocation
);
map
.
from
(
this
.
location
).
whenHasText
().
to
(
factory:
:
setLocation
);
map
.
from
(
()
->
this
.
maxRequestSize
).
to
(
factory:
:
setMaxRequestSize
);
map
.
from
(
this
.
maxRequestSize
).
to
(
factory:
:
setMaxRequestSize
);
map
.
from
(
()
->
this
.
maxFileSize
).
to
(
factory:
:
setMaxFileSize
);
map
.
from
(
this
.
maxFileSize
).
to
(
factory:
:
setMaxFileSize
);
return
factory
.
createMultipartConfig
();
return
factory
.
createMultipartConfig
();
}
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/PropertyMapper.java
View file @
1bd52bc4
...
@@ -91,6 +91,18 @@ public final class PropertyMapper {
...
@@ -91,6 +91,18 @@ public final class PropertyMapper {
return
new
PropertyMapper
(
this
,
operator
);
return
new
PropertyMapper
(
this
,
operator
);
}
}
/**
* Return a new {@link Source} from the specified value that can be used to perform
* the mapping.
* @param <T> the source type
* @param value the value
* @return a {@link Source} that can be used to complete the mapping
* @see #from(Supplier)
*/
public
<
T
>
Source
<
T
>
from
(
T
value
)
{
return
from
(()
->
value
);
}
/**
/**
* Return a new {@link Source} from the specified value supplier that can be used to
* Return a new {@link Source} from the specified value supplier that can be used to
* perform the mapping.
* perform the mapping.
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskExecutorBuilder.java
View file @
1bd52bc4
...
@@ -279,16 +279,15 @@ public class TaskExecutorBuilder {
...
@@ -279,16 +279,15 @@ public class TaskExecutorBuilder {
*/
*/
public
<
T
extends
ThreadPoolTaskExecutor
>
T
configure
(
T
taskExecutor
)
{
public
<
T
extends
ThreadPoolTaskExecutor
>
T
configure
(
T
taskExecutor
)
{
PropertyMapper
map
=
PropertyMapper
.
get
().
alwaysApplyingWhenNonNull
();
PropertyMapper
map
=
PropertyMapper
.
get
().
alwaysApplyingWhenNonNull
();
map
.
from
(
()
->
this
.
queueCapacity
).
to
(
taskExecutor:
:
setQueueCapacity
);
map
.
from
(
this
.
queueCapacity
).
to
(
taskExecutor:
:
setQueueCapacity
);
map
.
from
(
()
->
this
.
corePoolSize
).
to
(
taskExecutor:
:
setCorePoolSize
);
map
.
from
(
this
.
corePoolSize
).
to
(
taskExecutor:
:
setCorePoolSize
);
map
.
from
(
()
->
this
.
maxPoolSize
).
to
(
taskExecutor:
:
setMaxPoolSize
);
map
.
from
(
this
.
maxPoolSize
).
to
(
taskExecutor:
:
setMaxPoolSize
);
map
.
from
(
()
->
this
.
keepAlive
).
asInt
(
Duration:
:
getSeconds
)
map
.
from
(
this
.
keepAlive
).
asInt
(
Duration:
:
getSeconds
)
.
to
(
taskExecutor:
:
setKeepAliveSeconds
);
.
to
(
taskExecutor:
:
setKeepAliveSeconds
);
map
.
from
(()
->
this
.
allowCoreThreadTimeOut
)
map
.
from
(
this
.
allowCoreThreadTimeOut
).
to
(
taskExecutor:
:
setAllowCoreThreadTimeOut
);
.
to
(
taskExecutor:
:
setAllowCoreThreadTimeOut
);
map
.
from
(
this
.
threadNamePrefix
).
whenHasText
()
map
.
from
(()
->
this
.
threadNamePrefix
).
whenHasText
()
.
to
(
taskExecutor:
:
setThreadNamePrefix
);
.
to
(
taskExecutor:
:
setThreadNamePrefix
);
map
.
from
(
()
->
this
.
taskDecorator
).
to
(
taskExecutor:
:
setTaskDecorator
);
map
.
from
(
this
.
taskDecorator
).
to
(
taskExecutor:
:
setTaskDecorator
);
if
(!
CollectionUtils
.
isEmpty
(
this
.
taskExecutorCustomizers
))
{
if
(!
CollectionUtils
.
isEmpty
(
this
.
taskExecutorCustomizers
))
{
for
(
TaskExecutorCustomizer
customizer
:
this
.
taskExecutorCustomizers
)
{
for
(
TaskExecutorCustomizer
customizer
:
this
.
taskExecutorCustomizers
)
{
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/task/TaskSchedulerBuilder.java
View file @
1bd52bc4
...
@@ -167,8 +167,8 @@ public class TaskSchedulerBuilder {
...
@@ -167,8 +167,8 @@ public class TaskSchedulerBuilder {
*/
*/
public
<
T
extends
ThreadPoolTaskScheduler
>
T
configure
(
T
taskScheduler
)
{
public
<
T
extends
ThreadPoolTaskScheduler
>
T
configure
(
T
taskScheduler
)
{
PropertyMapper
map
=
PropertyMapper
.
get
().
alwaysApplyingWhenNonNull
();
PropertyMapper
map
=
PropertyMapper
.
get
().
alwaysApplyingWhenNonNull
();
map
.
from
(
()
->
this
.
poolSize
).
to
(
taskScheduler:
:
setPoolSize
);
map
.
from
(
this
.
poolSize
).
to
(
taskScheduler:
:
setPoolSize
);
map
.
from
(
()
->
this
.
threadNamePrefix
).
to
(
taskScheduler:
:
setThreadNamePrefix
);
map
.
from
(
this
.
threadNamePrefix
).
to
(
taskScheduler:
:
setThreadNamePrefix
);
if
(!
CollectionUtils
.
isEmpty
(
this
.
taskSchedulerCustomizers
))
{
if
(!
CollectionUtils
.
isEmpty
(
this
.
taskSchedulerCustomizers
))
{
for
(
TaskSchedulerCustomizer
customizer
:
this
.
taskSchedulerCustomizers
)
{
for
(
TaskSchedulerCustomizer
customizer
:
this
.
taskSchedulerCustomizers
)
{
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/webservices/client/WebServiceTemplateBuilder.java
View file @
1bd52bc4
...
@@ -502,13 +502,12 @@ public class WebServiceTemplateBuilder {
...
@@ -502,13 +502,12 @@ public class WebServiceTemplateBuilder {
configureMessageSenders
(
webServiceTemplate
);
configureMessageSenders
(
webServiceTemplate
);
PropertyMapper
map
=
PropertyMapper
.
get
().
alwaysApplyingWhenNonNull
();
PropertyMapper
map
=
PropertyMapper
.
get
().
alwaysApplyingWhenNonNull
();
applyCustomizers
(
webServiceTemplate
,
this
.
internalCustomizers
);
applyCustomizers
(
webServiceTemplate
,
this
.
internalCustomizers
);
map
.
from
(()
->
this
.
marshaller
).
to
(
webServiceTemplate:
:
setMarshaller
);
map
.
from
(
this
.
marshaller
).
to
(
webServiceTemplate:
:
setMarshaller
);
map
.
from
(()
->
this
.
unmarshaller
).
to
(
webServiceTemplate:
:
setUnmarshaller
);
map
.
from
(
this
.
unmarshaller
).
to
(
webServiceTemplate:
:
setUnmarshaller
);
map
.
from
(()
->
this
.
destinationProvider
)
map
.
from
(
this
.
destinationProvider
).
to
(
webServiceTemplate:
:
setDestinationProvider
);
.
to
(
webServiceTemplate:
:
setDestinationProvider
);
map
.
from
(
this
.
transformerFactoryClass
)
map
.
from
(()
->
this
.
transformerFactoryClass
)
.
to
(
webServiceTemplate:
:
setTransformerFactoryClass
);
.
to
(
webServiceTemplate:
:
setTransformerFactoryClass
);
map
.
from
(
()
->
this
.
messageFactory
).
to
(
webServiceTemplate:
:
setMessageFactory
);
map
.
from
(
this
.
messageFactory
).
to
(
webServiceTemplate:
:
setMessageFactory
);
if
(!
CollectionUtils
.
isEmpty
(
this
.
interceptors
))
{
if
(!
CollectionUtils
.
isEmpty
(
this
.
interceptors
))
{
Set
<
ClientInterceptor
>
merged
=
new
LinkedHashSet
<>(
this
.
interceptors
);
Set
<
ClientInterceptor
>
merged
=
new
LinkedHashSet
<>(
this
.
interceptors
);
if
(
webServiceTemplate
.
getInterceptors
()
!=
null
)
{
if
(
webServiceTemplate
.
getInterceptors
()
!=
null
)
{
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/PropertyMapperTests.java
View file @
1bd52bc4
...
@@ -37,11 +37,37 @@ public class PropertyMapperTests {
...
@@ -37,11 +37,37 @@ public class PropertyMapperTests {
@Rule
@Rule
public
ExpectedException
thrown
=
ExpectedException
.
none
();
public
ExpectedException
thrown
=
ExpectedException
.
none
();
@Test
public
void
fromNullValue
()
{
ExampleDest
dest
=
new
ExampleDest
();
this
.
map
.
from
((
String
)
null
).
to
(
dest:
:
setName
);
assertThat
(
dest
.
getName
()).
isNull
();
}
@Test
public
void
fromValue
()
{
ExampleDest
dest
=
new
ExampleDest
();
this
.
map
.
from
(
"Hello World"
).
to
(
dest:
:
setName
);
assertThat
(
dest
.
getName
()).
isEqualTo
(
"Hello World"
);
}
@Test
public
void
fromValueAsIntShouldAdaptSupplier
()
{
Integer
result
=
this
.
map
.
from
(
"123"
).
asInt
(
Long:
:
valueOf
)
.
toInstance
(
Integer:
:
new
);
assertThat
(
result
).
isEqualTo
(
123
);
}
@Test
public
void
fromValueAlwaysApplyingWhenNonNullShouldAlwaysApplyNonNullToSource
()
{
this
.
map
.
alwaysApplyingWhenNonNull
().
from
((
String
)
null
).
toCall
(
Assert:
:
fail
);
}
@Test
@Test
public
void
fromWhenSupplierIsNullShouldThrowException
()
{
public
void
fromWhenSupplierIsNullShouldThrowException
()
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
thrown
.
expectMessage
(
"Supplier must not be null"
);
this
.
thrown
.
expectMessage
(
"Supplier must not be null"
);
this
.
map
.
from
(
null
);
this
.
map
.
from
(
(
Supplier
<?>)
null
);
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment