Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
80364355
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
80364355
编写于
9月 04, 2019
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '5.1.x'
上级
0c735991
d036b5a2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
93 addition
and
23 deletion
+93
-23
spring-beans/src/main/java/org/springframework/beans/BeanUtils.java
...ns/src/main/java/org/springframework/beans/BeanUtils.java
+27
-20
spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java
...c/test/java/org/springframework/beans/BeanUtilsTests.java
+61
-0
spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java
...web/reactive/result/view/ViewResolutionResultHandler.java
+5
-3
未找到文件。
spring-beans/src/main/java/org/springframework/beans/BeanUtils.java
浏览文件 @
80364355
...
...
@@ -583,36 +583,43 @@ public abstract class BeanUtils {
}
/**
* Check if the given type represents a "simple" property:
* a primitive, a String or other CharSequence, a Number, a Date,
* a Temporal, a URI, a URL, a Locale, a Class, or a corresponding array.
* Check if the given type represents a "simple" property: a simple value
* type or an array of simple value types.
* <p>See {@link #isSimpleValueType(Class)} for the definition of <em>simple
* value type</em>.
* <p>Used to determine properties to check for a "simple" dependency-check.
* @param
clazz
the type to check
* @param
type
the type to check
* @return whether the given type represents a "simple" property
* @see org.springframework.beans.factory.support.RootBeanDefinition#DEPENDENCY_CHECK_SIMPLE
* @see org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#checkDependencies
* @see #isSimpleValueType(Class)
*/
public
static
boolean
isSimpleProperty
(
Class
<?>
clazz
)
{
Assert
.
notNull
(
clazz
,
"Class
must not be null"
);
return
isSimpleValueType
(
clazz
)
||
(
clazz
.
isArray
()
&&
isSimpleValueType
(
clazz
.
getComponentType
()));
public
static
boolean
isSimpleProperty
(
Class
<?>
type
)
{
Assert
.
notNull
(
type
,
"'type'
must not be null"
);
return
isSimpleValueType
(
type
)
||
(
type
.
isArray
()
&&
isSimpleValueType
(
type
.
getComponentType
()));
}
/**
* Check if the given type represents a "simple" value type:
* a primitive, an enum, a String or other CharSequence, a Number, a Date,
* a Temporal, a URI, a URL, a Locale or a Class.
* @param clazz the type to check
* Check if the given type represents a "simple" value type: a primitive or
* primitive wrapper, an enum, a String or other CharSequence, a Number, a
* Date, a Temporal, a URI, a URL, a Locale, or a Class.
* <p>{@code Void} and {@code void} are not considered simple value types.
* @param type the type to check
* @return whether the given type represents a "simple" value type
* @see #isSimpleProperty(Class)
*/
public
static
boolean
isSimpleValueType
(
Class
<?>
clazz
)
{
return
(
ClassUtils
.
isPrimitiveOrWrapper
(
clazz
)
||
Enum
.
class
.
isAssignableFrom
(
clazz
)
||
CharSequence
.
class
.
isAssignableFrom
(
clazz
)
||
Number
.
class
.
isAssignableFrom
(
clazz
)
||
Date
.
class
.
isAssignableFrom
(
clazz
)
||
Temporal
.
class
.
isAssignableFrom
(
clazz
)
||
URI
.
class
==
clazz
||
URL
.
class
==
clazz
||
Locale
.
class
==
clazz
||
Class
.
class
==
clazz
);
public
static
boolean
isSimpleValueType
(
Class
<?>
type
)
{
return
(
type
!=
void
.
class
&&
type
!=
Void
.
class
&&
(
ClassUtils
.
isPrimitiveOrWrapper
(
type
)
||
Enum
.
class
.
isAssignableFrom
(
type
)
||
CharSequence
.
class
.
isAssignableFrom
(
type
)
||
Number
.
class
.
isAssignableFrom
(
type
)
||
Date
.
class
.
isAssignableFrom
(
type
)
||
Temporal
.
class
.
isAssignableFrom
(
type
)
||
URI
.
class
==
type
||
URL
.
class
==
type
||
Locale
.
class
==
type
||
Class
.
class
==
type
));
}
...
...
spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java
浏览文件 @
80364355
...
...
@@ -20,7 +20,13 @@ import java.beans.Introspector;
import
java.beans.PropertyDescriptor
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Method
;
import
java.net.URI
;
import
java.net.URL
;
import
java.time.DayOfWeek
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.stream.Stream
;
import
org.junit.jupiter.api.Test
;
...
...
@@ -44,6 +50,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rob Harrop
* @author Chris Beams
* @author Sebastien Deleuze
* @author Sam Brannen
* @since 19.05.2003
*/
public
class
BeanUtilsTests
{
...
...
@@ -285,6 +292,60 @@ public class BeanUtilsTests {
}
}
@Test
public
void
isSimpleValueType
()
{
Stream
.
of
(
boolean
.
class
,
char
.
class
,
byte
.
class
,
short
.
class
,
int
.
class
,
long
.
class
,
float
.
class
,
double
.
class
,
Boolean
.
class
,
Character
.
class
,
Byte
.
class
,
Short
.
class
,
Integer
.
class
,
Long
.
class
,
Float
.
class
,
Double
.
class
,
DayOfWeek
.
class
,
String
.
class
,
Date
.
class
,
URI
.
class
,
URL
.
class
,
Locale
.
class
,
Class
.
class
).
forEach
(
this
::
assertIsSimpleValueType
);
Stream
.
of
(
int
[].
class
,
Object
.
class
,
List
.
class
,
void
.
class
,
Void
.
class
)
.
forEach
(
this
::
assertIsNotSimpleValueType
);
}
@Test
public
void
isSimpleProperty
()
{
Stream
.
of
(
boolean
.
class
,
char
.
class
,
byte
.
class
,
short
.
class
,
int
.
class
,
long
.
class
,
float
.
class
,
double
.
class
,
Boolean
.
class
,
Character
.
class
,
Byte
.
class
,
Short
.
class
,
Integer
.
class
,
Long
.
class
,
Float
.
class
,
Double
.
class
,
DayOfWeek
.
class
,
String
.
class
,
Date
.
class
,
URI
.
class
,
URL
.
class
,
Locale
.
class
,
Class
.
class
,
boolean
[].
class
,
Boolean
[].
class
,
Date
[].
class
).
forEach
(
this
::
assertIsSimpleProperty
);
Stream
.
of
(
Object
.
class
,
List
.
class
,
void
.
class
,
Void
.
class
)
.
forEach
(
this
::
assertIsNotSimpleProperty
);
}
private
void
assertIsSimpleValueType
(
Class
<?>
type
)
{
assertThat
(
BeanUtils
.
isSimpleValueType
(
type
)).
as
(
"Type ["
+
type
.
getName
()
+
"] should be a simple value type"
).
isTrue
();
}
private
void
assertIsNotSimpleValueType
(
Class
<?>
type
)
{
assertThat
(
BeanUtils
.
isSimpleValueType
(
type
)).
as
(
"Type ["
+
type
.
getName
()
+
"] should not be a simple value type"
).
isFalse
();
}
private
void
assertIsSimpleProperty
(
Class
<?>
type
)
{
assertThat
(
BeanUtils
.
isSimpleProperty
(
type
)).
as
(
"Type ["
+
type
.
getName
()
+
"] should be a simple property"
).
isTrue
();
}
private
void
assertIsNotSimpleProperty
(
Class
<?>
type
)
{
assertThat
(
BeanUtils
.
isSimpleProperty
(
type
)).
as
(
"Type ["
+
type
.
getName
()
+
"] should not be a simple property"
).
isFalse
();
}
private
void
assertSignatureEquals
(
Method
desiredMethod
,
String
signature
)
{
assertThat
(
BeanUtils
.
resolveSignature
(
signature
,
MethodSignatureBean
.
class
)).
isEqualTo
(
desiredMethod
);
}
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandler.java
浏览文件 @
80364355
...
...
@@ -160,9 +160,11 @@ public class ViewResolutionResultHandler extends HandlerResultHandlerSupport imp
type
=
result
.
getReturnType
().
getGeneric
().
toClass
();
}
return
(
CharSequence
.
class
.
isAssignableFrom
(
type
)
||
Rendering
.
class
.
isAssignableFrom
(
type
)
||
Model
.
class
.
isAssignableFrom
(
type
)
||
Map
.
class
.
isAssignableFrom
(
type
)
||
void
.
class
==
type
||
Void
.
class
==
type
||
View
.
class
.
isAssignableFrom
(
type
)
||
return
(
CharSequence
.
class
.
isAssignableFrom
(
type
)
||
Rendering
.
class
.
isAssignableFrom
(
type
)
||
Model
.
class
.
isAssignableFrom
(
type
)
||
Map
.
class
.
isAssignableFrom
(
type
)
||
View
.
class
.
isAssignableFrom
(
type
)
||
!
BeanUtils
.
isSimpleProperty
(
type
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录