Mercurial > hg > graal-jvmci-8
changeset 18239:9670aff0388b
Add utility for getting the unqualified type name of a Java type.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 01 Jul 2014 15:41:54 +0200 |
parents | 00460aab5c96 |
children | b7b85f57a21a |
files | graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaType.java |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaType.java Tue Jul 01 19:06:06 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaType.java Tue Jul 01 15:41:54 2014 +0200 @@ -41,6 +41,25 @@ String getName(); /** + * Returns an unqualified name of this type. + * + * <pre> + * "Object" + * "Integer" + * </pre> + */ + default String getUnqualifiedName() { + String name = getName(); + if (name.indexOf('/') != -1) { + name = name.substring(name.lastIndexOf('/') + 1); + } + if (name.endsWith(";")) { + name = name.substring(0, name.length() - 1); + } + return name; + } + + /** * For array types, gets the type of the components, or {@code null} if this is not an array * type. This method is analogous to {@link Class#getComponentType()}. */