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
d4f87ae7
Commit
d4f87ae7
authored
Apr 28, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
461cca32
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
55 additions
and
67 deletions
+55
-67
DataSourceBuilder.java
...gframework/boot/autoconfigure/jdbc/DataSourceBuilder.java
+2
-2
XADataSourceAutoConfiguration.java
...oot/autoconfigure/jdbc/XADataSourceAutoConfiguration.java
+1
-1
ConfigurationBeanFactoryMetaData.java
.../context/properties/ConfigurationBeanFactoryMetaData.java
+3
-3
ConfigurationPropertiesBindingPostProcessor.java
...operties/ConfigurationPropertiesBindingPostProcessor.java
+1
-1
BeanBinder.java
...ingframework/boot/context/properties/bind/BeanBinder.java
+1
-1
BindException.java
...framework/boot/context/properties/bind/BindException.java
+1
-1
BindHandler.java
...ngframework/boot/context/properties/bind/BindHandler.java
+1
-1
BindResult.java
...ingframework/boot/context/properties/bind/BindResult.java
+1
-1
Bindable.java
...pringframework/boot/context/properties/bind/Bindable.java
+2
-2
Binder.java
.../springframework/boot/context/properties/bind/Binder.java
+1
-1
JavaBeanBinder.java
...ramework/boot/context/properties/bind/JavaBeanBinder.java
+6
-6
MapBinder.java
...ringframework/boot/context/properties/bind/MapBinder.java
+2
-3
PropertySourcesPlaceholdersResolver.java
.../properties/bind/PropertySourcesPlaceholdersResolver.java
+2
-2
ValidationBindHandler.java
...ext/properties/bind/validation/ValidationBindHandler.java
+1
-1
ConfigurationPropertyName.java
.../context/properties/source/ConfigurationPropertyName.java
+4
-4
ConfigurationPropertyNameAliases.java
...t/properties/source/ConfigurationPropertyNameAliases.java
+6
-6
ConfigurationPropertySource.java
...ontext/properties/source/ConfigurationPropertySource.java
+1
-1
ConfigurationPropertySources.java
...ntext/properties/source/ConfigurationPropertySources.java
+1
-1
DefaultPropertyMapper.java
...boot/context/properties/source/DefaultPropertyMapper.java
+4
-12
MapConfigurationPropertySource.java
...ext/properties/source/MapConfigurationPropertySource.java
+1
-1
PropertySourceConfigurationPropertySource.java
...ies/source/PropertySourceConfigurationPropertySource.java
+2
-4
SystemEnvironmentPropertyMapper.java
...xt/properties/source/SystemEnvironmentPropertyMapper.java
+2
-3
TextResourceOrigin.java
...a/org/springframework/boot/origin/TextResourceOrigin.java
+1
-1
ConfigurationPropertyNameAliasesTests.java
...perties/source/ConfigurationPropertyNameAliasesTests.java
+8
-8
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceBuilder.java
View file @
d4f87ae7
...
@@ -90,8 +90,8 @@ public class DataSourceBuilder {
...
@@ -90,8 +90,8 @@ public class DataSourceBuilder {
ConfigurationPropertySource
source
=
new
MapConfigurationPropertySource
(
ConfigurationPropertySource
source
=
new
MapConfigurationPropertySource
(
this
.
properties
);
this
.
properties
);
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
aliases
.
addAl
ai
ses
(
"url"
,
"jdbc-url"
);
aliases
.
addAl
ia
ses
(
"url"
,
"jdbc-url"
);
aliases
.
addAl
ai
ses
(
"username"
,
"user"
);
aliases
.
addAl
ia
ses
(
"username"
,
"user"
);
Binder
binder
=
new
Binder
(
source
.
withAliases
(
aliases
));
Binder
binder
=
new
Binder
(
source
.
withAliases
(
aliases
));
binder
.
bind
(
ConfigurationPropertyName
.
EMPTY
,
Bindable
.
ofInstance
(
result
));
binder
.
bind
(
ConfigurationPropertyName
.
EMPTY
,
Bindable
.
ofInstance
(
result
));
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/XADataSourceAutoConfiguration.java
View file @
d4f87ae7
...
@@ -124,7 +124,7 @@ public class XADataSourceAutoConfiguration implements BeanClassLoaderAware {
...
@@ -124,7 +124,7 @@ public class XADataSourceAutoConfiguration implements BeanClassLoaderAware {
source
.
put
(
"url"
,
this
.
properties
.
determineUrl
());
source
.
put
(
"url"
,
this
.
properties
.
determineUrl
());
source
.
putAll
(
dataSourceProperties
.
getXa
().
getProperties
());
source
.
putAll
(
dataSourceProperties
.
getXa
().
getProperties
());
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
aliases
.
addAl
ai
ses
(
"user"
,
"username"
);
aliases
.
addAl
ia
ses
(
"user"
,
"username"
);
return
source
.
withAliases
(
aliases
);
return
source
.
withAliases
(
aliases
);
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetaData.java
View file @
d4f87ae7
...
@@ -41,7 +41,7 @@ public class ConfigurationBeanFactoryMetaData implements BeanFactoryPostProcesso
...
@@ -41,7 +41,7 @@ public class ConfigurationBeanFactoryMetaData implements BeanFactoryPostProcesso
private
ConfigurableListableBeanFactory
beanFactory
;
private
ConfigurableListableBeanFactory
beanFactory
;
private
Map
<
String
,
MetaData
>
beans
=
new
HashMap
<>();
private
final
Map
<
String
,
MetaData
>
beans
=
new
HashMap
<>();
@Override
@Override
public
void
postProcessBeanFactory
(
ConfigurableListableBeanFactory
beanFactory
)
public
void
postProcessBeanFactory
(
ConfigurableListableBeanFactory
beanFactory
)
...
@@ -96,9 +96,9 @@ public class ConfigurationBeanFactoryMetaData implements BeanFactoryPostProcesso
...
@@ -96,9 +96,9 @@ public class ConfigurationBeanFactoryMetaData implements BeanFactoryPostProcesso
private
static
class
MetaData
{
private
static
class
MetaData
{
private
String
bean
;
private
final
String
bean
;
private
String
method
;
private
final
String
method
;
MetaData
(
String
bean
,
String
method
)
{
MetaData
(
String
bean
,
String
method
)
{
this
.
bean
=
bean
;
this
.
bean
=
bean
;
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java
View file @
d4f87ae7
...
@@ -465,7 +465,7 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
...
@@ -465,7 +465,7 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc
*/
*/
private
static
class
ChainingValidator
implements
Validator
{
private
static
class
ChainingValidator
implements
Validator
{
private
Validator
[]
validators
;
private
final
Validator
[]
validators
;
ChainingValidator
(
Validator
...
validators
)
{
ChainingValidator
(
Validator
...
validators
)
{
Assert
.
notNull
(
validators
,
"Validators must not be null"
);
Assert
.
notNull
(
validators
,
"Validators must not be null"
);
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanBinder.java
View file @
d4f87ae7
...
@@ -29,7 +29,7 @@ interface BeanBinder {
...
@@ -29,7 +29,7 @@ interface BeanBinder {
/**
/**
* Return a bound bean instance or {@code null} if the {@link BeanBinder} does not
* Return a bound bean instance or {@code null} if the {@link BeanBinder} does not
* support the specified {@link Bindable}.
* support the specified {@link Bindable}.
* @param target the binable to bind
* @param target the bin
d
able to bind
* @param hasKnownBindableProperties if this binder has known bindable elements. If
* @param hasKnownBindableProperties if this binder has known bindable elements. If
* names from underlying {@link ConfigurationPropertySource} cannot be iterated this
* names from underlying {@link ConfigurationPropertySource} cannot be iterated this
* method can be {@code false}, even though binding may ultimately succeed.
* method can be {@code false}, even though binding may ultimately succeed.
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindException.java
View file @
d4f87ae7
...
@@ -78,7 +78,7 @@ public class BindException extends RuntimeException implements OriginProvider {
...
@@ -78,7 +78,7 @@ public class BindException extends RuntimeException implements OriginProvider {
StringBuilder
message
=
new
StringBuilder
();
StringBuilder
message
=
new
StringBuilder
();
message
.
append
(
"Failed to bind properties"
);
message
.
append
(
"Failed to bind properties"
);
message
.
append
(
name
==
null
?
""
:
" under '"
+
name
+
"'"
);
message
.
append
(
name
==
null
?
""
:
" under '"
+
name
+
"'"
);
message
.
append
(
" to "
+
target
.
getType
());
message
.
append
(
" to "
).
append
(
target
.
getType
());
return
message
.
toString
();
return
message
.
toString
();
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindHandler.java
View file @
d4f87ae7
...
@@ -29,7 +29,7 @@ import org.springframework.boot.context.properties.source.ConfigurationPropertyN
...
@@ -29,7 +29,7 @@ import org.springframework.boot.context.properties.source.ConfigurationPropertyN
public
interface
BindHandler
{
public
interface
BindHandler
{
/**
/**
* Default no-op bind hander.
* Default no-op bind hand
l
er.
*/
*/
BindHandler
DEFAULT
=
new
BindHandler
()
{
BindHandler
DEFAULT
=
new
BindHandler
()
{
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java
View file @
d4f87ae7
...
@@ -161,7 +161,7 @@ public final class BindResult<T> {
...
@@ -161,7 +161,7 @@ public final class BindResult<T> {
if
(
value
==
null
)
{
if
(
value
==
null
)
{
return
(
BindResult
<
T
>)
UNBOUND
;
return
(
BindResult
<
T
>)
UNBOUND
;
}
}
return
new
BindResult
<
T
>(
value
);
return
new
BindResult
<>(
value
);
}
}
}
}
spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java
View file @
d4f87ae7
...
@@ -129,7 +129,7 @@ public final class Bindable<T> {
...
@@ -129,7 +129,7 @@ public final class Bindable<T> {
* @return an updated {@link Bindable}
* @return an updated {@link Bindable}
*/
*/
public
Bindable
<
T
>
withAnnotations
(
Annotation
...
annotations
)
{
public
Bindable
<
T
>
withAnnotations
(
Annotation
...
annotations
)
{
return
new
Bindable
<
T
>(
this
.
type
,
this
.
boxedType
,
this
.
value
,
return
new
Bindable
<>(
this
.
type
,
this
.
boxedType
,
this
.
value
,
(
annotations
==
null
?
NO_ANNOTATIONS
:
annotations
));
(
annotations
==
null
?
NO_ANNOTATIONS
:
annotations
));
}
}
...
@@ -226,7 +226,7 @@ public final class Bindable<T> {
...
@@ -226,7 +226,7 @@ public final class Bindable<T> {
Class
<?>
wrapperType
=
Array
.
get
(
array
,
0
).
getClass
();
Class
<?>
wrapperType
=
Array
.
get
(
array
,
0
).
getClass
();
return
ResolvableType
.
forClass
(
wrapperType
);
return
ResolvableType
.
forClass
(
wrapperType
);
}
}
if
(
resolved
.
isArray
())
{
if
(
resolved
!=
null
&&
resolved
.
isArray
())
{
return
ResolvableType
.
forArrayComponent
(
box
(
type
.
getComponentType
()));
return
ResolvableType
.
forArrayComponent
(
box
(
type
.
getComponentType
()));
}
}
return
type
;
return
type
;
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java
View file @
d4f87ae7
...
@@ -287,7 +287,7 @@ public class Binder {
...
@@ -287,7 +287,7 @@ public class Binder {
}
}
private
Object
bindBean
(
ConfigurationPropertyName
name
,
Bindable
<?>
target
,
private
Object
bindBean
(
ConfigurationPropertyName
name
,
Bindable
<?>
target
,
BindHandler
handler
,
Context
context
)
throws
Exception
{
BindHandler
handler
,
Context
context
)
{
boolean
hasKnownBindableProperties
=
context
.
streamSources
()
boolean
hasKnownBindableProperties
=
context
.
streamSources
()
.
flatMap
((
s
)
->
s
.
filter
(
name:
:
isAncestorOf
).
stream
()).
findAny
()
.
flatMap
((
s
)
->
s
.
filter
(
name:
:
isAncestorOf
).
stream
()).
findAny
()
.
isPresent
();
.
isPresent
();
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java
View file @
d4f87ae7
...
@@ -44,12 +44,12 @@ class JavaBeanBinder implements BeanBinder {
...
@@ -44,12 +44,12 @@ class JavaBeanBinder implements BeanBinder {
return
null
;
return
null
;
}
}
BeanSupplier
<
T
>
beanSupplier
=
bean
.
getSupplier
(
target
);
BeanSupplier
<
T
>
beanSupplier
=
bean
.
getSupplier
(
target
);
boolean
bound
=
bind
(
target
,
propertyBinder
,
bean
,
beanSupplier
);
boolean
bound
=
bind
(
propertyBinder
,
bean
,
beanSupplier
);
return
(
bound
?
beanSupplier
.
get
()
:
null
);
return
(
bound
?
beanSupplier
.
get
()
:
null
);
}
}
private
<
T
>
boolean
bind
(
B
indable
<
T
>
target
,
BeanPropertyBinder
propertyBinder
,
private
<
T
>
boolean
bind
(
B
eanPropertyBinder
propertyBinder
,
Bean
<
T
>
bean
,
Bean
<
T
>
bean
,
Bean
Supplier
<
T
>
beanSupplier
)
{
BeanSupplier
<
T
>
beanSupplier
)
{
boolean
bound
=
false
;
boolean
bound
=
false
;
for
(
Map
.
Entry
<
String
,
BeanProperty
>
entry
:
bean
.
getProperties
().
entrySet
())
{
for
(
Map
.
Entry
<
String
,
BeanProperty
>
entry
:
bean
.
getProperties
().
entrySet
())
{
bound
|=
bind
(
beanSupplier
,
propertyBinder
,
entry
.
getValue
());
bound
|=
bind
(
beanSupplier
,
propertyBinder
,
entry
.
getValue
());
...
@@ -151,7 +151,7 @@ class JavaBeanBinder implements BeanBinder {
...
@@ -151,7 +151,7 @@ class JavaBeanBinder implements BeanBinder {
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
public
BeanSupplier
<
T
>
getSupplier
(
Bindable
<
T
>
target
)
{
public
BeanSupplier
<
T
>
getSupplier
(
Bindable
<
T
>
target
)
{
return
new
BeanSupplier
<
T
>(()
->
{
return
new
BeanSupplier
<>(()
->
{
T
instance
=
null
;
T
instance
=
null
;
if
(
target
.
getValue
()
!=
null
)
{
if
(
target
.
getValue
()
!=
null
)
{
instance
=
target
.
getValue
().
get
();
instance
=
target
.
getValue
().
get
();
...
@@ -168,7 +168,7 @@ class JavaBeanBinder implements BeanBinder {
...
@@ -168,7 +168,7 @@ class JavaBeanBinder implements BeanBinder {
boolean
useExistingValueForType
)
{
boolean
useExistingValueForType
)
{
Class
<?>
type
=
bindable
.
getType
().
resolve
();
Class
<?>
type
=
bindable
.
getType
().
resolve
();
Supplier
<
T
>
value
=
bindable
.
getValue
();
Supplier
<
T
>
value
=
bindable
.
getValue
();
if
(
value
==
null
&&
!
isInstantia
ta
ble
(
type
))
{
if
(
value
==
null
&&
!
isInstantiable
(
type
))
{
return
null
;
return
null
;
}
}
if
(
useExistingValueForType
&&
value
!=
null
)
{
if
(
useExistingValueForType
&&
value
!=
null
)
{
...
@@ -183,7 +183,7 @@ class JavaBeanBinder implements BeanBinder {
...
@@ -183,7 +183,7 @@ class JavaBeanBinder implements BeanBinder {
return
(
Bean
<
T
>)
bean
;
return
(
Bean
<
T
>)
bean
;
}
}
private
static
boolean
isInstantia
ta
ble
(
Class
<?>
type
)
{
private
static
boolean
isInstantiable
(
Class
<?>
type
)
{
if
(
type
.
isInterface
())
{
if
(
type
.
isInterface
())
{
return
false
;
return
false
;
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java
View file @
d4f87ae7
...
@@ -84,7 +84,7 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> {
...
@@ -84,7 +84,7 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> {
public
void
bindEntries
(
ConfigurationPropertySource
source
,
public
void
bindEntries
(
ConfigurationPropertySource
source
,
Map
<
Object
,
Object
>
map
)
{
Map
<
Object
,
Object
>
map
)
{
for
(
ConfigurationPropertyName
name
:
source
)
{
for
(
ConfigurationPropertyName
name
:
source
)
{
Bindable
<?>
valueBindable
=
getValueBindable
(
source
,
name
);
Bindable
<?>
valueBindable
=
getValueBindable
(
name
);
ConfigurationPropertyName
entryName
=
getEntryName
(
source
,
name
);
ConfigurationPropertyName
entryName
=
getEntryName
(
source
,
name
);
Object
key
=
getContext
().
getConversionService
()
Object
key
=
getContext
().
getConversionService
()
.
convert
(
getKeyName
(
entryName
),
this
.
keyType
);
.
convert
(
getKeyName
(
entryName
),
this
.
keyType
);
...
@@ -93,8 +93,7 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> {
...
@@ -93,8 +93,7 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> {
}
}
}
}
private
Bindable
<?>
getValueBindable
(
ConfigurationPropertySource
source
,
private
Bindable
<?>
getValueBindable
(
ConfigurationPropertyName
name
)
{
ConfigurationPropertyName
name
)
{
if
(
isMultiElementName
(
name
)
&&
isValueTreatedAsNestedMap
())
{
if
(
isMultiElementName
(
name
)
&&
isValueTreatedAsNestedMap
())
{
return
Bindable
.
of
(
this
.
mapType
);
return
Bindable
.
of
(
this
.
mapType
);
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolver.java
View file @
d4f87ae7
...
@@ -33,9 +33,9 @@ import org.springframework.util.SystemPropertyUtils;
...
@@ -33,9 +33,9 @@ import org.springframework.util.SystemPropertyUtils;
*/
*/
public
class
PropertySourcesPlaceholdersResolver
implements
PlaceholdersResolver
{
public
class
PropertySourcesPlaceholdersResolver
implements
PlaceholdersResolver
{
private
PropertySources
sources
;
private
final
PropertySources
sources
;
private
PropertyPlaceholderHelper
helper
;
private
final
PropertyPlaceholderHelper
helper
;
public
PropertySourcesPlaceholdersResolver
(
Environment
environment
)
{
public
PropertySourcesPlaceholdersResolver
(
Environment
environment
)
{
this
(
getSources
(
environment
),
null
);
this
(
getSources
(
environment
),
null
);
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/bind/validation/ValidationBindHandler.java
View file @
d4f87ae7
...
@@ -46,7 +46,7 @@ public class ValidationBindHandler extends AbstractBindHandler {
...
@@ -46,7 +46,7 @@ public class ValidationBindHandler extends AbstractBindHandler {
private
boolean
validate
;
private
boolean
validate
;
private
Set
<
ConfigurationProperty
>
boundProperties
=
new
LinkedHashSet
<>();
private
final
Set
<
ConfigurationProperty
>
boundProperties
=
new
LinkedHashSet
<>();
public
ValidationBindHandler
(
Validator
...
validators
)
{
public
ValidationBindHandler
(
Validator
...
validators
)
{
super
();
super
();
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java
View file @
d4f87ae7
...
@@ -141,7 +141,7 @@ public final class ConfigurationPropertyName
...
@@ -141,7 +141,7 @@ public final class ConfigurationPropertyName
* Returns {@code true} if this element is an ancestor (immediate or nested parent) or
* Returns {@code true} if this element is an ancestor (immediate or nested parent) or
* the specified name.
* the specified name.
* @param name the name to check
* @param name the name to check
* @return {@code true} if this name is an ances
s
or
* @return {@code true} if this name is an ances
t
or
*/
*/
public
boolean
isAncestorOf
(
ConfigurationPropertyName
name
)
{
public
boolean
isAncestorOf
(
ConfigurationPropertyName
name
)
{
ConfigurationPropertyName
candidate
=
(
name
==
null
?
null
:
name
.
getParent
());
ConfigurationPropertyName
candidate
=
(
name
==
null
?
null
:
name
.
getParent
());
...
@@ -231,8 +231,8 @@ public final class ConfigurationPropertyName
...
@@ -231,8 +231,8 @@ public final class ConfigurationPropertyName
public
static
ConfigurationPropertyName
of
(
String
name
)
public
static
ConfigurationPropertyName
of
(
String
name
)
throws
IllegalArgumentException
{
throws
IllegalArgumentException
{
Assert
.
notNull
(
name
,
"Name must not be null"
);
Assert
.
notNull
(
name
,
"Name must not be null"
);
Assert
.
isTrue
(!
name
.
toString
().
startsWith
(
"."
),
"Name must not start with '.'"
);
Assert
.
isTrue
(!
name
.
startsWith
(
"."
),
"Name must not start with '.'"
);
Assert
.
isTrue
(!
name
.
toString
().
endsWith
(
"."
),
"Name must not end with '.'"
);
Assert
.
isTrue
(!
name
.
endsWith
(
"."
),
"Name must not end with '.'"
);
if
(
StringUtils
.
isEmpty
(
name
))
{
if
(
StringUtils
.
isEmpty
(
name
))
{
return
EMPTY
;
return
EMPTY
;
}
}
...
@@ -308,7 +308,7 @@ public final class ConfigurationPropertyName
...
@@ -308,7 +308,7 @@ public final class ConfigurationPropertyName
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
String
string
=
getValue
(
Form
.
CONFIGURATION
)
.
toString
()
;
String
string
=
getValue
(
Form
.
CONFIGURATION
);
return
(
this
.
indexed
?
"["
+
string
+
"]"
:
string
);
return
(
this
.
indexed
?
"["
+
string
+
"]"
:
string
);
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameAliases.java
View file @
d4f87ae7
...
@@ -26,7 +26,7 @@ import org.springframework.util.LinkedMultiValueMap;
...
@@ -26,7 +26,7 @@ import org.springframework.util.LinkedMultiValueMap;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.util.MultiValueMap
;
/**
/**
* Maintains a mapping of {@link ConfigurationPropertyName} al
ai
ses.
* Maintains a mapping of {@link ConfigurationPropertyName} al
ia
ses.
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Madhura Bhave
* @author Madhura Bhave
...
@@ -41,23 +41,23 @@ public final class ConfigurationPropertyNameAliases {
...
@@ -41,23 +41,23 @@ public final class ConfigurationPropertyNameAliases {
}
}
public
ConfigurationPropertyNameAliases
(
String
name
,
String
...
aliases
)
{
public
ConfigurationPropertyNameAliases
(
String
name
,
String
...
aliases
)
{
addAl
ai
ses
(
name
,
aliases
);
addAl
ia
ses
(
name
,
aliases
);
}
}
public
ConfigurationPropertyNameAliases
(
ConfigurationPropertyName
name
,
public
ConfigurationPropertyNameAliases
(
ConfigurationPropertyName
name
,
ConfigurationPropertyName
...
aliases
)
{
ConfigurationPropertyName
...
aliases
)
{
addAl
ai
ses
(
name
,
aliases
);
addAl
ia
ses
(
name
,
aliases
);
}
}
public
void
addAl
ai
ses
(
String
name
,
String
...
aliases
)
{
public
void
addAl
ia
ses
(
String
name
,
String
...
aliases
)
{
Assert
.
notNull
(
name
,
"Name must not be null"
);
Assert
.
notNull
(
name
,
"Name must not be null"
);
Assert
.
notNull
(
aliases
,
"Aliases must not be null"
);
Assert
.
notNull
(
aliases
,
"Aliases must not be null"
);
addAl
ai
ses
(
ConfigurationPropertyName
.
of
(
name
),
addAl
ia
ses
(
ConfigurationPropertyName
.
of
(
name
),
Arrays
.
stream
(
aliases
).
map
(
ConfigurationPropertyName:
:
of
)
Arrays
.
stream
(
aliases
).
map
(
ConfigurationPropertyName:
:
of
)
.
toArray
(
ConfigurationPropertyName
[]::
new
));
.
toArray
(
ConfigurationPropertyName
[]::
new
));
}
}
public
void
addAl
ai
ses
(
ConfigurationPropertyName
name
,
public
void
addAl
ia
ses
(
ConfigurationPropertyName
name
,
ConfigurationPropertyName
...
aliases
)
{
ConfigurationPropertyName
...
aliases
)
{
Assert
.
notNull
(
name
,
"Name must not be null"
);
Assert
.
notNull
(
name
,
"Name must not be null"
);
Assert
.
notNull
(
aliases
,
"Aliases must not be null"
);
Assert
.
notNull
(
aliases
,
"Aliases must not be null"
);
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySource.java
View file @
d4f87ae7
...
@@ -77,7 +77,7 @@ public interface ConfigurationPropertySource extends Iterable<ConfigurationPrope
...
@@ -77,7 +77,7 @@ public interface ConfigurationPropertySource extends Iterable<ConfigurationPrope
/**
/**
* Return a variant of this source that supports name aliases.
* Return a variant of this source that supports name aliases.
* @param aliases a function that returns a stream of aliases for any given name
* @param aliases a function that returns a stream of aliases for any given name
* @return a {@link ConfigurationPropertySource} instance supporting name al
ai
ses
* @return a {@link ConfigurationPropertySource} instance supporting name al
ia
ses
*/
*/
default
ConfigurationPropertySource
withAliases
(
default
ConfigurationPropertySource
withAliases
(
ConfigurationPropertyNameAliases
aliases
)
{
ConfigurationPropertyNameAliases
aliases
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySources.java
View file @
d4f87ae7
...
@@ -47,7 +47,7 @@ public class ConfigurationPropertySources
...
@@ -47,7 +47,7 @@ public class ConfigurationPropertySources
/**
/**
* The name of the {@link PropertySource} {@link #adapt adapter}.
* The name of the {@link PropertySource} {@link #adapt adapter}.
*/
*/
public
static
final
String
PROPERTY_SOURCE_NAME
=
"configurationPropertes"
;
public
static
final
String
PROPERTY_SOURCE_NAME
=
"configurationPropert
i
es"
;
private
final
PropertySources
propertySources
;
private
final
PropertySources
propertySources
;
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/source/DefaultPropertyMapper.java
View file @
d4f87ae7
...
@@ -37,9 +37,9 @@ class DefaultPropertyMapper implements PropertyMapper {
...
@@ -37,9 +37,9 @@ class DefaultPropertyMapper implements PropertyMapper {
public
static
final
PropertyMapper
INSTANCE
=
new
DefaultPropertyMapper
();
public
static
final
PropertyMapper
INSTANCE
=
new
DefaultPropertyMapper
();
private
Cache
<
ConfigurationPropertyName
>
configurationPropertySourceCache
=
new
Cache
<>();
private
final
Cache
<
ConfigurationPropertyName
>
configurationPropertySourceCache
=
new
Cache
<>();
private
Cache
<
String
>
propertySourceCache
=
new
Cache
<>();
private
final
Cache
<
String
>
propertySourceCache
=
new
Cache
<>();
private
final
ConfigurationPropertyNameBuilder
nameBuilder
=
new
ConfigurationPropertyNameBuilder
();
private
final
ConfigurationPropertyNameBuilder
nameBuilder
=
new
ConfigurationPropertyNameBuilder
();
...
@@ -59,12 +59,7 @@ class DefaultPropertyMapper implements PropertyMapper {
...
@@ -59,12 +59,7 @@ class DefaultPropertyMapper implements PropertyMapper {
@Override
@Override
public
List
<
PropertyMapping
>
map
(
PropertySource
<?>
propertySource
,
public
List
<
PropertyMapping
>
map
(
PropertySource
<?>
propertySource
,
String
propertySourceName
)
{
String
propertySourceName
)
{
List
<
PropertyMapping
>
mapping
=
this
.
propertySourceCache
.
get
(
propertySourceName
);
return
this
.
propertySourceCache
.
computeIfAbsent
(
propertySourceName
,
this
::
tryMap
);
if
(
mapping
==
null
)
{
mapping
=
tryMap
(
propertySourceName
);
this
.
propertySourceCache
.
put
(
propertySourceName
,
mapping
);
}
return
mapping
;
}
}
private
List
<
PropertyMapping
>
tryMap
(
String
propertySourceName
)
{
private
List
<
PropertyMapping
>
tryMap
(
String
propertySourceName
)
{
...
@@ -94,10 +89,7 @@ class DefaultPropertyMapper implements PropertyMapper {
...
@@ -94,10 +89,7 @@ class DefaultPropertyMapper implements PropertyMapper {
@Override
@Override
protected
boolean
removeEldestEntry
(
Map
.
Entry
<
K
,
List
<
PropertyMapping
>>
eldest
)
{
protected
boolean
removeEldestEntry
(
Map
.
Entry
<
K
,
List
<
PropertyMapping
>>
eldest
)
{
if
(
size
()
<
this
.
capacity
)
{
return
size
()
>=
this
.
capacity
;
return
false
;
}
return
true
;
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySource.java
View file @
d4f87ae7
...
@@ -60,7 +60,7 @@ public class MapConfigurationPropertySource implements ConfigurationPropertySour
...
@@ -60,7 +60,7 @@ public class MapConfigurationPropertySource implements ConfigurationPropertySour
}
}
/**
/**
* Add all enties from the specified map.
* Add all ent
r
ies from the specified map.
* @param map the source map
* @param map the source map
*/
*/
public
void
putAll
(
Map
<?,
?>
map
)
{
public
void
putAll
(
Map
<?,
?>
map
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/source/PropertySourceConfigurationPropertySource.java
View file @
d4f87ae7
...
@@ -145,7 +145,7 @@ class PropertySourceConfigurationPropertySource implements ConfigurationProperty
...
@@ -145,7 +145,7 @@ class PropertySourceConfigurationPropertySource implements ConfigurationProperty
return
names
;
return
names
;
}
}
List
<
PropertyMapping
>
mappings
=
getPropertyMappings
();
List
<
PropertyMapping
>
mappings
=
getPropertyMappings
();
names
=
new
ArrayList
<
ConfigurationPropertyName
>(
mappings
.
size
());
names
=
new
ArrayList
<>(
mappings
.
size
());
for
(
PropertyMapping
mapping
:
mappings
)
{
for
(
PropertyMapping
mapping
:
mappings
)
{
names
.
add
(
mapping
.
getConfigurationPropertyName
());
names
.
add
(
mapping
.
getConfigurationPropertyName
());
}
}
...
@@ -167,7 +167,7 @@ class PropertySourceConfigurationPropertySource implements ConfigurationProperty
...
@@ -167,7 +167,7 @@ class PropertySourceConfigurationPropertySource implements ConfigurationProperty
}
}
String
[]
names
=
((
EnumerablePropertySource
<?>)
this
.
propertySource
)
String
[]
names
=
((
EnumerablePropertySource
<?>)
this
.
propertySource
)
.
getPropertyNames
();
.
getPropertyNames
();
mappings
=
new
ArrayList
<
PropertyMapping
>(
names
.
length
);
mappings
=
new
ArrayList
<>(
names
.
length
);
for
(
String
name
:
names
)
{
for
(
String
name
:
names
)
{
mappings
.
addAll
(
this
.
mapper
.
map
(
this
.
propertySource
,
name
));
mappings
.
addAll
(
this
.
mapper
.
map
(
this
.
propertySource
,
name
));
}
}
...
@@ -238,8 +238,6 @@ class PropertySourceConfigurationPropertySource implements ConfigurationProperty
...
@@ -238,8 +238,6 @@ class PropertySourceConfigurationPropertySource implements ConfigurationProperty
private
static
class
Cache
{
private
static
class
Cache
{
private
ConfigurationPropertyName
knownMissingName
;
private
List
<
ConfigurationPropertyName
>
names
;
private
List
<
ConfigurationPropertyName
>
names
;
private
List
<
PropertyMapping
>
mappings
;
private
List
<
PropertyMapping
>
mappings
;
...
...
spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java
View file @
d4f87ae7
...
@@ -45,7 +45,7 @@ import org.springframework.util.StringUtils;
...
@@ -45,7 +45,7 @@ import org.springframework.util.StringUtils;
*/
*/
class
SystemEnvironmentPropertyMapper
implements
PropertyMapper
{
class
SystemEnvironmentPropertyMapper
implements
PropertyMapper
{
public
static
PropertyMapper
INSTANCE
=
new
SystemEnvironmentPropertyMapper
();
public
static
final
PropertyMapper
INSTANCE
=
new
SystemEnvironmentPropertyMapper
();
private
final
ConfigurationPropertyNameBuilder
nameBuilder
=
new
ConfigurationPropertyNameBuilder
(
private
final
ConfigurationPropertyNameBuilder
nameBuilder
=
new
ConfigurationPropertyNameBuilder
(
this
::
createElement
);
this
::
createElement
);
...
@@ -104,10 +104,9 @@ class SystemEnvironmentPropertyMapper implements PropertyMapper {
...
@@ -104,10 +104,9 @@ class SystemEnvironmentPropertyMapper implements PropertyMapper {
}
}
private
String
convertName
(
ConfigurationPropertyName
configurationPropertyName
)
{
private
String
convertName
(
ConfigurationPropertyName
configurationPropertyName
)
{
String
propertyName
=
configurationPropertyName
.
stream
()
return
configurationPropertyName
.
stream
()
.
map
(
name
->
name
.
getValue
(
Form
.
UNIFORM
).
toUpperCase
())
.
map
(
name
->
name
.
getValue
(
Form
.
UNIFORM
).
toUpperCase
())
.
collect
(
Collectors
.
joining
(
"_"
));
.
collect
(
Collectors
.
joining
(
"_"
));
return
propertyName
;
}
}
private
boolean
isListShortcutPossible
(
ConfigurationPropertyName
name
)
{
private
boolean
isListShortcutPossible
(
ConfigurationPropertyName
name
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java
View file @
d4f87ae7
...
@@ -86,7 +86,7 @@ public class TextResourceOrigin implements Origin {
...
@@ -86,7 +86,7 @@ public class TextResourceOrigin implements Origin {
result
.
append
(
this
.
resource
==
null
?
"unknown resource [?]"
result
.
append
(
this
.
resource
==
null
?
"unknown resource [?]"
:
this
.
resource
.
getDescription
());
:
this
.
resource
.
getDescription
());
if
(
this
.
location
!=
null
)
{
if
(
this
.
location
!=
null
)
{
result
.
append
(
":"
+
this
.
location
);
result
.
append
(
":"
).
append
(
this
.
location
);
}
}
return
result
.
toString
();
return
result
.
toString
();
}
}
...
...
spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertyNameAliasesTests.java
View file @
d4f87ae7
...
@@ -62,7 +62,7 @@ public class ConfigurationPropertyNameAliasesTests {
...
@@ -62,7 +62,7 @@ public class ConfigurationPropertyNameAliasesTests {
@Test
@Test
public
void
addAliasesFromStringShouldAddMapping
()
throws
Exception
{
public
void
addAliasesFromStringShouldAddMapping
()
throws
Exception
{
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
aliases
.
addAl
ai
ses
(
"foo"
,
"bar"
,
"baz"
);
aliases
.
addAl
ia
ses
(
"foo"
,
"bar"
,
"baz"
);
assertThat
(
aliases
.
getAliases
(
ConfigurationPropertyName
.
of
(
"foo"
)))
assertThat
(
aliases
.
getAliases
(
ConfigurationPropertyName
.
of
(
"foo"
)))
.
containsExactly
(
ConfigurationPropertyName
.
of
(
"bar"
),
.
containsExactly
(
ConfigurationPropertyName
.
of
(
"bar"
),
ConfigurationPropertyName
.
of
(
"baz"
));
ConfigurationPropertyName
.
of
(
"baz"
));
...
@@ -71,7 +71,7 @@ public class ConfigurationPropertyNameAliasesTests {
...
@@ -71,7 +71,7 @@ public class ConfigurationPropertyNameAliasesTests {
@Test
@Test
public
void
addAlaisesFromNameShouldAddMapping
()
throws
Exception
{
public
void
addAlaisesFromNameShouldAddMapping
()
throws
Exception
{
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
aliases
.
addAl
ai
ses
(
ConfigurationPropertyName
.
of
(
"foo"
),
aliases
.
addAl
ia
ses
(
ConfigurationPropertyName
.
of
(
"foo"
),
ConfigurationPropertyName
.
of
(
"bar"
),
ConfigurationPropertyName
.
of
(
"baz"
));
ConfigurationPropertyName
.
of
(
"bar"
),
ConfigurationPropertyName
.
of
(
"baz"
));
assertThat
(
aliases
.
getAliases
(
ConfigurationPropertyName
.
of
(
"foo"
)))
assertThat
(
aliases
.
getAliases
(
ConfigurationPropertyName
.
of
(
"foo"
)))
.
containsExactly
(
ConfigurationPropertyName
.
of
(
"bar"
),
.
containsExactly
(
ConfigurationPropertyName
.
of
(
"bar"
),
...
@@ -81,8 +81,8 @@ public class ConfigurationPropertyNameAliasesTests {
...
@@ -81,8 +81,8 @@ public class ConfigurationPropertyNameAliasesTests {
@Test
@Test
public
void
addWhenHasExistingShouldAddAdditionalMappings
()
throws
Exception
{
public
void
addWhenHasExistingShouldAddAdditionalMappings
()
throws
Exception
{
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
aliases
.
addAl
ai
ses
(
"foo"
,
"bar"
);
aliases
.
addAl
ia
ses
(
"foo"
,
"bar"
);
aliases
.
addAl
ai
ses
(
"foo"
,
"baz"
);
aliases
.
addAl
ia
ses
(
"foo"
,
"baz"
);
assertThat
(
aliases
.
getAliases
(
ConfigurationPropertyName
.
of
(
"foo"
)))
assertThat
(
aliases
.
getAliases
(
ConfigurationPropertyName
.
of
(
"foo"
)))
.
containsExactly
(
ConfigurationPropertyName
.
of
(
"bar"
),
.
containsExactly
(
ConfigurationPropertyName
.
of
(
"bar"
),
ConfigurationPropertyName
.
of
(
"baz"
));
ConfigurationPropertyName
.
of
(
"baz"
));
...
@@ -97,7 +97,7 @@ public class ConfigurationPropertyNameAliasesTests {
...
@@ -97,7 +97,7 @@ public class ConfigurationPropertyNameAliasesTests {
@Test
@Test
public
void
getAliasesWhenMappedShouldReturnMapping
()
throws
Exception
{
public
void
getAliasesWhenMappedShouldReturnMapping
()
throws
Exception
{
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
aliases
.
addAl
ai
ses
(
"foo"
,
"bar"
);
aliases
.
addAl
ia
ses
(
"foo"
,
"bar"
);
assertThat
(
aliases
.
getAliases
(
ConfigurationPropertyName
.
of
(
"foo"
)))
assertThat
(
aliases
.
getAliases
(
ConfigurationPropertyName
.
of
(
"foo"
)))
.
containsExactly
(
ConfigurationPropertyName
.
of
(
"bar"
));
.
containsExactly
(
ConfigurationPropertyName
.
of
(
"bar"
));
}
}
...
@@ -105,8 +105,8 @@ public class ConfigurationPropertyNameAliasesTests {
...
@@ -105,8 +105,8 @@ public class ConfigurationPropertyNameAliasesTests {
@Test
@Test
public
void
getNameForAliasWhenHasMappingShouldReturnName
()
throws
Exception
{
public
void
getNameForAliasWhenHasMappingShouldReturnName
()
throws
Exception
{
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
aliases
.
addAl
ai
ses
(
"foo"
,
"bar"
);
aliases
.
addAl
ia
ses
(
"foo"
,
"bar"
);
aliases
.
addAl
ai
ses
(
"foo"
,
"baz"
);
aliases
.
addAl
ia
ses
(
"foo"
,
"baz"
);
assertThat
((
Object
)
aliases
.
getNameForAlias
(
ConfigurationPropertyName
.
of
(
"bar"
)))
assertThat
((
Object
)
aliases
.
getNameForAlias
(
ConfigurationPropertyName
.
of
(
"bar"
)))
.
isEqualTo
(
ConfigurationPropertyName
.
of
(
"foo"
));
.
isEqualTo
(
ConfigurationPropertyName
.
of
(
"foo"
));
assertThat
((
Object
)
aliases
.
getNameForAlias
(
ConfigurationPropertyName
.
of
(
"baz"
)))
assertThat
((
Object
)
aliases
.
getNameForAlias
(
ConfigurationPropertyName
.
of
(
"baz"
)))
...
@@ -116,7 +116,7 @@ public class ConfigurationPropertyNameAliasesTests {
...
@@ -116,7 +116,7 @@ public class ConfigurationPropertyNameAliasesTests {
@Test
@Test
public
void
getNameForAliasWhenNotMappedShouldReturnNull
()
throws
Exception
{
public
void
getNameForAliasWhenNotMappedShouldReturnNull
()
throws
Exception
{
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
ConfigurationPropertyNameAliases
aliases
=
new
ConfigurationPropertyNameAliases
();
aliases
.
addAl
ai
ses
(
"foo"
,
"bar"
);
aliases
.
addAl
ia
ses
(
"foo"
,
"bar"
);
assertThat
((
Object
)
aliases
.
getNameForAlias
(
ConfigurationPropertyName
.
of
(
"baz"
)))
assertThat
((
Object
)
aliases
.
getNameForAlias
(
ConfigurationPropertyName
.
of
(
"baz"
)))
.
isNull
();
.
isNull
();
}
}
...
...
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