You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just to be clear that toClassOrInterfaceType is not a JavaParser method, but an utility method that for instance in Drools has been implemented in this way.
So you can simply add the same method to your code base and reuse it:
public static ClassOrInterfaceType toClassOrInterfaceType( String className ) {
String withoutDollars = className.replace("$", "."); // nested class in Java cannot be used in casts
return withoutDollars.indexOf('<') >= 0 ? StaticJavaParser.parseClassOrInterfaceType(withoutDollars) : new ClassOrInterfaceType(null, withoutDollars);
}
Also note that when you're sure that the type name doesn't refer to an inner class or has generics, as in your example, you can rewrite that statement in an even simpler and more efficient way as it follow:
Suggestion from @mariofusco as he used async profiler against the
java-generator
, thanks for the amazing work 馃檹 !He noticed that one possible optimization would be to reduce the amount of work that JavaParser should do when parsing plain Strings e.g. here :
can be more efficient narrowing down the scope of the JavaParser string parsing:
The text was updated successfully, but these errors were encountered: