-
Notifications
You must be signed in to change notification settings - Fork 493
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
https://github.com/thymeleaf/thymeleaf/issues/112#issuecomment-193490091 #496
base: 3.0-dev
Are you sure you want to change the base?
Conversation
commit: added Switch Case expression and its helping classes
public final class Case implements Serializable { | ||
|
||
|
||
/** |
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.
remove empty documentation
private final IStandardExpression caseExprValue; | ||
|
||
Case(final IStandardExpression caseExpr, final IStandardExpression caseExprValue) { | ||
super(); |
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.
super is called automatically so it can be removed
private final List<Case> cases; | ||
|
||
CaseSequence(final List<Case> cases) { | ||
super(); |
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.
super() can be removed since it's called automatically
public class CaseSequence implements Iterable<Case>, Serializable { | ||
|
||
|
||
/** |
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.
remove empty documentation since it doesn't add value
final String switchStr = input.substring(0, operatorPos).trim(); | ||
final String remainder = input.substring(operatorPos + 1).trim(); | ||
|
||
// Check the switch condition and fail quickly if it is not valid |
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.
this comment is useless as the code speaks for itself :)
return null; | ||
} | ||
|
||
// Trying to fail quickly... |
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.
this comment is useless as the code speaks for itself :)
Object defaultCase = null; | ||
|
||
// compare each case 'key' with switch variable | ||
// if the switch variable matches on of the cases, return its value |
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.
this comment is useless as the code speaks for itself :)
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.
@vborcea you are obviously free to comment on any code on GitHub, but I'd appreciate if you please don't use that kind of language.
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.
@danielfernandez Sorry, I didn't wanted to harm no one. :). What I wanted to say was that the code speaks for itself so adding extra comment on a nice written code is useless. I didn't wanted to be a jerk at all.
/* | ||
* ============================================================================= | ||
* | ||
* Copyright (c) 2011-2016, The THYMELEAF team (http://www.thymeleaf.org) |
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.
Copyright (c) 2011-2017
/* | ||
* ============================================================================= | ||
* | ||
* Copyright (c) 2011-2016, The THYMELEAF team (http://www.thymeleaf.org) |
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.
Copyright (c) 2011-2017
/* | ||
* ============================================================================= | ||
* | ||
* Copyright (c) 2011-2016, The THYMELEAF team (http://www.thymeleaf.org) |
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.
Copyright (c) 2011-2016
// remainder string should represent the case sequence | ||
// condition: at least 1 case should exist | ||
|
||
CaseSequence sequence = CaseUtils.composeSequence(remainder); |
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.
final ;)
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.
Taking into consideration that business is added some unit tests would be very helpful
commit: added Switch Case expression and its helping classes