1 /* 2 * Copyright (C) 2022 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 android.processor.immutability 18 19 object MessageUtils { 20 classNotImmutableFailurenull21 fun classNotImmutableFailure(className: String) = "$className should be marked @Immutable" 22 23 fun classNotFinalFailure(className: String) = "$className should be marked final" 24 25 fun memberNotMethodFailure() = "Member must be a method" 26 27 fun nonInterfaceClassFailure() = "Class was not an interface" 28 29 fun nonInterfaceReturnFailure(prefix: String, index: Int = -1) = 30 if (prefix.isEmpty()) { 31 "Type at index $index was not an interface" 32 } else { 33 "$prefix was not an interface" 34 } 35 genericTypeKindFailurenull36 fun genericTypeKindFailure(typeName: CharSequence) = "TypeKind $typeName unsupported" 37 38 fun arrayFailure() = "Array types are not supported as they can be mutated by callers" 39 40 fun nonInterfaceReturnFailure() = "Must return an interface" 41 42 fun voidReturnFailure() = "Cannot return void" 43 44 fun staticNonFinalFailure() = "Static member must be final" 45 }