ProcessorErrors.kt revision 0f77cff2005ccc6263b9902b3ea56fe01161ba51
119b41105359a52aeb80070dec40247241231f05dYigit Boyar/* 219b41105359a52aeb80070dec40247241231f05dYigit Boyar * Copyright (C) 2016 The Android Open Source Project 319b41105359a52aeb80070dec40247241231f05dYigit Boyar * 419b41105359a52aeb80070dec40247241231f05dYigit Boyar * Licensed under the Apache License, Version 2.0 (the "License"); 519b41105359a52aeb80070dec40247241231f05dYigit Boyar * you may not use this file except in compliance with the License. 619b41105359a52aeb80070dec40247241231f05dYigit Boyar * You may obtain a copy of the License at 719b41105359a52aeb80070dec40247241231f05dYigit Boyar * 819b41105359a52aeb80070dec40247241231f05dYigit Boyar * http://www.apache.org/licenses/LICENSE-2.0 919b41105359a52aeb80070dec40247241231f05dYigit Boyar * 1019b41105359a52aeb80070dec40247241231f05dYigit Boyar * Unless required by applicable law or agreed to in writing, software 1119b41105359a52aeb80070dec40247241231f05dYigit Boyar * distributed under the License is distributed on an "AS IS" BASIS, 1219b41105359a52aeb80070dec40247241231f05dYigit Boyar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1319b41105359a52aeb80070dec40247241231f05dYigit Boyar * See the License for the specific language governing permissions and 1419b41105359a52aeb80070dec40247241231f05dYigit Boyar * limitations under the License. 1519b41105359a52aeb80070dec40247241231f05dYigit Boyar */ 1619b41105359a52aeb80070dec40247241231f05dYigit Boyar 1719b41105359a52aeb80070dec40247241231f05dYigit Boyarpackage com.android.support.room.processor 1819b41105359a52aeb80070dec40247241231f05dYigit Boyar 1919b41105359a52aeb80070dec40247241231f05dYigit Boyarimport com.android.support.room.Query 201600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyarimport com.android.support.room.vo.Field 2119b41105359a52aeb80070dec40247241231f05dYigit Boyar 2219b41105359a52aeb80070dec40247241231f05dYigit Boyarobject ProcessorErrors { 2319b41105359a52aeb80070dec40247241231f05dYigit Boyar val MISSING_QUERY_ANNOTATION = "Query methods must be annotated with ${Query::class.java}" 2419b41105359a52aeb80070dec40247241231f05dYigit Boyar val CANNOT_RESOLVE_RETURN_TYPE = "Cannot resolve return type for %s" 2519b41105359a52aeb80070dec40247241231f05dYigit Boyar val CANNOT_USE_UNBOUND_GENERICS_IN_QUERY_METHODS = "Cannot use unbound generics in query " + 260f77cff2005ccc6263b9902b3ea56fe01161ba51Yigit Boyar "queryMethods. It must be bound to a type through base Dao class." 27de33ce4068e2678c03fa6fd62f4770be89f79adcYigit Boyar val CANNOT_USE_UNBOUND_GENERICS_IN_ENTITY_FIELDS = "Cannot use unbound fields in entities." 280f77cff2005ccc6263b9902b3ea56fe01161ba51Yigit Boyar val CANNOT_USE_UNBOUND_GENERICS_IN_DAO_CLASSES = "Cannot use unbound generics in Dao classes." + 290f77cff2005ccc6263b9902b3ea56fe01161ba51Yigit Boyar " If you are trying to create a base DAO, create a normal class, extend it with type" + 300f77cff2005ccc6263b9902b3ea56fe01161ba51Yigit Boyar " params then mark the subclass with @Dao." 311600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar val CANNOT_FIND_GETTER_FOR_FIELD = "Cannot find getter for field." 321600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar val CANNOT_FIND_SETTER_FOR_FIELD = "Cannot find setter for field." 33e6325fbeaa2e6759496ea2ca9a4d3d958df690d7Yigit Boyar val MISSING_PRIMARY_KEY = "An entity must have at least 1 field annotated with @PrimaryKey" 340f77cff2005ccc6263b9902b3ea56fe01161ba51Yigit Boyar val DAO_MUST_BE_AN_ABSTRACT_CLASS_OR_AN_INTERFACE = "Dao class must be an abstract class or" + 350f77cff2005ccc6263b9902b3ea56fe01161ba51Yigit Boyar " an interface" 36e6325fbeaa2e6759496ea2ca9a4d3d958df690d7Yigit Boyar 371600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar private val TOO_MANY_MATCHING_GETTERS = "Ambiguous getter for %s. All of the following " + 381600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar "match: %s. You can @Ignore the ones that you don't want to match." 391600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar private val TOO_MANY_MATCHING_SETTERS = "Ambiguous setter for %s. All of the following " + 401600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar "match: %s. You can @Ignore the ones that you don't want to match." 411600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar 420f77cff2005ccc6263b9902b3ea56fe01161ba51Yigit Boyar val DAO_MUST_BE_ANNOTATED_WITH_DAO = "Dao class must be annoated with @Dao" 430f77cff2005ccc6263b9902b3ea56fe01161ba51Yigit Boyar 441600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar fun tooManyMatchingGetters(field : Field, methodNames : List<String>) : String { 451600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar return TOO_MANY_MATCHING_GETTERS.format(field, methodNames.joinToString(", ")) 461600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar } 471600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar 481600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar fun tooManyMatchingSetter(field: Field, methodNames: List<String>) : String { 491600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar return TOO_MANY_MATCHING_SETTERS.format(field, methodNames.joinToString(", ")) 501600cc11df868b62b6ae3995d94a3ec0b86559adYigit Boyar } 5119b41105359a52aeb80070dec40247241231f05dYigit Boyar} 52