Skip to content

Fix duplicate toUpperCase() calls, use Locale.ROOT #158

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
5 changes: 3 additions & 2 deletions java/com/google/openlocationcode/OpenLocationCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,12 @@ public double getEastLongitude() {
* @constructor
*/
public OpenLocationCode(String code) throws IllegalArgumentException {
if (!isValidCode(code.toUpperCase())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can get rid of the code.toUpperCase() here all together, since we're calling it inside of isValidCode().

Choose a reason for hiding this comment

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

since this is public, can we make that assumption and document it the constructor comments?

Copy link
Member

Choose a reason for hiding this comment

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

I don't understand your question here, can you rephrase? What assumption are you thinking we need to document?

String newCode = code.toUpperCase();
if (!isValidCode(newCode)) {
throw new IllegalArgumentException(
"The provided code '" + code + "' is not a valid Open Location Code.");
}
this.code = code.toUpperCase();
this.code = newCode;
}

/**
Expand Down