Interface IZenClassRegistry

All Known Implementing Classes:
ZenClassRegistry

public interface IZenClassRegistry
Holds information related to the various classes and expansions exposed to ZenCode.

An instance of this class can be obtained through IZenClassRegistry.

Since:
9.1.0
  • Method Details

    • isRegistered

      boolean isRegistered(IScriptLoader loader, Class<?> clazz)
      Verifies whether the given class is registered and thus exposed to the given loader.
      Parameters:
      loader - The IScriptLoader for which exposure data should be checked for.
      clazz - The class whose exposure should be checked.
      Returns:
      Whether the class is exposed to the loader or not.
      Since:
      9.1.0
    • getNameFor

      Optional<String> getNameFor(IScriptLoader loader, Class<?> clazz)
      Attempts to identify the name under which the target class is exposed to ZenCode in the given loader.
      Parameters:
      loader - The IScriptLoader for which the name should be identified.
      clazz - The class whose name should be identified.
      Returns:
      An Optional wrapping the name of the class if it is exposed, an empty optional if the class is not exposed.
      Since:
      9.1.0
    • getImplementationsOf

      <T> List<Class<? extends T>> getImplementationsOf(IScriptLoader loader, Class<T> target)
      Gets all non-abstract classes that extend or implement the given target for the specified loader.
      Type Parameters:
      T - The type the returned classes should be implementing or extending.
      Parameters:
      loader - The IScriptLoader for which implementations should be found.
      target - The class or interface for which implementations should be identified.
      Returns:
      A List of non-abstract classes that extend or implement the given target, if any.
      Since:
      9.1.0
    • getClassData

      Gets the raw class data for the given loader.

      Access to the raw class data is discouraged, as other methods of querying classes should be preferred. Nevertheless, access is permitted as there might be some instances where the raw data needs to be used. Such data access is regardless provided as read-only, to avoid unwanted tampering.

      Parameters:
      loader - The IScriptLoader for which the raw class data should be obtained.
      Returns:
      An instance of IZenClassRegistry.IClassData containing the raw class data for the target loader.
      Since:
      9.1.0
    • getClassesInPackage

      List<Class<?>> getClassesInPackage(IScriptLoader loader, String packageName)
      Gets all classes that are located in the given package among the ones exposed to the targeted loader.

      The concept of package used in this context is the ZenCode concept, instead of the Java one. This means that subpackages of the given package are also queried.

      Parameters:
      loader - The IScriptLoader for which the data should be gathered.
      packageName - The name of the package the various classes should be located in.
      Returns:
      A List of all the classes located in the target package.
      Since:
      9.1.0
    • getGlobalsInPackage

      List<Class<?>> getGlobalsInPackage(IScriptLoader loader, String packageName)
      Gets all classes that expose globals located in the given package among the ones exposed to the targeted loader.

      The concept of package used in this context is the ZenCode concept, instead of the Java one. This means that subpackages of the given package are also queried.

      Parameters:
      loader - The IScriptLoader for which the data should be gathered.
      packageName - The name of the package the various global-exposing classes should be located in.
      Returns:
      A List of all the global-exposing classes located in the target package.
      Since:
      9.1.0
    • getRootPackages

      Set<String> getRootPackages(IScriptLoader loader)
      Gets the set of all the packages that act as root for the given loader.
      Parameters:
      loader - The IScriptLoader for which root packages should be gathered.
      Returns:
      A Set containing all root packages.
      Since:
      9.1.0
    • getNativeTypeRegistry

      INativeTypeRegistry getNativeTypeRegistry(IScriptLoader loader)
      Obtains the INativeTypeRegistry for the given loader.
      Parameters:
      loader - The IScriptLoader for which the native type registry should be obtained.
      Returns:
      The loader's corresponding INativeTypeRegistry.
      Since:
      9.1.0
    • isBlacklisted

      boolean isBlacklisted(Class<?> clazz)
      Checks whether the given class has been blacklisted from registration.

      A blacklisted class will never be registered to any loader because its registration might fail due to unsatisfied requirements. A reason for the blacklist can be identified through the log.

      Parameters:
      clazz - The class to check for blacklisting.
      Since:
      9.1.0