mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-08 16:04:10 -08:00
Implement Class.getSimpleName
This commit is contained in:
parent
0b7f3c14ac
commit
a2a679b2e3
|
@ -17,6 +17,7 @@ package org.teavm.classlib.java.lang;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.teavm.classlib.impl.DeclaringClassMetadataGenerator;
|
||||
import org.teavm.classlib.java.lang.annotation.TAnnotation;
|
||||
import org.teavm.classlib.java.lang.reflect.TAnnotatedElement;
|
||||
|
@ -32,6 +33,7 @@ import org.teavm.platform.metadata.ClassScopedMetadataProvider;
|
|||
*/
|
||||
public class TClass<T> extends TObject implements TAnnotatedElement {
|
||||
TString name;
|
||||
TString simpleName;
|
||||
private TClass<?> componentType;
|
||||
private boolean componentTypeDirty = true;
|
||||
private PlatformClass platformClass;
|
||||
|
@ -73,6 +75,26 @@ public class TClass<T> extends TObject implements TAnnotatedElement {
|
|||
return name;
|
||||
}
|
||||
|
||||
public TString getSimpleName() {
|
||||
if (simpleName == null) {
|
||||
String name = platformClass.getMetadata().getName();
|
||||
int lastDollar = name.lastIndexOf('$');
|
||||
if (lastDollar != -1) {
|
||||
name = name.substring(lastDollar + 1);
|
||||
if (name.charAt(0) >= 0 && name.charAt(0) <= 9) {
|
||||
name = "";
|
||||
}
|
||||
} else {
|
||||
int lastDot = name.lastIndexOf('.');
|
||||
if (lastDot != -1) {
|
||||
name = name.substring(lastDot + 1);
|
||||
}
|
||||
}
|
||||
simpleName = TString.wrap(name);
|
||||
}
|
||||
return simpleName;
|
||||
}
|
||||
|
||||
public boolean isPrimitive() {
|
||||
return platformClass.getMetadata().isPrimitive();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user