-
Notifications
You must be signed in to change notification settings - Fork 151
Cloud Device generation adjustments #1906
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonValue; | ||
| import java.util.*; | ||
| import java.util.logging.Logger; | ||
|
|
||
| /** | ||
| * Type of cardholder account used for the transaction. Allows a cardholder to select the type of | ||
|
|
@@ -37,6 +38,8 @@ public enum AccountType { | |
|
|
||
| UNIVERSAL("Universal"); | ||
|
|
||
| private static final Logger LOG = Logger.getLogger(AccountType.class.getName()); | ||
|
|
||
| private String value; | ||
|
|
||
| AccountType(String value) { | ||
|
|
@@ -60,6 +63,12 @@ public static AccountType fromValue(String value) { | |
| return b; | ||
| } | ||
| } | ||
| throw new IllegalArgumentException("Unexpected value '" + value + "'"); | ||
| // handling unexpected value | ||
| LOG.warning( | ||
| "AccountType: unexpected enum value '" | ||
| + value | ||
| + "' - Supported values are " | ||
| + Arrays.toString(AccountType.values())); | ||
| return null; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is technically a breaking change, right? In the past this would have failed and now it will return
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure, the nexo Did you mean this change? or am I missing something? |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonValue; | ||
| import java.util.*; | ||
| import java.util.logging.Logger; | ||
|
|
||
| /** Gets or Sets Alignment */ | ||
| public enum Alignment { | ||
|
|
@@ -25,6 +26,8 @@ public enum Alignment { | |
|
|
||
| RIGHT("Right"); | ||
|
|
||
| private static final Logger LOG = Logger.getLogger(Alignment.class.getName()); | ||
|
|
||
| private String value; | ||
|
|
||
| Alignment(String value) { | ||
|
|
@@ -48,6 +51,12 @@ public static Alignment fromValue(String value) { | |
| return b; | ||
| } | ||
| } | ||
| throw new IllegalArgumentException("Unexpected value '" + value + "'"); | ||
| // handling unexpected value | ||
| LOG.warning( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gcatanese if this is not generated, rather than doing this per enum, it would be cleaner to make a generic
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see we are repeating this across all enums, so centralizing it in one class will help with maintainability and consistency longer-term
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would also remove the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore this, I see now the comment below 😁 |
||
| "Alignment: unexpected enum value '" | ||
| + value | ||
| + "' - Supported values are " | ||
| + Arrays.toString(Alignment.values())); | ||
| return null; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, but could we use String templating here using String.format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we could use
String.format(...)., but readability seems not to be an issue. However this change will involve updating the Mustache templates and regenerate all models. Still to be considerred? WDYT @thomasc-adyenThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore this, I see now the comment "Approach for centralizing unknown enum handling" 😁