@@ -580,11 +580,12 @@ public enum Territory {
580580 private final String [] fullNameAliases ;
581581
582582 /**
583- * Return the numeric territory code for a territory.
583+ * Return the numeric territory code for a territory. Package private, because territory numbers are no longer
584+ * exposed publicly.
584585 *
585586 * @return Integer territory code.
586587 */
587- public int getNumber () {
588+ int getNumber () {
588589 return number ;
589590 }
590591
@@ -629,14 +630,15 @@ public String[] getFullNameAliases() {
629630 }
630631
631632 /**
632- * Return the territory for a specific code.
633+ * Return the territory for a specific code. Package private, because territory numbers are no longer exposed
634+ * publicly.
633635 *
634636 * @param number Numeric territory code.
635637 * @return Territory.
636638 * @throws UnknownTerritoryException Thrown if incorrect numeric or alphanumeric code.
637639 */
638640 @ Nonnull
639- public static Territory fromNumber (final int number ) throws UnknownTerritoryException {
641+ static Territory fromNumber (final int number ) throws UnknownTerritoryException {
640642 if ((number < 0 ) || (number >= codeList .size ())) {
641643 throw new UnknownTerritoryException (number );
642644 }
@@ -656,32 +658,32 @@ public static Territory fromNumber(final int number) throws UnknownTerritoryExce
656658 *
657659 * Brazilian mapcodes, on the other hand, would be specified as "BRA BDHP.JK39-1D", using the ISO 3 letter code.
658660 *
659- * @param numericOrAlpha Territory, may be numeric or alphanumeric code.
661+ * @param alphaCode Territory, alphanumeric code.
660662 * @return Territory.
661663 * @throws UnknownTerritoryException Thrown if incorrect numeric or alphanumeric code.
662664 */
663665 @ Nonnull
664- public static Territory fromString (@ Nonnull final String numericOrAlpha ) throws UnknownTerritoryException {
665- checkNonnull ("numericOrAlpha " , numericOrAlpha );
666- return createFromString (numericOrAlpha , null );
666+ public static Territory fromString (@ Nonnull final String alphaCode ) throws UnknownTerritoryException {
667+ checkNonnull ("alphaCode " , alphaCode );
668+ return createFromString (alphaCode , null );
667669 }
668670
669671 /**
670672 * Get a territory from a name, specifying a parent territory for disambiguation.
671673 *
672- * @param numericOrAlpha Territory, may be numeric or alphanumeric code. See {@link #fromString(String)}
674+ * @param alphaCode Territory, alphanumeric code. See {@link #fromString(String)}
673675 * for an explanation of the format for this name. (This is NOT strictly an ISO code!)
674676 * @param parentTerritory Parent territory.
675677 * @return Territory.
676678 * @throws UnknownTerritoryException Thrown if the territory is not found given the parentTerritory.
677679 */
678680 @ Nonnull
679681 public static Territory fromString (
680- @ Nonnull final String numericOrAlpha ,
682+ @ Nonnull final String alphaCode ,
681683 @ Nonnull final ParentTerritory parentTerritory ) throws UnknownTerritoryException {
682- checkNonnull ("numericOrAlpha " , numericOrAlpha );
684+ checkNonnull ("alphaCode " , alphaCode );
683685 checkNonnull ("parentTerritory" , parentTerritory );
684- return createFromString (numericOrAlpha , parentTerritory );
686+ return createFromString (alphaCode , parentTerritory );
685687 }
686688
687689 /**
@@ -772,7 +774,7 @@ public boolean hasSubdivisions() {
772774 }
773775
774776 /**
775- * Local constructors to create a territory code.
777+ * Private constructors to create a territory code.
776778 */
777779 private Territory (
778780 final int number ,
@@ -869,26 +871,18 @@ private Territory(
869871 /**
870872 * Get a territory from a name, specifying a parent territory for disambiguation.
871873 *
872- * @param numericOrAlpha Territory name .
874+ * @param alphaCode Territory, alphanumeric code .
873875 * @param parentTerritory Parent territory.
874876 * @return Territory.
875877 * @throws UnknownTerritoryException Thrown if the territory is not found.
876878 */
877879 @ Nonnull
878880 private static Territory createFromString (
879- @ Nonnull final String numericOrAlpha ,
881+ @ Nonnull final String alphaCode ,
880882 @ Nullable final ParentTerritory parentTerritory ) throws UnknownTerritoryException {
881- final String trimmed = Mapcode .convertStringToPlainAscii (numericOrAlpha .trim ().replace ('_' , '-' )).toUpperCase ();
882-
883- // First, try as numeric code.
884- try {
885- final Integer territoryCode = Integer .valueOf (trimmed );
886- return fromNumber (territoryCode );
887- } catch (final NumberFormatException ignored ) {
888- // Re-try as alpha code.
889- }
883+ final String trimmed = Mapcode .convertStringToPlainAscii (alphaCode .trim ().replace ('_' , '-' )).toUpperCase ();
890884
891- // Now, try as alpha code.
885+ // Try as alpha code.
892886 final List <Territory > territories = nameMap .get (trimmed );
893887 if (territories != null ) {
894888 if (parentTerritory == null ) {
0 commit comments