Java Class Name Convert To classNameToConstant(String className)

Here you can find the source of classNameToConstant(String className)

Description

class Name To Constant

License

Open Source License

Declaration

public static String classNameToConstant(String className) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String classNameToConstant(String className) {
        return camelCaseNameToConstant(className);
    }/*from w w w  . j a v  a2  s . c o m*/

    private static String camelCaseNameToConstant(String camelCaseName) {
        if (camelCaseName == null || camelCaseName.isEmpty()) {
            return camelCaseName;
        }

        return camelCaseName.replaceAll("([a-z]{1})([A-Z]{1})", "$1_$2").toUpperCase();
    }
}

Related

  1. classNameToAsm(Class c1ass)
  2. classNameToDirectoryName(final Class targetClass)
  3. classnameToFilename(String classname)
  4. classNameToFilePath(String className)
  5. classNameToFullyQualifiedClassName(String packageName, String className)