1a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar/*
2a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar * Copyright (C) 2017 The Android Open Source Project
3a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar *
4a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar * Licensed under the Apache License, Version 2.0 (the "License");
5a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar * you may not use this file except in compliance with the License.
6a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar * You may obtain a copy of the License at
7a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar *
8a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar *      http://www.apache.org/licenses/LICENSE-2.0
9a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar *
10a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar * Unless required by applicable law or agreed to in writing, software
11a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar * distributed under the License is distributed on an "AS IS" BASIS,
12a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar * See the License for the specific language governing permissions and
14a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar * limitations under the License.
15a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar */
16a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar
17bdc4c86d3dff74f6634a38e2f7b316b0e823a2c8Alan Viverettepackage androidx.room.migration.bundle;
18a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar
19bdc4c86d3dff74f6634a38e2f7b316b0e823a2c8Alan Viveretteimport androidx.annotation.RestrictTo;
20a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar
21a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyarimport com.google.gson.annotations.SerializedName;
22a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar
23a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyarimport java.util.List;
24a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar
25a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar/**
26a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar * Data class that holds the schema information about a primary key.
27a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar *
28a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar * @hide
29a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar */
30a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
31e5ed537fe6f14f0bbb43ddef605ed22f09714142Yigit Boyarpublic class PrimaryKeyBundle implements SchemaEquality<PrimaryKeyBundle> {
32a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar    @SerializedName("columnNames")
33a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar    private List<String> mColumnNames;
34a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar    @SerializedName("autoGenerate")
35a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar    private boolean mAutoGenerate;
36a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar
37a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar    public PrimaryKeyBundle(boolean autoGenerate, List<String> columnNames) {
38a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar        mColumnNames = columnNames;
39a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar        mAutoGenerate = autoGenerate;
40a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar    }
41a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar
42a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar    public List<String> getColumnNames() {
43a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar        return mColumnNames;
44a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar    }
45a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar
46a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar    public boolean isAutoGenerate() {
47a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar        return mAutoGenerate;
48a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar    }
49e5ed537fe6f14f0bbb43ddef605ed22f09714142Yigit Boyar
50e5ed537fe6f14f0bbb43ddef605ed22f09714142Yigit Boyar    @Override
51e5ed537fe6f14f0bbb43ddef605ed22f09714142Yigit Boyar    public boolean isSchemaEqual(PrimaryKeyBundle other) {
52e5ed537fe6f14f0bbb43ddef605ed22f09714142Yigit Boyar        return mColumnNames.equals(other.mColumnNames) && mAutoGenerate == other.mAutoGenerate;
53e5ed537fe6f14f0bbb43ddef605ed22f09714142Yigit Boyar    }
54a64756a18111a7312b3fa03b76d13381a8907176Yigit Boyar}
55