Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new KiwiJdbc utility to return trimmed string, or null if blank #1048

Closed
sleberknight opened this issue Oct 5, 2023 · 0 comments · Fixed by #1061
Closed

Add new KiwiJdbc utility to return trimmed string, or null if blank #1048

sleberknight opened this issue Oct 5, 2023 · 0 comments · Fixed by #1061
Assignees
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Milestone

Comments

@sleberknight
Copy link
Member

sleberknight commented Oct 5, 2023

Add a utility to KiwiJdbc to return null if a string obtained from calling ResultSet#getString is blank (i.e. null, empty string, or whitespace-only). If the string is not blank, then strip any leading or trailing whitespace and return the result.

Signature:

@Nullable
String trimmedStringOrNullIfBlank(ResultSet rs, String columnName)

Behavior:

If the value returned by ResultSet#getString is null, return null. If it is blank, return null. Otherwise, return the value after stripping any leading or trailing whitespace. Intermediate whitespace, e.g. between words, is not removed.

Examples:

String Value Return Value
null null
"" null
" " null
"\t\r\n" null
"alice" "alice"
"Sphinx of black quartz, judge my vow" "Sphinx of black quartz, judge my vow"
" string with leading whitespace" "string with leading whitespace"
"string with trailing whitespace " "string with trailing whitespace"
" string with leading and trailing whitespace " "string with leading and trailing whitespace"
@sleberknight sleberknight added the new feature A new feature such as a new class, method, package, group of classes, etc. label Oct 5, 2023
@sleberknight sleberknight added this to the 3.1.0 milestone Oct 5, 2023
@sleberknight sleberknight self-assigned this Oct 5, 2023
@sleberknight sleberknight changed the title Add new KiwiJdbc utility to return null instead of blank strings, or stripped string Add new KiwiJdbc utility to return stripped string, or null instead of blank Oct 5, 2023
@sleberknight sleberknight changed the title Add new KiwiJdbc utility to return stripped string, or null instead of blank Add new KiwiJdbc utility to return stripped string, or null if blank Oct 8, 2023
@sleberknight sleberknight changed the title Add new KiwiJdbc utility to return stripped string, or null if blank Add new KiwiJdbc utility to return trimmed string, or null if blank Oct 8, 2023
sleberknight added a commit that referenced this issue Oct 8, 2023
Add stringOrNullIfBlank method to KiwiJdbc. If the value returned
from the database is null or blank (whitespace only), this method
returns null. If the value from the database is not blank, the
string is returned after trimming any leading or trailing whitespace.

Closes #1048
sleberknight added a commit that referenced this issue Oct 8, 2023
#1061)

Add stringOrNullIfBlank method to KiwiJdbc. If the value returned
from the database is null or blank (whitespace only), this method
returns null. If the value from the database is not blank, the
string is returned after trimming any leading or trailing whitespace.

Closes #1048
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant