@@ -87,7 +87,7 @@ public Mapcode(
8787
8888 checkMapcodeCode ("code" , code );
8989 if (containsTerritory (code )) {
90- throw new IllegalArgumentException ("code cannot territory information : " + code );
90+ throw new IllegalArgumentException ("Must not contain territory : " + code );
9191 }
9292 final String codeUppercase = code .toUpperCase ();
9393 this .codePrecision2 = codeUppercase ;
@@ -140,6 +140,7 @@ public String getCode() {
140140 * @param precision Precision. Range: 0..2.
141141 * @param alphabet Alphabet.
142142 * @return Mapcode code.
143+ * @throws IllegalArgumentException Thrown if precision is out of range (must be in [0, 2]).
143144 */
144145 @ Nonnull
145146 public String getCode (final int precision , @ Nullable final Alphabet alphabet ) {
@@ -156,7 +157,7 @@ public String getCode(final int precision, @Nullable final Alphabet alphabet) {
156157 }
157158
158159 @ Nonnull
159- public String getCode (final int precision ) {
160+ public String getCode (final int precision ) throws IllegalArgumentException {
160161 return getCode (precision , null );
161162 }
162163
@@ -172,14 +173,15 @@ public String getCode(final int precision) {
172173 * @param precision Precision specifier. Range: [0, 2].
173174 * @param alphabet Alphabet.
174175 * @return Full international mapcode.
176+ * @throws IllegalArgumentException Thrown if precision is out of range (must be in [0, 2]).
175177 */
176178 @ Nonnull
177- public String getCodeWithTerritoryFullname (final int precision , @ Nullable final Alphabet alphabet ) {
179+ public String getCodeWithTerritoryFullname (final int precision , @ Nullable final Alphabet alphabet ) throws IllegalArgumentException {
178180 return territory .getFullName () + ' ' + getCode (precision , alphabet );
179181 }
180182
181183 @ Nonnull
182- public String getCodeWithTerritoryFullname (final int precision ) {
184+ public String getCodeWithTerritoryFullname (final int precision ) throws IllegalArgumentException {
183185 return getCodeWithTerritoryFullname (precision , null );
184186 }
185187
@@ -206,14 +208,15 @@ public String getCodeWithTerritoryFullname() {
206208 * @param precision Precision specifier. Range: [0, 2].
207209 * @param alphabet Alphabet.
208210 * @return Short-hand international mapcode.
211+ * @throws IllegalArgumentException Thrown if precision is out of range (must be in [0, 2]).
209212 */
210213 @ Nonnull
211- public String getCodeWithTerritory (final int precision , @ Nullable final Alphabet alphabet ) {
214+ public String getCodeWithTerritory (final int precision , @ Nullable final Alphabet alphabet ) throws IllegalArgumentException {
212215 return territory .toString () + ' ' + getCode (precision , alphabet );
213216 }
214217
215218 @ Nonnull
216- public String getCodeWithTerritory (final int precision ) {
219+ public String getCodeWithTerritory (final int precision ) throws IllegalArgumentException {
217220 return getCodeWithTerritory (precision , null );
218221 }
219222
@@ -389,12 +392,12 @@ static String convertMapcodeToPlainAscii(@Nonnull final String mapcode) {
389392 * @param mapcode Mapcode (optionally with a territory) to be converted.
390393 * @param alphabet Alphabet to convert to, may contain Unicode characters.
391394 * @return Converted mapcode.
392- * @throws IllegalArgumentException If mapcode has incorrect syntax.
395+ * @throws IllegalArgumentException Thrown if mapcode has incorrect syntax.
393396 */
394397 @ Nonnull
395398 static String convertMapcodeToAlphabet (@ Nonnull final String mapcode , @ Nullable final Alphabet alphabet ) throws IllegalArgumentException {
396399 checkMapcodeCode ("mapcode" , mapcode );
397- return (alphabet != null ) ? Decoder .encodeUTF16 (mapcode .toUpperCase (), alphabet .code ) : mapcode .toUpperCase ();
400+ return (alphabet != null ) ? Decoder .encodeUTF16 (mapcode .toUpperCase (), alphabet .getCode () ) : mapcode .toUpperCase ();
398401 }
399402
400403 /**
0 commit comments