Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
d094bd51
Commit
d094bd51
authored
13 years ago
by
buczekp
Browse files
Options
Downloads
Patches
Plain Diff
[LMS-2281] minor: new convenience methods for toString on Strings and Objects
SVN: 21608
parent
1769d217
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/source/java/ch/systemsx/cisd/common/shared/basic/utils/StringUtils.java
+28
-6
28 additions, 6 deletions
.../systemsx/cisd/common/shared/basic/utils/StringUtils.java
with
28 additions
and
6 deletions
common/source/java/ch/systemsx/cisd/common/shared/basic/utils/StringUtils.java
+
28
−
6
View file @
d094bd51
...
...
@@ -125,12 +125,33 @@ public final class StringUtils
return
isBlank
(
value
)
?
null
:
value
;
}
/** Returns an empty if given <var>stringOrNull</var> is <code>null</code>. */
/**
* Returns an empty string if given <var>stringOrNull</var> is <code>null</code>, otherwise it
* returns <var>stringOrNull</var> itself.
*/
public
static
final
String
emptyIfNull
(
final
String
stringOrNull
)
{
return
stringOrNull
==
null
?
EMPTY_STRING
:
stringOrNull
;
}
/**
* Returns an empty string if given <var>objectOrNull</var> is <code>null</code>, otherwise it
* returns result of {@link #toString()} on the object.
*/
public
static
final
String
toStringEmptyIfNull
(
final
Object
objectOrNull
)
{
return
objectOrNull
==
null
?
EMPTY_STRING
:
objectOrNull
.
toString
();
}
/**
* Returns null if given <var>objectOrNull</var> is <code>null</code>, otherwise it returns
* result of {@link #toString()} on the object.
*/
public
static
final
String
toStringOrNull
(
final
Object
objectOrNull
)
{
return
objectOrNull
==
null
?
null
:
objectOrNull
.
toString
();
}
/**
* Returns <var>defaultStr</var>, if <var>str</var> is blank, or otherwise it returns
* <var>str</var> itself.
...
...
@@ -228,18 +249,19 @@ public final class StringUtils
* <p>
* Allowed modifiers are:
* <ul>
* <li> <i>i</i> - Perform case-insensitive matching
* <li> <i>g</i> - Perform a global match (find all matches rather than stopping after the first match)
* <li> <i>m</i> - Perform multiline matching
* <li><i>i</i> - Perform case-insensitive matching
* <li><i>g</i> - Perform a global match (find all matches rather than stopping after the first
* match)
* <li><i>m</i> - Perform multiline matching
* </ul>
*/
public
static
final
native
boolean
matches
(
final
String
regExp
,
final
String
value
,
public
static
final
native
boolean
matches
(
final
String
regExp
,
final
String
value
,
final
String
modifiers
)
/*-{
var re = new RegExp(regExp, modifiers);
return value.search(re) > -1;
}-*/
;
/**
* Returns <code>true</code> if given <var>regExp</var> could be found in given
* <var>value</var>.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment