Region implements Serializable, Comparable<Region> { public static Region register(@NonNull String regionId, @NonNull final Realm realm) { return register(regionId, realm, null); } private  Region(
            @NonNull String regionId, @NonNull Optional<String> regionCode, @NonNull Realm realm); String getRegionCode(); Optional<String> getEndpoint(Service service); int compareTo(Region other); @Override // For backward compatibility maintain the enum toString behavior String toString(); static Region[] values(); static Region valueOf(@NonNull String name); static String formatDefaultRegionEndpoint(Service service, Region region); static String formatDefaultRegionEndpoint(Service service, String regionId); static Region fromRegionId(String regionId); static Region fromRegionCode(String regionCode); static Region fromRegionCodeOrId(String regionCodeOrId); static Region register(@NonNull String regionId, @NonNull final Realm realm); static Region register(
            @NonNull String regionId, @NonNull final Realm realm, String regionCode); static void setInstanceMetadataServiceClientConfig(ClientConfig clientConfig); static void enableInstanceMetadataService(); static void skipInstanceMetadataService(); static boolean registerFromInstanceMetadataService(); static final Region AP_CHUNCHEON_1; static final Region AP_MELBOURNE_1; static final Region AP_HYDERABAD_1; static final Region AP_MUMBAI_1; static final Region AP_OSAKA_1; static final Region AP_SEOUL_1; static final Region AP_SYDNEY_1; static final Region AP_TOKYO_1; static final Region CA_MONTREAL_1; static final Region CA_TORONTO_1; static final Region EU_AMSTERDAM_1; static final Region EU_FRANKFURT_1; static final Region EU_ZURICH_1; static final Region ME_JEDDAH_1; static final Region ME_DUBAI_1; static final Region SA_SAOPAULO_1; static final Region UK_LONDON_1; static final Region US_ASHBURN_1; static final Region US_PHOENIX_1; static final Region US_SANJOSE_1; static final Region US_LANGLEY_1; static final Region US_LUKE_1; static final Region US_GOV_ASHBURN_1; static final Region US_GOV_CHICAGO_1; static final Region US_GOV_PHOENIX_1; static final Region UK_GOV_LONDON_1; static final Region UK_GOV_CARDIFF_1; static final Region AP_CHIYODA_1; }
@Test public void serializeAndDeserialize() throws IOException, ClassNotFoundException { final File tempFile = File.createTempFile("test", ".data"); tempFile.deleteOnExit(); final FileOutputStream outputFile = new FileOutputStream(tempFile.getPath()); final ObjectOutputStream out = new ObjectOutputStream(outputFile); final Region unknownRegion = Region.register("foobar", Realm.OC1); out.writeObject(Region.US_PHOENIX_1); out.writeObject(unknownRegion); out.close(); outputFile.close(); final FileInputStream inputFile = new FileInputStream(tempFile.getPath()); final ObjectInputStream in = new ObjectInputStream(inputFile); final Region region1 = (Region) in.readObject(); final Region region2 = (Region) in.readObject(); in.close(); inputFile.close(); assertEquals(Region.US_PHOENIX_1, region1); assertEquals(unknownRegion, region2); }
@Test(expected = IllegalArgumentException.class) public void existingRegionsAreImmutable() { Region.register(Region.US_PHOENIX_1.getRegionId(), Realm.OC3); }
@Test(expected = IllegalArgumentException.class) public void newRegionsAreImmutable() { final String newRegionId = "us-foo-2"; Region.register(newRegionId, Realm.OC3); Region.register(newRegionId, Realm.OC2); }