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.Embedded; 20 import android.arch.persistence.room.Relation; 21 22 import java.util.ArrayList; 23 import java.util.List; 24 25 public class DatasetWithFilledAutofillFields { 26 @Embedded 27 public AutofillDataset autofillDataset; 28 29 @Relation(parentColumn = "id", entityColumn = "datasetId", entity = FilledAutofillField.class) 30 public List<FilledAutofillField> filledAutofillFields; 31 add(FilledAutofillField filledAutofillField)32 public void add(FilledAutofillField filledAutofillField) { 33 if (filledAutofillFields == null) { 34 this.filledAutofillFields = new ArrayList<>(); 35 } 36 this.filledAutofillFields.add(filledAutofillField); 37 } 38 39 @Override equals(Object o)40 public boolean equals(Object o) { 41 if (this == o) return true; 42 if (o == null || getClass() != o.getClass()) return false; 43 44 DatasetWithFilledAutofillFields that = (DatasetWithFilledAutofillFields) o; 45 46 if (autofillDataset != null ? !autofillDataset.equals(that.autofillDataset) : 47 that.autofillDataset != null) 48 return false; 49 return filledAutofillFields != null ? 50 filledAutofillFields.equals(that.filledAutofillFields) : 51 that.filledAutofillFields == null; 52 } 53 54 @Override hashCode()55 public int hashCode() { 56 int result = autofillDataset != null ? autofillDataset.hashCode() : 0; 57 result = 31 * result + (filledAutofillFields != null ? filledAutofillFields.hashCode() : 0); 58 return result; 59 } 60 } 61