public class

DatabaseViewBundle

extends java.lang.Object

implements androidx.room.migration.bundle.SchemaEquality<DatabaseViewBundle>

 java.lang.Object

↳androidx.room.migration.bundle.DatabaseViewBundle

Overview

Data class that holds the schema information about a DatabaseView.

Summary

Constructors
publicDatabaseViewBundle(java.lang.String viewName, java.lang.String createSql)

Methods
public java.lang.StringcreateView()

public java.lang.StringgetCreateSql()

public java.lang.StringgetViewName()

public booleanisSchemaEqual(DatabaseViewBundle other)

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

Constructors

public DatabaseViewBundle(java.lang.String viewName, java.lang.String createSql)

Methods

public java.lang.String getViewName()

Returns:

The name of this view.

public java.lang.String getCreateSql()

Returns:

Create view SQL query.

public java.lang.String createView()

Returns:

Create view SQL query that uses the actual view name.

public boolean isSchemaEqual(DatabaseViewBundle other)

Source

/*
 * Copyright 2018 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.room.migration.bundle;

import androidx.annotation.RestrictTo;

import com.google.gson.annotations.SerializedName;

/**
 * Data class that holds the schema information about a
 * {@link androidx.room.DatabaseView DatabaseView}.
 *
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
public class DatabaseViewBundle implements SchemaEquality<DatabaseViewBundle> {

    @SerializedName("viewName")
    private String mViewName;
    @SerializedName("createSql")
    private String mCreateSql;

    public DatabaseViewBundle(String viewName, String createSql) {
        mViewName = viewName;
        mCreateSql = createSql;
    }

    /**
     * @return The name of this view.
     */
    public String getViewName() {
        return mViewName;
    }

    /**
     * @return Create view SQL query.
     */
    public String getCreateSql() {
        return mCreateSql;
    }

    /**
     * @return Create view SQL query that uses the actual view name.
     */
    public String createView() {
        return BundleUtil.replaceViewName(mCreateSql, getViewName());
    }

    @Override
    public boolean isSchemaEqual(DatabaseViewBundle other) {
        return mViewName != null && mViewName.equals(other.mViewName)
                && mCreateSql != null && mCreateSql.equals(other.mCreateSql);
    }
}