Import a class.
Returns the constructor of the class to be created.
For example, import "java.util.ArrayList" for a java Array List.
Define a custom class type for the imported class and pass the
constructor type of the class as the template parameter to get
the proper type returned. You could also just cast the result.
When passing a ClassConfiguration object, the config will be applied
to this class. This config does not apply to any other class.
If you want to change the config for all classes, use the
config class in order to do that. Any undefined field
in the config will be ignored and the default value will be used.
If you want to change the sync and async suffixes to an empty string,
you can pass an empty string as the suffix.
// Definitions for class java.util.ArrayList declareclassArrayListClass<TextendsJavaType> extendsList<T> { publicconstructor(other: ArrayListClass<T>); publicconstructor(); }
// This causes the class to be imported when the module is loaded. classArrayList<T> extendsimportClass<typeofArrayListClass>('java.util.ArrayList')<T> {}
// Create a new ArrayList instance constlist = newArrayList<string>();
// Add some contents to the list list.add('Hello'); list.add('World');
// Check the list contents assert.equals(list.sizeSync(), 2); assert.equals(list.getSync(0), 'Hello'); assert.equals(list.getSync(1), 'World');
Import a class. Returns the constructor of the class to be created. For example, import "java.util.ArrayList" for a java Array List.
Define a custom class type for the imported class and pass the constructor type of the class as the template parameter to get the proper type returned. You could also just cast the result.
When passing a ClassConfiguration object, the config will be applied to this class. This config does not apply to any other class. If you want to change the config for all classes, use the config class in order to do that. Any undefined field in the config will be ignored and the default value will be used. If you want to change the sync and async suffixes to an empty string, you can pass an empty string as the suffix.
Examples
Import
java.util.ArrayList
and create a new instance of itImport
java.util.ArrayList
with typesImport
java.util.ArrayList
with custom config