Returns the simple name of the underlying class as given in the source code. Behaves identically to Class#getSimpleName() but does not require the class to be loaded.
()
| 294 | |
| 295 | |
| 296 | public String getSimpleName() { |
| 297 | int lastDollarSign = className.lastIndexOf('$'); |
| 298 | if (lastDollarSign != -1) { |
| 299 | String innerClassName = className.substring(lastDollarSign + 1); |
| 300 | // local and anonymous classes are prefixed with number (1,2,3...), anonymous classes are |
| 301 | // entirely numeric whereas local classes have the user supplied name as a suffix |
| 302 | return CharMatcher.digit().trimLeadingFrom(innerClassName); |
| 303 | } |
| 304 | String packageName = getPackageName(); |
| 305 | if (packageName.isEmpty()) { |
| 306 | return className; |
| 307 | } |
| 308 | |
| 309 | // Since this is a top level class, its simple name is always the part after package name. |
| 310 | return className.substring(packageName.length() + 1); |
| 311 | } |
| 312 | |
| 313 | /** |
| 314 | * Returns the fully qualified name of the class. |
no test coverage detected