Class ZenClassRegistry

java.lang.Object
com.blamejared.crafttweaker.impl.registry.zencode.ZenClassRegistry
All Implemented Interfaces:
IZenClassRegistry

public final class ZenClassRegistry extends Object implements IZenClassRegistry
  • Constructor Details

    • ZenClassRegistry

      public ZenClassRegistry()
  • Method Details

    • isRegistered

      public boolean isRegistered(IScriptLoader loader, Class<?> clazz)
      Description copied from interface: IZenClassRegistry
      Verifies whether the given class is registered and thus exposed to the given loader.
      Specified by:
      isRegistered in interface IZenClassRegistry
      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.
    • getNameFor

      public Optional<String> getNameFor(IScriptLoader loader, Class<?> clazz)
      Description copied from interface: IZenClassRegistry
      Attempts to identify the name under which the target class is exposed to ZenCode in the given loader.
      Specified by:
      getNameFor in interface IZenClassRegistry
      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.
    • getImplementationsOf

      public <T> List<Class<? extends T>> getImplementationsOf(IScriptLoader loader, Class<T> checkFor)
      Description copied from interface: IZenClassRegistry
      Gets all non-abstract classes that extend or implement the given target for the specified loader.
      Specified by:
      getImplementationsOf in interface IZenClassRegistry
      Type Parameters:
      T - The type the returned classes should be implementing or extending.
      Parameters:
      loader - The IScriptLoader for which implementations should be found.
      checkFor - 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.
    • getClassData

      public IZenClassRegistry.IClassData getClassData(IScriptLoader loader)
      Description copied from interface: IZenClassRegistry
      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.

      Specified by:
      getClassData in interface IZenClassRegistry
      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.
    • getClassesInPackage

      public List<Class<?>> getClassesInPackage(IScriptLoader loader, String packageName)
      Description copied from interface: IZenClassRegistry
      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.

      Specified by:
      getClassesInPackage in interface IZenClassRegistry
      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.
    • getGlobalsInPackage

      public List<Class<?>> getGlobalsInPackage(IScriptLoader loader, String packageName)
      Description copied from interface: IZenClassRegistry
      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.

      Specified by:
      getGlobalsInPackage in interface IZenClassRegistry
      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.
    • getRootPackages

      public Set<String> getRootPackages(IScriptLoader loader)
      Description copied from interface: IZenClassRegistry
      Gets the set of all the packages that act as root for the given loader.
      Specified by:
      getRootPackages in interface IZenClassRegistry
      Parameters:
      loader - The IScriptLoader for which root packages should be gathered.
      Returns:
      A Set containing all root packages.
    • getNativeTypeRegistry

      public INativeTypeRegistry getNativeTypeRegistry(IScriptLoader loader)
      Description copied from interface: IZenClassRegistry
      Obtains the INativeTypeRegistry for the given loader.
      Specified by:
      getNativeTypeRegistry in interface IZenClassRegistry
      Parameters:
      loader - The IScriptLoader for which the native type registry should be obtained.
      Returns:
      The loader's corresponding INativeTypeRegistry.
    • isBlacklisted

      public boolean isBlacklisted(Class<?> cls)
      Description copied from interface: IZenClassRegistry
      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.

      Specified by:
      isBlacklisted in interface IZenClassRegistry
      Parameters:
      cls - The class to check for blacklisting.
    • fillLoaderData

      public void fillLoaderData(Collection<IScriptLoader> loaders)
    • registerNativeType

      public void registerNativeType(IScriptLoader loader, NativeTypeInfo info)
    • registerZenType

      public void registerZenType(IScriptLoader loader, Class<?> clazz, ZenTypeInfo info, boolean globals)
    • applyInheritanceRules

      public void applyInheritanceRules()