Skip to content

Conversation

FridaTveit
Copy link
Contributor

…to enum.

@coveralls
Copy link

coveralls commented Dec 20, 2016

Coverage Status

Coverage decreased (-0.06%) to 12.185% when pulling 3dafd07 on FridaTveit:AddEnumForSyntaxAnalysisModeInParser into 02a9224 on oskopek:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 12.54% when pulling 1044ce4 on FridaTveit:AddEnumForSyntaxAnalysisModeInParser into 02a9224 on oskopek:master.

1 similar comment
@coveralls
Copy link

coveralls commented Dec 21, 2016

Coverage Status

Coverage increased (+0.3%) to 12.54% when pulling 1044ce4 on FridaTveit:AddEnumForSyntaxAnalysisModeInParser into 02a9224 on oskopek:master.

Copy link
Owner

@oskopek oskopek left a comment

Choose a reason for hiding this comment

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

Left a few comments for you in the review. Great work :)

}
}

public enum SyntaxAnalysisMode {
Copy link
Owner

Choose a reason for hiding this comment

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

Lets pull this out into a separate file. Also, you can put the getSyntaxAnalysisModeFromInt method into the enum itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

EQUAL_OR_SHORTER_LENGTH
}

public static SyntaxAnalysisMode getSyntaxAnalysisModeFromInt(int syntaxAnalysisModeInt) {
Copy link
Owner

Choose a reason for hiding this comment

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

Note: once this function is in the enum, we could implement it as:

if (syntaxAnalysisModeInt < 0 || syntaxAnalysisModeInt >= values().length) {
    throw new IllegalArgumentException("Expected: 0, 1, or 2. Got: " + syntaxAnalysisModeInt);
} else {
    return values()[syntaxAnalysisModeInt];
}

However, I like you implementation better, as it might be easier to read in the long run, so I suggest we keep it as it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay :)


import static org.junit.Assert.assertEquals;

public class ParserTest {
Copy link
Owner

Choose a reason for hiding this comment

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

Reminder: Rename this test once the enum is in its own file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

return recognizedPlate.getString();
}

public String parse(RecognizedPlate recognizedPlate, SyntaxAnalysisMode syntaxAnalysisMode) {
Copy link
Owner

Choose a reason for hiding this comment

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

This changes one of the methods in the "public API" (there is no such thing currently, but I suspect people use the method in their code). We should be able to do this change for the next major release, but we should document it somehow. I added the following file: docs/upgradeRecipes/upgradeRecipe-2.0.0.adoc. It will be of great help to all users if they wish to upgrade in the future.

Just add something along the lines of

=== `Parser.parse` method parameters

The method `String Parser.parse(RecognizedPlate, int)` changed to
`String Parser.parse(RecognizedPlate, SyntaxAnalysisMode)`.

Workaround: `parse(plate, syntaxAnalysisModeInt)`
-> `parse(plate, SyntaxAnalysisMode.getSyntaxAnalysisModeFromInt(syntaxAnalysisModeInt))`

To the "Minor API changes" part of that file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

…for the change to Parser.parse. Pulled SyntaxAnalysisMode into its own file and moved getSyntaxAnalysisModeFromInt into this file. Renamed ParserTest to SyntaxAnalysisModeTest to reflect this change.
@FridaTveit FridaTveit force-pushed the AddEnumForSyntaxAnalysisModeInParser branch from 1044ce4 to 9feccd2 Compare December 21, 2016 22:00
@coveralls
Copy link

coveralls commented Dec 21, 2016

Coverage Status

Coverage increased (+0.3%) to 13.716% when pulling 9feccd2 on FridaTveit:AddEnumForSyntaxAnalysisModeInParser into b80b810 on oskopek:master.

Copy link
Owner

@oskopek oskopek left a comment

Choose a reason for hiding this comment

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

Thanks a lot! :)

@oskopek oskopek merged commit 550890a into oskopek:master Dec 21, 2016
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