public abstract class

MapParamsEntity

extends java.lang.Object

 java.lang.Object

↳androidx.core.location.altitude.impl.db.MapParamsEntity

Gradle dependencies

compile group: 'androidx.core', name: 'core-location-altitude', version: '1.0.0-alpha02'

  • groupId: androidx.core
  • artifactId: core-location-altitude
  • version: 1.0.0-alpha02

Artifact androidx.core:core-location-altitude:1.0.0-alpha02 it located at Google repository (https://maven.google.com/)

Overview

Defines the entity type and its converters within the MapParams table.

Summary

Constructors
publicMapParamsEntity()

Methods
public static byte[]fromValue(MapParamsProto value)

Encodes a MapParamsProto

public static MapParamsPrototoValue(byte[] byteArray[])

Decodes a MapParamsProto

public abstract MapParamsProtovalue()

Returns parameters for a spherically projected geoid map and corresponding tile management.

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

Constructors

public MapParamsEntity()

Methods

public static byte[] fromValue(MapParamsProto value)

Encodes a MapParamsProto

public static MapParamsProto toValue(byte[] byteArray[])

Decodes a MapParamsProto

public abstract MapParamsProto value()

Returns parameters for a spherically projected geoid map and corresponding tile management.

Source

/*
 * Copyright 2022 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.core.location.altitude.impl.db;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.location.altitude.impl.proto.InvalidProtocolBufferException;
import androidx.core.location.altitude.impl.proto.MapParamsProto;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import androidx.room.TypeConverter;

import com.google.auto.value.AutoValue;
import com.google.auto.value.AutoValue.CopyAnnotations;

import org.jetbrains.annotations.Contract;

/** Defines the entity type and its converters within the MapParams table. */
@AutoValue
@Entity(tableName = "MapParams")
public abstract class MapParamsEntity {

    private static final String TAG = "MapParamsEntity";

    @NonNull
    @Contract("_, _ -> new")
    static MapParamsEntity create(int id, MapParamsProto value) {
        return new AutoValue_MapParamsEntity(id, value);
    }

    /** Encodes a {@link MapParamsProto} */
    @NonNull
    @TypeConverter
    public static byte[] fromValue(@NonNull MapParamsProto value) {
        return value.toByteArray();
    }

    /** Decodes a {@link MapParamsProto} */
    @Nullable
    @TypeConverter
    public static MapParamsProto toValue(@NonNull byte[] byteArray) {
        try {
            return MapParamsProto.parseFrom(byteArray);
        } catch (InvalidProtocolBufferException e) {
            Log.e(TAG, "Unable to parse map params.");
            return null;
        }
    }

    @CopyAnnotations
    @PrimaryKey
    @ColumnInfo(name = "id")
    abstract int id();

    /**
     * Returns parameters for a spherically projected geoid map and corresponding tile management.
     */
    @CopyAnnotations
    @ColumnInfo(name = "value")
    @NonNull
    public abstract MapParamsProto value();
}