E164CountryCodeUtil { public static E164CountryCode lookup(String address) { int len = (address.length() > maxPrefixLength ? maxPrefixLength : address.length()); for (int i = len; i > 0; i--) { String prefix = address.substring(0, i); E164CountryCode entry = byPrefix.get(prefix); if (entry != null) { return entry; } } return null; } private  E164CountryCodeUtil(); static E164CountryCode lookup(String address); static HashMap<String,E164CountryCode> parse(InputStream is);  }
@Test public void lookup() throws Exception { E164CountryCode result0 = E164CountryCodeUtil.lookup("1"); Assert.assertEquals("US", result0.getIso()); result0 = E164CountryCodeUtil.lookup("1313"); Assert.assertEquals("US", result0.getIso()); result0 = E164CountryCodeUtil.lookup(""); Assert.assertEquals(null, result0); result0 = E164CountryCodeUtil.lookup("1416"); Assert.assertEquals("CA", result0.getIso()); result0 = E164CountryCodeUtil.lookup("18765551212"); Assert.assertEquals("JM", result0.getIso()); result0 = E164CountryCodeUtil.lookup("448765551212"); Assert.assertEquals("GB", result0.getIso()); }