Class AutoRegisterInfo

java.lang.Object
de.craftsblock.craftsnet.autoregister.meta.AutoRegisterInfo

public class AutoRegisterInfo extends Object
The AutoRegisterInfo holds information about a class to be processed in an auto registration process. It contains the class name, the annotation associated with the class, the class loader, and a list of parent types (superclasses and interfaces) of the class. Optional it contains the addon that the source is located in. If no addons was set, the source is not located inside an addon.
Since:
3.2.0-SNAPSHOT
  • Constructor Details

    • AutoRegisterInfo

      public AutoRegisterInfo(@NotNull @NotNull String className, @Nullable @Nullable Collection<Addon> bounding, @NotNull @NotNull Annotation annotation, @NotNull @NotNull ClassLoader loader, @NotNull @NotNull List<String> parentTypes)
      Constructs an AutoRegisterInfo object with the given parameters.
      Parameters:
      className - The fully qualified name of the class to be registered.
      bounding - The optional Addon that contains the class. Can be null if not inside an addon.
      annotation - The annotation associated with the class.
      loader - The ClassLoader that was used to load the class.
      parentTypes - A list of parent types (superclasses and interfaces) of the class.
  • Method Details

    • getInstantiated

      public Object getInstantiated(CraftsNet craftsNet)
      Returns an instance of the target class. If the instance type requires a new object each time, a fresh instance is created. Otherwise, a cached instance is returned.
      Parameters:
      craftsNet - The CraftsNet instance used for dependency injection.
      Returns:
      An instance of the target class.
      Since:
      3.3.2-SNAPSHOT
    • getClassName

      @NotNull public @NotNull String getClassName()
      Returns the fully qualified class name of the target class.
      Returns:
      The class name as a String.
    • getBounding

      @Nullable public @Nullable Collection<Addon> getBounding()
      Returns the Addon associated with this class, if any.
      Returns:
      The Addon instance or null if no addon is associated.
    • hasBounding

      public boolean hasBounding()
      Checks whether this class is associated with an Addon.
      Returns:
      true if an addon is associated, otherwise false.
      Since:
      3.3.2-SNAPSHOT
    • getAnnotation

      @NotNull public @NotNull Annotation getAnnotation()
      Returns the annotation associated with this class.
      Returns:
      The associated Annotation.
    • getLoader

      @NotNull public @NotNull ClassLoader getLoader()
      Returns the class loader used to load this class.
      Returns:
      The ClassLoader instance.
    • getParentTypes

      @NotNull public @NotNull @Unmodifiable List<String> getParentTypes()
      Returns a list of parent types (superclasses and interfaces) of the class.
      Returns:
      An unmodifiable list of parent type names.
    • equals

      public boolean equals(Object o)

      Compares two AutoRegisterInfo objects for equality based on their class name and annotation.

      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()

      Calculates the hash code based on the class name and annotation.

      Overrides:
      hashCode in class Object
    • of

      public static AutoRegisterInfo of(@NotNull @NotNull String className, @Nullable @Nullable Collection<Addon> bounding, @NotNull @NotNull Annotation annotation, @NotNull @NotNull ClassLoader loader, @NotNull @NotNull List<String> parentTypes)
      Creates a new instance of AutoRegisterInfo.
      Parameters:
      className - The name of the class.
      bounding - The list of addons that the auto register info is from. Nullable if the register info does not come from an addon.
      annotation - The annotation associated with the class.
      loader - The class loader that was used to load the class.
      parentTypes - A list of the names of the parent types (superclasses and interfaces) of the class.
      Returns:
      A new instance of AutoRegisterInfo.