All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.amazonaws.regions.InMemoryRegionImpl Maven / Gradle / Ivy

Go to download

The AWS SDK for Java with support for OSGi. The AWS SDK for Java provides Java APIs for building software on AWS' cost-effective, scalable, and reliable infrastructure products. The AWS Java SDK allows developers to code against APIs for all of Amazon's infrastructure web services (Amazon S3, Amazon EC2, Amazon SQS, Amazon Relational Database Service, Amazon AutoScaling, etc).

There is a newer version: 1.11.60
Show newest version
/*
 * Copyright 2016-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.amazonaws.regions;

import com.amazonaws.util.ValidationUtils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * An implementation of {@link RegionImpl} that holds all information in memory.
 */
public class InMemoryRegionImpl implements RegionImpl {

    private static final String DEFAULT_DOMAIN = "amazonaws.com";

    private final String name;

    private final String domain;

    private final Map endpoints = new HashMap();

    private final List https = new ArrayList();

    private final List http = new ArrayList();

    public InMemoryRegionImpl(String name, String domain) {
        ValidationUtils.assertNotNull(name, "region name");
        this.name = name;
        this.domain = domain == null ? DEFAULT_DOMAIN : domain;
    }

    public InMemoryRegionImpl addEndpoint(String serviceName, String endpoint) {
        ValidationUtils.assertNotNull(serviceName, "service name");
        ValidationUtils.assertNotNull(endpoint, "endpoint");

        endpoints.put(serviceName, endpoint);
        return this;
    }

    public InMemoryRegionImpl addHttps(String serviceName) {
        https.add(serviceName);
        return this;
    }

    public InMemoryRegionImpl addHttp(String serviceName) {
        http.add(serviceName);
        return this;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public String getDomain() {
        return domain;
    }

    @Override
    public String getPartition() {
        throw new UnsupportedOperationException("Partition is not available in the in memory implementation");
    }

    @Override
    public boolean isServiceSupported(String serviceName) {
        return endpoints.containsKey(serviceName);
    }

    @Override
    public String getServiceEndpoint(String serviceName) {
        return endpoints.get(serviceName);
    }

    @Override
    public boolean hasHttpsEndpoint(String serviceName) {
        return https.contains(serviceName);
    }

    @Override
    public boolean hasHttpEndpoint(String serviceName) {
        return http.contains(serviceName);
    }

    @Override
    public Collection getAvailableEndpoints() {
        return Collections.unmodifiableCollection(endpoints.values());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy