Home | History | Annotate | Download | only in model
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.example.android.autofill.service.model;
     18 
     19 import android.arch.persistence.room.ColumnInfo;
     20 import android.arch.persistence.room.Entity;
     21 import android.support.annotation.NonNull;
     22 
     23 @Entity(primaryKeys = {"id"})
     24 public class AutofillDataset {
     25     @NonNull
     26     @ColumnInfo(name = "id")
     27     private final String mId;
     28 
     29     @NonNull
     30     @ColumnInfo(name = "datasetName")
     31     private final String mDatasetName;
     32 
     33     @NonNull
     34     @ColumnInfo(name = "packageName")
     35     private final String mPackageName;
     36 
     37     public AutofillDataset(@NonNull String id, @NonNull String datasetName,
     38                            @NonNull String packageName) {
     39         mId = id;
     40         mDatasetName = datasetName;
     41         mPackageName = packageName;
     42     }
     43 
     44     @NonNull
     45     public String getId() {
     46         return mId;
     47     }
     48 
     49     @NonNull
     50     public String getDatasetName() {
     51         return mDatasetName;
     52     }
     53 
     54     @NonNull
     55     public String getPackageName() {
     56         return mPackageName;
     57     }
     58 
     59     @Override
     60     public boolean equals(Object o) {
     61         if (this == o) return true;
     62         if (o == null || getClass() != o.getClass()) return false;
     63 
     64         AutofillDataset that = (AutofillDataset) o;
     65 
     66         if (!mId.equals(that.mId)) return false;
     67         if (!mDatasetName.equals(that.mDatasetName)) return false;
     68         return mPackageName.equals(that.mPackageName);
     69     }
     70 
     71     @Override
     72     public int hashCode() {
     73         int result = mId.hashCode();
     74         result = 31 * result + mDatasetName.hashCode();
     75         result = 31 * result + mPackageName.hashCode();
     76         return result;
     77     }
     78 }
     79