Record Class ModelAsset

java.lang.Object
java.lang.Record
kr.toxicity.model.api.data.ModelAsset
Record Components:
rawName - the original raw name or path of the asset
name - the sanitized, pack-compliant name of the asset
sizeAssume - the estimated size of the asset in bytes (0 if unknown)
supplier - a supplier for the input stream containing the model data
All Implemented Interfaces:
Comparable<ModelAsset>

public record ModelAsset(@NotNull String rawName, @NotNull String name, long sizeAssume, @NotNull ModelAsset.StreamSupplier supplier) extends Record implements Comparable<ModelAsset>
Represents a raw model asset that can be loaded into the engine.

This record encapsulates the source of the model data (e.g., a file or stream), its name, and metadata. It provides methods to load and parse the model data into a usable format.

Since:
2.0.0
  • Constructor Details

    • ModelAsset

      @Internal public ModelAsset(@NotNull @NotNull String rawName, @NotNull @NotNull String name, long sizeAssume, @NotNull @NotNull ModelAsset.StreamSupplier supplier)
      Internal constructor for ModelAsset.
  • Method Details

    • of

      @NotNull public static @NotNull ModelAsset of(@NotNull @NotNull String name, byte[] bytes)
      Creates a new ModelAsset from a name and byte array.
      Parameters:
      name - the name of the asset
      bytes - the byte array containing the model data
      Returns:
      the created asset
      Since:
      2.0.0
    • of

      @NotNull public static @NotNull ModelAsset of(@NotNull @NotNull String name, @NotNull @NotNull ModelAsset.StreamSupplier supplier)
      Creates a new ModelAsset from a name and stream supplier.
      Parameters:
      name - the name of the asset
      supplier - the stream supplier
      Returns:
      the created asset
      Since:
      2.0.0
    • of

      @NotNull public static @NotNull ModelAsset of(@NotNull @NotNull String name, long sizeAssume, @NotNull @NotNull ModelAsset.StreamSupplier supplier)
      Creates a new ModelAsset from a name, stream supplier, and estimated size.
      Parameters:
      name - the name of the asset
      sizeAssume - the estimated size in bytes
      supplier - the stream supplier
      Returns:
      the created asset
      Since:
      2.0.0
    • of

      @NotNull public static @NotNull ModelAsset of(@NotNull @NotNull File file)
      Creates a new ModelAsset from a file.
      Parameters:
      file - the source file
      Returns:
      the created asset
      Since:
      2.0.0
    • of

      @NotNull public static @NotNull ModelAsset of(@NotNull @NotNull Path path)
      Creates a new ModelAsset from a path.
      Parameters:
      path - the source path
      Returns:
      the created asset
      Throws:
      RuntimeException - if an I/O error occurs
      Since:
      2.0.0
    • toResult

      @NotNull public @NotNull ModelLoadResult toResult()
      Loads and parses the model data from this asset.
      Returns:
      the result of the load operation
      Throws:
      RuntimeException - if an I/O or parsing error occurs
      Since:
      2.0.0
    • compareTo

      public int compareTo(@NotNull @NotNull ModelAsset o)
      Specified by:
      compareTo in interface Comparable<ModelAsset>
    • equals

      public boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • toString

      @NotNull public @NotNull String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • rawName

      @NotNull public @NotNull String rawName()
      Returns the value of the rawName record component.
      Returns:
      the value of the rawName record component
    • name

      @NotNull public @NotNull String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • sizeAssume

      public long sizeAssume()
      Returns the value of the sizeAssume record component.
      Returns:
      the value of the sizeAssume record component
    • supplier

      @NotNull public @NotNull ModelAsset.StreamSupplier supplier()
      Returns the value of the supplier record component.
      Returns:
      the value of the supplier record component