Move getterName/setterName to JvmAbi
Reuse in RuntimeTypeMapper in reflection
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java;
|
||||
|
||||
import kotlin.KotlinPackage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.name.ClassId;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
@@ -55,10 +56,21 @@ public final class JvmAbi {
|
||||
return isDelegated ? propertyName.asString() + DELEGATED_PROPERTY_NAME_SUFFIX : propertyName.asString();
|
||||
}
|
||||
|
||||
public static boolean isAccessorName(String name) {
|
||||
return name.startsWith(GETTER_PREFIX) || name.startsWith(SETTER_PREFIX);
|
||||
@NotNull
|
||||
public static String getterName(@NotNull String propertyName) {
|
||||
return GETTER_PREFIX + capitalizeWithJavaBeanConvention(propertyName);
|
||||
}
|
||||
|
||||
private JvmAbi() {
|
||||
@NotNull
|
||||
public static String setterName(@NotNull String propertyName) {
|
||||
return SETTER_PREFIX + capitalizeWithJavaBeanConvention(propertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.intellij.openapi.util.text.StringUtil#capitalizeWithJavaBeanConvention(String)
|
||||
*/
|
||||
@NotNull
|
||||
private static String capitalizeWithJavaBeanConvention(@NotNull String s) {
|
||||
return s.length() > 1 && Character.isUpperCase(s.charAt(1)) ? s : KotlinPackage.capitalize(s);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user