1 /* <lambda>null2 * 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 androidx.room.vo 18 19 /** 20 * A common value object when we need to associate a Field with an Index 21 * variable. 22 * <p> 23 * If we are sure that the field will be there at compile time, we set it to always Exists so that 24 * the generated code does not check for -1 column indices. 25 */ 26 data class FieldWithIndex(val field: Field, val indexVar: String, val alwaysExists: Boolean) { 27 companion object { 28 fun byOrder(fields: List<Field>): List<FieldWithIndex> { 29 return fields.mapIndexed { index, field -> 30 FieldWithIndex(field = field, 31 indexVar = "${index + 1}", 32 alwaysExists = true) 33 } 34 } 35 } 36 } 37