1 /* 2 * Copyright 2024 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 @file:Suppress("unused", "UNUSED_PARAMETER", "MemberVisibilityCanBePrivate") 18 19 package replacewith 20 21 import android.view.View 22 23 class ReplaceWithUsageKotlin { 24 var otherBooleanProperty: Boolean = false 25 var otherProperty: String = "value" 26 27 @Deprecated(message = "Use [otherProperty] instead", replaceWith = ReplaceWith("otherProperty")) 28 var someProperty: String = "value" 29 30 @Deprecated( 31 message = "Use [otherBooleanProperty] instead", 32 replaceWith = ReplaceWith("otherBooleanProperty") 33 ) 34 var someBooleanProperty: Boolean = false 35 36 @get:Deprecated(message = "Use [getMethod] instead", replaceWith = ReplaceWith("getMethod")) 37 @set:Deprecated( 38 message = "Use [setMethod(String)] instead", 39 replaceWith = ReplaceWith("setMethod(value)") 40 ) 41 var deprecatedSetGetProperty: String = "value" 42 43 var deprecatedAccessorProperty: String 44 @Deprecated(message = "Use [getMethod] instead", replaceWith = ReplaceWith("getMethod")) 45 get() { 46 return otherProperty 47 } 48 @Deprecated( 49 message = "Use [setMethod(String)] instead", 50 replaceWith = ReplaceWith("setMethod(value)") 51 ) 52 set(value) { 53 otherProperty = value 54 } 55 56 @Deprecated( 57 message = "Use [otherProperty] instead", 58 replaceWith = ReplaceWith("otherProperty = arg") 59 ) setMethodDeprecatednull60 fun setMethodDeprecated(arg: String) { 61 otherProperty = arg 62 } 63 64 @Deprecated(message = "Use [otherProperty] instead", replaceWith = ReplaceWith("otherProperty")) getMethodDeprecatednull65 fun getMethodDeprecated(): String { 66 return otherProperty 67 } 68 setMethodnull69 fun setMethod(arg: String) { 70 otherProperty = arg 71 } 72 getMethodnull73 fun getMethod(): String { 74 return otherProperty 75 } 76 77 /** 78 * Constructor. 79 * 80 * @deprecated Use [java.lang.StringBuffer#StringBuffer(String)] instead. 81 */ 82 @Deprecated( 83 message = "Use [java.lang.StringBuffer#StringBuffer(String)] instead.", 84 replaceWith = ReplaceWith("StringBuffer(param)", "java.lang.StringBuffer") 85 ) 86 constructor(param: String) { 87 // Stub. 88 } 89 90 /** 91 * Constructor. 92 * 93 * @deprecated Use [ReplaceWithUsageKotlin#obtain(int)] instead. 94 */ 95 @Deprecated( 96 message = "Use [ReplaceWithUsageKotlin#obtain(Int)] instead.", 97 replaceWith = ReplaceWith("ReplaceWithUsageKotlin.obtain(param)") 98 ) 99 constructor(param: Int) { 100 // Stub. 101 } 102 103 /** Constructor. */ 104 constructor() { 105 // Stub. 106 } 107 108 inner class InnerClass { 109 /** 110 * Constructor. 111 * 112 * @deprecated Use [InnerClass#InnerClass()] instead. 113 */ 114 @Deprecated("Use [InnerClass#InnerClass()] instead.", ReplaceWith("InnerClass()")) 115 constructor(param: String) { 116 // Stub. 117 } 118 119 /** Constructor. */ 120 constructor() { 121 // Stub. 122 } 123 } 124 125 companion object { 126 /** 127 * Calls the method on the object. 128 * 129 * @param obj The object on which to call the method. 130 */ 131 @Deprecated("Use [Object#toString()] directly.", ReplaceWith("obj.toString()")) 132 @JvmStatic toStringnull133 fun toString(obj: Any) { 134 obj.toString() 135 } 136 137 /** Returns a new object. */ 138 @JvmStatic obtainnull139 fun obtain(param: Int): ReplaceWithUsageKotlin { 140 return ReplaceWithUsageKotlin() 141 } 142 143 /** String constant. */ 144 @Deprecated( 145 message = "Use {@link View#AUTOFILL_HINT_NAME} directly.", 146 ReplaceWith(expression = "View.AUTOFILL_HINT_NAME") 147 ) 148 @JvmStatic 149 val AUTOFILL_HINT_NAME = View.AUTOFILL_HINT_NAME 150 } 151 } 152