-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted code for better output to the UI of the properties list
- Loading branch information
Showing
2 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...nd/src/main/java/edu/internet2/tier/shibboleth/admin/util/EmptyStringToNullConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package edu.internet2.tier.shibboleth.admin.util; | ||
|
|
||
| import org.apache.commons.lang3.StringUtils; | ||
|
|
||
| import javax.persistence.AttributeConverter; | ||
| import javax.persistence.Converter; | ||
|
|
||
| @Converter | ||
| public class EmptyStringToNullConverter implements AttributeConverter<String, String> { | ||
| @Override | ||
| public String convertToDatabaseColumn(String string) { | ||
| // if whitespace is set on a value, send null to the db | ||
| return StringUtils.defaultIfBlank(string, null); | ||
| } | ||
|
|
||
| @Override | ||
| public String convertToEntityAttribute(String dbData) { | ||
| // keep nulls from the db as nulls | ||
| return dbData; | ||
| } | ||
| } |