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

software.amazon.awssdk.codegen.internal.DefaultProtocolMetadataConstants Maven / Gradle / Ivy

/*
 * Copyright 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 software.amazon.awssdk.codegen.internal;

import java.util.AbstractMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import software.amazon.awssdk.protocols.core.OperationMetadataAttribute;
import software.amazon.awssdk.utils.AttributeMap;

/**
 * Default implementation of {@link ProtocolMetadataConstants}.
 */
public final class DefaultProtocolMetadataConstants implements ProtocolMetadataConstants {
    private final Set, OperationMetadataAttribute>> knownKeys = new LinkedHashSet<>();
    private final AttributeMap.Builder map = AttributeMap.builder();

    @Override
    public List, OperationMetadataAttribute>> keys() {
        return knownKeys.stream().filter(x -> map.get(x.getValue()) != null).collect(Collectors.toList());
    }

    @Override
    public  T put(Class containingClass, OperationMetadataAttribute key, T value) {
        knownKeys.add(new AbstractMap.SimpleEntry<>(containingClass, key));
        T oldValue = map.get(key);
        map.put(key, value);
        return oldValue;
    }

    @Override
    public  T get(OperationMetadataAttribute key) {
        return map.get(key);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy