
software.amazon.awssdk.internal.http.LowCopyListMap 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.internal.http;
import static software.amazon.awssdk.utils.CollectionUtils.deepCopyMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Supplier;
import software.amazon.awssdk.annotations.NotThreadSafe;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.annotations.ThreadSafe;
import software.amazon.awssdk.http.SdkHttpRequest;
import software.amazon.awssdk.http.SdkHttpResponse;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Lazy;
/**
* A {@code Map>} for headers and query strings in {@link SdkHttpRequest} and {@link SdkHttpResponse} that
* avoids copying data during conversion between builders and buildables, unless data is modified.
*
* This is created via {@link #emptyHeaders()} or {@link #emptyQueryParameters()}.
*/
@SdkInternalApi
public final class LowCopyListMap {
private LowCopyListMap() {
}
/**
* Create an empty {@link LowCopyListMap.ForBuilder} for header storage.
*/
public static LowCopyListMap.ForBuilder emptyHeaders() {
return new LowCopyListMap.ForBuilder(() -> new TreeMap<>(String.CASE_INSENSITIVE_ORDER));
}
/**
* Create an empty {@link LowCopyListMap.ForBuilder} for query parameter storage.
*/
public static LowCopyListMap.ForBuilder emptyQueryParameters() {
return new LowCopyListMap.ForBuilder(LinkedHashMap::new);
}
@NotThreadSafe
public static final class ForBuilder {
/**
* The constructor that can be used to create new, empty maps.
*/
private final Supplier
© 2015 - 2025 Weber Informatics LLC | Privacy Policy