Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
228d9db4
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,发现更多精彩内容 >>
提交
228d9db4
编写于
2月 27, 2015
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish StreamConverter(Tests)
上级
fcd60b26
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
8 deletion
+14
-8
spring-core/src/main/java/org/springframework/core/convert/support/StreamConverter.java
...springframework/core/convert/support/StreamConverter.java
+2
-2
spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java
...gframework/core/convert/support/StreamConverterTests.java
+12
-6
未找到文件。
spring-core/src/main/java/org/springframework/core/convert/support/StreamConverter.java
浏览文件 @
228d9db4
...
...
@@ -29,7 +29,7 @@ import org.springframework.core.convert.converter.ConditionalGenericConverter;
import
org.springframework.lang.UsesJava8
;
/**
* Convert
a {@link Stream} to an
from a collection or array, converting the
* Convert
s a {@link Stream} to and
from a collection or array, converting the
* element type if necessary.
*
* @author Stephane Nicoll
...
...
@@ -77,7 +77,7 @@ public class StreamConverter implements ConditionalGenericConverter {
/**
* Validate that the specified {@code sourceType} can be converted to a {@link Collection} of
* t
ype type of the stream elements
* t
he type of the stream elements.
* @param elementType the type of the stream elements
* @param sourceType the type to convert from
*/
...
...
spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java
浏览文件 @
228d9db4
...
...
@@ -34,20 +34,23 @@ import static org.hamcrest.CoreMatchers.*;
import
static
org
.
hamcrest
.
core
.
Is
.
is
;
import
static
org
.
junit
.
Assert
.*;
/**
* Tests for {@link StreamConverter}.
*
* @author Stephane Nicoll
* @since 4.2
*/
public
class
StreamConverterTests
{
@Rule
public
final
ExpectedException
thrown
=
ExpectedException
.
none
();
private
GenericConversionService
conversionService
;
private
final
GenericConversionService
conversionService
=
new
GenericConversionService
()
;
private
StreamConverter
streamConverter
;
private
final
StreamConverter
streamConverter
=
new
StreamConverter
(
this
.
conversionService
)
;
@Before
public
void
setup
()
{
this
.
conversionService
=
new
GenericConversionService
();
this
.
streamConverter
=
new
StreamConverter
(
this
.
conversionService
);
this
.
conversionService
.
addConverter
(
new
CollectionToCollectionConverter
(
this
.
conversionService
));
this
.
conversionService
.
addConverter
(
new
ArrayToCollectionConverter
(
this
.
conversionService
));
this
.
conversionService
.
addConverter
(
new
CollectionToArrayConverter
(
this
.
conversionService
));
...
...
@@ -111,6 +114,7 @@ public class StreamConverterTests {
}
@Test
@SuppressWarnings
(
"resource"
)
public
void
convertFromListToStream
()
throws
NoSuchFieldException
{
this
.
conversionService
.
addConverterFactory
(
new
StringToNumberConverterFactory
());
List
<
String
>
stream
=
Arrays
.
asList
(
"1"
,
"2"
,
"3"
);
...
...
@@ -124,6 +128,7 @@ public class StreamConverterTests {
}
@Test
@SuppressWarnings
(
"resource"
)
public
void
convertFromArrayToStream
()
throws
NoSuchFieldException
{
Integer
[]
stream
=
new
Integer
[]
{
1
,
0
,
1
};
this
.
conversionService
.
addConverter
(
new
Converter
<
Integer
,
Boolean
>()
{
...
...
@@ -142,6 +147,7 @@ public class StreamConverterTests {
}
@Test
@SuppressWarnings
(
"resource"
)
public
void
convertFromListToRawStream
()
throws
NoSuchFieldException
{
List
<
String
>
stream
=
Arrays
.
asList
(
"1"
,
"2"
,
"3"
);
TypeDescriptor
streamOfInteger
=
new
TypeDescriptor
(
Types
.
class
.
getField
(
"rawStream"
));
;
...
...
@@ -169,7 +175,7 @@ public class StreamConverterTests {
new
TypeDescriptor
(
Types
.
class
.
getField
(
"arrayOfLongs"
)));
}
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
{
"rawtypes"
}
)
static
class
Types
{
public
List
<
String
>
listOfStrings
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录