Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
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
YZG
yzg-util
Commits
1e77ab8e
Commit
1e77ab8e
authored
Jul 30, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
常规BUG的修改
parent
da705be1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
49 deletions
+41
-49
StringHelper.java
...c/main/java/com/yanzuoguang/util/helper/StringHelper.java
+41
-49
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/StringHelper.java
View file @
1e77ab8e
...
@@ -115,67 +115,69 @@ public class StringHelper {
...
@@ -115,67 +115,69 @@ public class StringHelper {
return
str
.
toString
();
return
str
.
toString
();
}
}
/**
/**
* 传入很多
字符串,获取第一个非空的字符串,至少需要两个参数
* 传入很多
值,返回第一个不等于排除值、空值的值,当全部为排除值时,返回默认值
*
*
* @param from0 第一个参数
* @param expandValue 排除值
* @param froms 参数列表
* @param defReturn 默认返回值
* @return 第一个非空字符串
* @param froms 其他值
* @param <T>
* @return 返回值
*/
*/
public
static
String
getFirst
(
String
from0
,
String
...
froms
)
{
public
static
<
T
extends
Object
>
T
getFirstRun
(
T
expandValue
,
T
defReturn
,
T
...
froms
)
{
if
(!
isEmpty
(
from0
))
{
return
from0
;
}
if
(
froms
!=
null
)
{
if
(
froms
!=
null
)
{
for
(
String
from
:
froms
)
{
for
(
T
from
:
froms
)
{
if
(!
isEmpty
(
from
))
{
if
(
isEmpty
(
from
))
{
continue
;
}
if
(
expandValue
!=
null
&&
(
expandValue
==
from
||
expandValue
.
equals
(
from
)))
{
continue
;
}
return
from
;
return
from
;
}
}
}
}
return
defReturn
;
}
}
return
EMPTY
;
/**
* 传入很多字符串,获取第一个非空的字符串,至少需要两个参数
*
* @param froms 参数列表
* @return 第一个非空字符串
*/
public
static
String
getFirst
(
String
...
froms
)
{
return
getFirstRun
(
EMPTY
,
EMPTY
,
froms
);
}
}
/**
/**
* 传入很多整形,获取第一个非0的值,至少需要两个参数
* 传入很多整形,获取第一个非0的值,至少需要两个参数
*
*
* @param from0 第一个参数
* @param froms 参数列表
* @param froms 参数列表
* @return 第一个非0值
* @return 第一个非0值
*/
*/
public
static
Integer
getFirst
(
Integer
from0
,
Integer
...
froms
)
{
public
static
Integer
getFirst
(
Integer
...
froms
)
{
if
(
from0
!=
null
&&
from0
!=
0
)
{
return
getFirstRun
(
0
,
0
,
froms
);
return
from0
;
}
if
(
froms
!=
null
)
{
for
(
Integer
from
:
froms
)
{
if
(
from
!=
null
&&
from
!=
0
)
{
return
from
;
}
}
}
return
0
;
}
}
/**
/**
* 传入很多整形,获取第一个非0的值,至少需要两个参数
* 传入很多整形,获取第一个非0的值,至少需要两个参数
*
*
* @param from0 第一个参数
* @param froms 参数列表
* @param froms 参数列表
* @return 第一个非0值
* @return 第一个非0值
*/
*/
public
static
Double
getFirst
(
Double
from0
,
Double
...
froms
)
{
public
static
Double
getFirst
(
Double
...
froms
)
{
if
(
from0
!=
null
&&
from0
!=
0
)
{
return
getFirstRun
(
0.0
,
0.0
,
froms
);
return
from0
;
}
}
if
(
froms
!=
null
)
{
for
(
Double
from
:
froms
)
{
/**
if
(
from
!=
null
&&
from
!=
0
)
{
* 获取第一个非空值
return
from
;
*
}
* @param froms 返回值
}
* @return 默认返回false
}
*/
return
0.0
;
public
static
Boolean
getFirst
(
Boolean
...
froms
)
{
return
getFirstRun
(
null
,
false
,
froms
);
}
}
/**
/**
...
@@ -186,17 +188,7 @@ public class StringHelper {
...
@@ -186,17 +188,7 @@ public class StringHelper {
* @return 第一个非空字符串
* @return 第一个非空字符串
*/
*/
public
static
String
getFirstNull
(
String
from0
,
String
...
froms
)
{
public
static
String
getFirstNull
(
String
from0
,
String
...
froms
)
{
if
(!
isEmpty
(
from0
))
{
return
getFirstRun
(
EMPTY
,
null
,
froms
);
return
from0
;
}
if
(
froms
!=
null
)
{
for
(
String
from
:
froms
)
{
if
(!
isEmpty
(
from
))
{
return
from
;
}
}
}
return
null
;
}
}
/**
/**
...
...
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