Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package com.aliyun.openservices.shade.com.aliyun.openservices.shade.io.opentelemetry.api.internal;
import static com.aliyun.openservices.shade.com.aliyun.openservices.shade.io.opentelemetry.api.internal.Utils.checkArgument;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
/**
* An immutable set of key-value pairs.
*
*
Key-value pairs are dropped for {@code null} or empty keys.
*
*
Note: for subclasses of this, null keys will be removed, but if your key has another concept
* of being "empty", you'll need to remove them before calling the constructor, assuming you don't
* want the "empty" keys to be kept in your collection.
*
*
This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*
* @param The type of the values contained in this.
*/
@Immutable
public abstract class ImmutableKeyValuePairs {
private final Object[] data;
/**
* Stores the raw object data directly. Does not do any de-duping or sorting. If you use this
* constructor, you *must* guarantee that the data has been de-duped and sorted by key before it
* is passed here.
*/
protected ImmutableKeyValuePairs(Object[] data) {
this.data = data;
}
/**
* Sorts and dedupes the key/value pairs in {@code data}. {@code null} values will be removed.
* Keys will be compared with the given {@link Comparator}.
*/
protected ImmutableKeyValuePairs(Object[] data, Comparator> keyComparator) {
this(sortAndFilter(data, keyComparator));
}
// TODO: Improve this to avoid one allocation, for the moment only some Builders and the asMap
// calls this.
protected final List