Skip to content

Commit

Permalink
Merge pull request #87 from bpangburn/UncheckedAndLogging
Browse files Browse the repository at this point in the history
Minimize unchecked scope. Avoid StringBuilder in logging
  • Loading branch information
bpangburn authored Mar 19, 2021
2 parents 60817a0 + a50bcf3 commit 734b2e1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions swingset/src/main/java/com/nqadmin/swingset/SSBaseComboBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,6 @@ private void updateRowset() {
* As written this method will only work with the two current implementations of
* SSBaseComboBox: SSComboBox where M is Integer and SSDBComboBox where M is Long.
*/
@SuppressWarnings("unchecked")
@Override
public void updateSSComponent() {
// TODO Modify this class similar to updateSSComponent() in SSFormattedTextField and only limit JDBC types accepted
Expand All @@ -1061,23 +1060,25 @@ public void updateSSComponent() {
final String boundColumnText = getBoundColumnText();

// LOGGING
logger.debug("{}: getBoundColumnText() - " + boundColumnText, () -> getColumnForLog());
logger.debug(() -> String.format("%s: getBoundColumnText() - %s", getColumnForLog(), boundColumnText));

// GET THE BOUND VALUE STORED IN THE ROWSET - may throw a NumberFormatException
M targetValue = null;
Object objValue = null;
if ((boundColumnText != null) && !boundColumnText.isEmpty()) {
// https://github.com/bpangburn/swingset/issues/46
if (this instanceof SSComboBox) {
targetValue = (M)(Object)Integer.parseInt(boundColumnText);
objValue = Integer.parseInt(boundColumnText);
} else if (this instanceof SSDBComboBox) {
targetValue = (M)(Object)Long.parseLong(boundColumnText);
objValue = Long.parseLong(boundColumnText);
} else {
throw new Exception();
}
}
@SuppressWarnings("unchecked")
M targetValue = (M) objValue;

// LOGGING
logger.debug("{}: targetValue - " + targetValue, () -> getColumnForLog());
logger.debug(() -> String.format("%s: targetValue - %s", getColumnForLog(), targetValue));

// UPDATE COMPONENT
setSelectedMapping(targetValue);// setSelectedMapping() should handle null OK.}
Expand Down

0 comments on commit 734b2e1

Please sign in to comment.