* Returns the class name for use for this script source. The name is intended to be unique to support mapping
* class names to source files even if many sources have the same file name (e.g. build.gradle).
*/
public String getClassName() {
if (className == null) {
URI sourceUri = resource.getURI();
String name = StringUtils.substringAfterLast(sourceUri.getPath(), "/");
StringBuilder className = new StringBuilder(name.length());
for (int i = 0; i < name.length(); i++) {
char ch = name.charAt(i);
if (Character.isJavaIdentifierPart(ch)) {
className.append(ch);
} else {
className.append('_');
}
}
if (!Character.isJavaIdentifierStart(className.charAt(0))) {
className.insert(0, '_');
}
className.append('_');
String path = sourceUri.toString();
className.append(HashUtil.createHash(path));
this.className = className.toString();
}