Java Class Name Extract extractClassNameWithParent(String fullClassName)

Here you can find the source of extractClassNameWithParent(String fullClassName)

Description

Class name with the parent if one exists.

License

Open Source License

Parameter

Parameter Description
fullClassName class name including packages

Return

name of class with parent separated with "$".

Declaration

public static String extractClassNameWithParent(String fullClassName) 

Method Source Code

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

public class Main {
    /**//  w w w .ja  v a 2  s  . com
     * Class name with the parent if one exists. This happens
     * when the class is an anonymous class. We want
     * class name:Parent$Child.
     * @param fullClassName class name including packages
     * @return name of class with parent separated with "$".
     */
    public static String extractClassNameWithParent(String fullClassName) {
        String[] splitName = fullClassName.split("\\.");
        return splitName[Math.max(splitName.length - 1, 0)];
    }
}

Related

  1. extractClassName(String methodName)
  2. extractClassName(String qualifiedName)
  3. extractClassNameFromArray(final String arrayName)
  4. extractClassNames(Class[] classArray)
  5. extractClassNameWithoutPackage(String className)