Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
60300148
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 搜索 >>
提交
60300148
编写于
3月 08, 2019
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CollectionUtils.toIterator tolerates null Enumeration as input
See gh-22547
上级
a94c12ff
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
39 deletion
+40
-39
spring-core/src/main/java/org/springframework/util/CollectionUtils.java
...c/main/java/org/springframework/util/CollectionUtils.java
+11
-10
spring-core/src/main/java/org/springframework/util/StringUtils.java
...e/src/main/java/org/springframework/util/StringUtils.java
+29
-29
未找到文件。
spring-core/src/main/java/org/springframework/util/CollectionUtils.java
浏览文件 @
60300148
/*
* Copyright 2002-201
6
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -125,7 +125,7 @@ public abstract class CollectionUtils {
* Check whether the given Iterator contains the given element.
* @param iterator the Iterator to check
* @param element the element to look for
* @return {@code true} if found, {@code false}
el
se
* @return {@code true} if found, {@code false}
otherwi
se
*/
public
static
boolean
contains
(
Iterator
<?>
iterator
,
Object
element
)
{
if
(
iterator
!=
null
)
{
...
...
@@ -143,7 +143,7 @@ public abstract class CollectionUtils {
* Check whether the given Enumeration contains the given element.
* @param enumeration the Enumeration to check
* @param element the element to look for
* @return {@code true} if found, {@code false}
el
se
* @return {@code true} if found, {@code false}
otherwi
se
*/
public
static
boolean
contains
(
Enumeration
<?>
enumeration
,
Object
element
)
{
if
(
enumeration
!=
null
)
{
...
...
@@ -163,7 +163,7 @@ public abstract class CollectionUtils {
* {@code true} for an equal element as well.
* @param collection the Collection to check
* @param element the element to look for
* @return {@code true} if found, {@code false}
el
se
* @return {@code true} if found, {@code false}
otherwi
se
*/
public
static
boolean
containsInstance
(
Collection
<?>
collection
,
Object
element
)
{
if
(
collection
!=
null
)
{
...
...
@@ -268,7 +268,7 @@ public abstract class CollectionUtils {
* Determine whether the given Collection only contains a single unique object.
* @param collection the Collection to check
* @return {@code true} if the collection contains a single reference or
* multiple references to the same instance, {@code false}
el
se
* multiple references to the same instance, {@code false}
otherwi
se
*/
public
static
boolean
hasUniqueObject
(
Collection
<?>
collection
)
{
if
(
isEmpty
(
collection
))
{
...
...
@@ -326,12 +326,13 @@ public abstract class CollectionUtils {
}
/**
* Adapt an
enumeration to an iterator
.
* @param enumeration the
enumeration
* @return the
iterator
* Adapt an
{@link Enumeration} to an {@link Iterator}
.
* @param enumeration the
original {@code Enumeration}
* @return the
adapted {@code Iterator}
*/
@SuppressWarnings
(
"unchecked"
)
public
static
<
E
>
Iterator
<
E
>
toIterator
(
Enumeration
<
E
>
enumeration
)
{
return
new
EnumerationIterator
<
E
>(
enumeration
);
return
(
enumeration
!=
null
?
new
EnumerationIterator
<
E
>(
enumeration
)
:
Collections
.
EMPTY_SET
.
iterator
()
);
}
/**
...
...
@@ -508,7 +509,7 @@ public abstract class CollectionUtils {
if
(
this
==
other
)
{
return
true
;
}
return
map
.
equals
(
other
);
return
this
.
map
.
equals
(
other
);
}
@Override
...
...
spring-core/src/main/java/org/springframework/util/StringUtils.java
浏览文件 @
60300148
/*
* Copyright 2002-201
8
the original author or authors.
* Copyright 2002-201
9
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.
...
...
@@ -765,6 +765,32 @@ public abstract class StringUtils {
// Convenience methods for working with String arrays
//---------------------------------------------------------------------
/**
* Copy the given {@link Collection} into a {@code String} array.
* <p>The {@code Collection} must contain {@code String} elements only.
* @param collection the {@code Collection} to copy
* @return the resulting {@code String} array
*/
public
static
String
[]
toStringArray
(
Collection
<
String
>
collection
)
{
if
(
collection
==
null
)
{
return
null
;
}
return
collection
.
toArray
(
new
String
[
collection
.
size
()]);
}
/**
* Copy the given {@link Enumeration} into a {@code String} array.
* <p>The {@code Enumeration} must contain {@code String} elements only.
* @param enumeration the {@code Enumeration} to copy
* @return the resulting {@code String} array
*/
public
static
String
[]
toStringArray
(
Enumeration
<
String
>
enumeration
)
{
if
(
enumeration
==
null
)
{
return
null
;
}
return
toStringArray
(
Collections
.
list
(
enumeration
));
}
/**
* Append the given {@code String} to the given {@code String} array,
* returning a new array consisting of the input array contents plus
...
...
@@ -838,8 +864,8 @@ public abstract class StringUtils {
}
/**
*
Turn given source {@code String} array into sorted arra
y.
* @param array the
source
array
*
Sort the given {@code String} array if necessar
y.
* @param array the
original
array
* @return the sorted array (never {@code null})
*/
public
static
String
[]
sortStringArray
(
String
[]
array
)
{
...
...
@@ -851,32 +877,6 @@ public abstract class StringUtils {
return
array
;
}
/**
* Copy the given {@code Collection} into a {@code String} array.
* <p>The {@code Collection} must contain {@code String} elements only.
* @param collection the {@code Collection} to copy
* @return the {@code String} array
*/
public
static
String
[]
toStringArray
(
Collection
<
String
>
collection
)
{
if
(
collection
==
null
)
{
return
null
;
}
return
collection
.
toArray
(
new
String
[
collection
.
size
()]);
}
/**
* Copy the given Enumeration into a {@code String} array.
* The Enumeration must contain {@code String} elements only.
* @param enumeration the Enumeration to copy
* @return the {@code String} array
*/
public
static
String
[]
toStringArray
(
Enumeration
<
String
>
enumeration
)
{
if
(
enumeration
==
null
)
{
return
null
;
}
return
toStringArray
(
Collections
.
list
(
enumeration
));
}
/**
* Trim the elements of the given {@code String} array,
* calling {@code String.trim()} on each of them.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录