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
0a5e45a6
Commit
0a5e45a6
authored
May 20, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将源码打包进jar包
parent
7dba90b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
11 deletions
+33
-11
StringHelper.java
...c/main/java/com/yanzuoguang/util/helper/StringHelper.java
+15
-11
TestStringHelper.java
yzg-util-base/src/test/java/helper/TestStringHelper.java
+18
-0
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/StringHelper.java
View file @
0a5e45a6
...
...
@@ -55,7 +55,7 @@ public class StringHelper {
for
(
Object
from
:
froms
)
{
boolean
isEmpty
=
from
==
null
||
from
.
toString
().
length
()
<
1
;
if
(
isEmpty
)
{
return
isEmpty
;
return
true
;
}
}
return
false
;
...
...
@@ -139,20 +139,24 @@ public class StringHelper {
* @param expandValue 排除值
* @param defReturn 默认返回值
* @param froms 其他值
* @param <T>
* @param <T>
数据类型
* @return 返回值
*/
public
static
<
T
extends
Object
>
T
getFirstRun
(
T
expandValue
,
T
defReturn
,
T
...
froms
)
{
if
(
froms
!
=
null
)
{
for
(
T
from
:
froms
)
{
if
(
isEmpty
(
from
))
{
continue
;
}
if
(
expandValue
!=
null
&&
(
expandValue
==
from
||
expandValue
.
equals
(
from
)))
{
continue
;
}
public
static
<
T
>
T
getFirstRun
(
T
expandValue
,
T
defReturn
,
T
...
froms
)
{
if
(
froms
=
=
null
)
{
return
defReturn
;
}
for
(
T
from
:
froms
)
{
if
(
from
==
null
||
isEmpty
(
from
))
{
continue
;
}
if
(
expandValue
==
null
)
{
return
from
;
}
if
(
expandValue
==
from
||
expandValue
.
equals
(
from
))
{
continue
;
}
return
from
;
}
return
defReturn
;
}
...
...
yzg-util-base/src/test/java/helper/TestStringHelper.java
View file @
0a5e45a6
package
helper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
org.junit.Assert
;
import
org.junit.Test
;
public
class
TestStringHelper
{
@Test
public
void
testFirstRun
()
{
int
firstRun
=
StringHelper
.
toInt
(
StringHelper
.
getFirstRun
(
0
,
0
,
1
,
2
));
Assert
.
assertEquals
(
firstRun
,
1
);
Assert
.
assertNotEquals
(
firstRun
,
2
);
firstRun
=
StringHelper
.
toInt
(
StringHelper
.
getFirstRun
(
0
,
0
,
null
,
0
,
2
));
Assert
.
assertEquals
(
firstRun
,
2
);
String
yzg
=
"颜佐光"
;
String
yzg1
=
"颜佐光1"
;
String
firstEmpty
=
StringHelper
.
getFirstRun
(
null
,
StringHelper
.
EMPTY
,
null
,
StringHelper
.
EMPTY
,
yzg
,
yzg1
);
Assert
.
assertEquals
(
firstEmpty
,
yzg
);
Assert
.
assertNotEquals
(
yzg
,
yzg1
);
}
@Test
public
void
test
()
{
System
.
out
.
println
(
StringHelper
.
left
(
"100500103"
,
3
));
...
...
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