Move getterName/setterName to JvmAbi

Reuse in RuntimeTypeMapper in reflection
This commit is contained in:
Alexander Udalov
2015-07-09 20:05:44 +03:00
parent 64d8e35d26
commit c62f19ee82
13 changed files with 82 additions and 94 deletions
@@ -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);
}
}