Skip to content
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