Skip to content

Conversation

@sukhokri
Copy link

commit: added Switch Case expression and its helping classes

commit: added Switch Case expression and its helping classes
public final class Case implements Serializable {


/**
Copy link

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();
Copy link

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();
Copy link

@vborcea vborcea Feb 12, 2017

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 {


/**
Copy link

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
Copy link

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...
Copy link

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
Copy link

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 :)

Copy link
Member

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.

Copy link

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)
Copy link

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)
Copy link

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)
Copy link

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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final ;)

Copy link

@vborcea vborcea left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants