public final class

PlatformDataValues

extends java.lang.Object

 java.lang.Object

↳androidx.wear.protolayout.expression.PlatformDataValues

Gradle dependencies

compile group: 'androidx.wear.protolayout', name: 'protolayout-expression', version: '1.2.0'

  • groupId: androidx.wear.protolayout
  • artifactId: protolayout-expression
  • version: 1.2.0

Artifact androidx.wear.protolayout:protolayout-expression:1.2.0 it located at Google repository (https://maven.google.com/)

Overview

Typed mapping of PlatformDataKey to DynamicDataBuilders.DynamicDataValue.

Summary

Methods
public java.util.Map<PlatformDataKey, DynamicDataBuilders.DynamicDataValue>getAll()

Returns the key-value mapping.

public static PlatformDataValuesof(PlatformDataKey<DynamicBuilders.DynamicType> key, DynamicDataBuilders.DynamicDataValue<DynamicBuilders.DynamicType> value)

Creates a PlatformDataValues from a single key/value pair.

public java.lang.StringtoString()

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Methods

public static PlatformDataValues of(PlatformDataKey<DynamicBuilders.DynamicType> key, DynamicDataBuilders.DynamicDataValue<DynamicBuilders.DynamicType> value)

Creates a PlatformDataValues from a single key/value pair.

public java.util.Map<PlatformDataKey, DynamicDataBuilders.DynamicDataValue> getAll()

Returns the key-value mapping.

public java.lang.String toString()

Source

/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License 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 androidx.wear.protolayout.expression;

import static java.util.Collections.unmodifiableMap;

import androidx.annotation.NonNull;
import androidx.collection.ArrayMap;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicType;
import androidx.wear.protolayout.expression.DynamicDataBuilders.DynamicDataValue;

import java.util.Map;

/** Typed mapping of {@link PlatformDataKey} to {@link DynamicDataValue}. */
public final class PlatformDataValues {
    @NonNull final Map<PlatformDataKey<?>, DynamicDataValue<?>> data;

    /** Builder for {@link PlatformDataValues}. */
    public static final class Builder {
        @NonNull final Map<PlatformDataKey<?>, DynamicDataValue<?>> data = new ArrayMap<>();

        /** Puts a key/value pair. */
        @NonNull
        @SuppressWarnings("BuilderSetStyle") // Map-style builder, getter is generic get().
        public <T extends DynamicType> Builder put(
                @NonNull PlatformDataKey<T> key, @NonNull DynamicDataValue<T> value) {
            data.put(key, value);
            return this;
        }

        /**
         * Puts all values from another {@link PlatformDataValues}.
         *
         * <p>Values not in {@code other} are not removed from this {@link Builder}.
         */
        @NonNull
        @SuppressWarnings("BuilderSetStyle") // Map-style builder, getter is generic get().
        public Builder putAll(@NonNull PlatformDataValues other) {
            data.putAll(other.data);
            return this;
        }

        /** Builds the {@link PlatformDataValues}. */
        @NonNull
        public PlatformDataValues build() {
            return new PlatformDataValues(unmodifiableMap(data));
        }
    }

    /** Creates a {@link PlatformDataValues} from a single key/value pair. */
    @NonNull
    public static <T extends DynamicType> PlatformDataValues of(
            @NonNull PlatformDataKey<T> key, @NonNull DynamicDataValue<T> value) {
        return new PlatformDataValues(Map.of(key, value));
    }

    PlatformDataValues(@NonNull Map<PlatformDataKey<?>, DynamicDataValue<?>> data) {
        this.data = data;
    }

    /** Returns the key-value mapping. */
    @NonNull
    public Map<PlatformDataKey<?>, DynamicDataValue<?>> getAll() {
        return unmodifiableMap(data);
    }

    @Override
    @NonNull
    public String toString() {
        return String.format("PlatformDataValues{%s}", data);
    }
}