You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2019/01/11 08:24:51 UTC
[myfaces-tobago] 03/03: optimize code
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
commit 4e60324199bd3764d1fa7a623cbb73be301e1ebe
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Thu Jan 10 17:37:55 2019 +0100
optimize code
---
.../tobago/example/demo/GroupController.java | 25 +++++++++++++---------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/GroupController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/GroupController.java
index cf6e971..92d7ac7 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/GroupController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/GroupController.java
@@ -103,16 +103,21 @@ public class GroupController implements Serializable {
}
private void compute() {
- if (currency.getCurrencyCode().equals("JPY")) {
- valueInEuro = value * 0.00884806667;
- } else if (currency.getCurrencyCode().equals("TTD")) {
- valueInEuro = value * 0.133748824;
- } else if (currency.getCurrencyCode().equals("USD")) {
- valueInEuro = value * 0.896097495;
- } else if (currency.getCurrencyCode().equals("EUR")) {
- valueInEuro = value;
- } else {
- valueInEuro = 0;
+ switch (currency.getCurrencyCode()) {
+ case "JPY":
+ valueInEuro = value * 0.00884806667;
+ break;
+ case "TTD":
+ valueInEuro = value * 0.133748824;
+ break;
+ case "USD":
+ valueInEuro = value * 0.896097495;
+ break;
+ case "EUR":
+ valueInEuro = value;
+ break;
+ default:
+ throw new RuntimeException("Unsupported Currency: '" + currency.getCurrencyCode() + "'");
}
LOG.info("euro value: '{}', value: '{}', currency: '{}'", valueInEuro, value, currency.getCurrencyCode());
}