Package kr.toxicity.model.api.data
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 assetname- the sanitized, pack-compliant name of the assetsizeAssume- 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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA functional interface for supplying an input stream. -
Constructor Summary
ConstructorsConstructorDescriptionModelAsset(@NotNull String rawName, @NotNull String name, long sizeAssume, @NotNull ModelAsset.StreamSupplier supplier) Internal constructor for ModelAsset. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(@NotNull ModelAsset o) booleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.@NotNull Stringname()Returns the value of thenamerecord component.static @NotNull ModelAssetCreates a new ModelAsset from a file.static @NotNull ModelAssetCreates a new ModelAsset from a name and byte array.static @NotNull ModelAssetof(@NotNull String name, long sizeAssume, @NotNull ModelAsset.StreamSupplier supplier) Creates a new ModelAsset from a name, stream supplier, and estimated size.static @NotNull ModelAssetof(@NotNull String name, @NotNull ModelAsset.StreamSupplier supplier) Creates a new ModelAsset from a name and stream supplier.static @NotNull ModelAssetCreates a new ModelAsset from a path.@NotNull StringrawName()Returns the value of therawNamerecord component.longReturns the value of thesizeAssumerecord component.@NotNull ModelAsset.StreamSuppliersupplier()Returns the value of thesupplierrecord component.@NotNull ModelLoadResulttoResult()Loads and parses the model data from this asset.@NotNull StringtoString()Returns a string representation of this record class.
-
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
Creates a new ModelAsset from a name and byte array.- Parameters:
name- the name of the assetbytes- 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 assetsupplier- 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 assetsizeAssume- the estimated size in bytessupplier- the stream supplier- Returns:
- the created asset
- Since:
- 2.0.0
-
of
Creates a new ModelAsset from a file.- Parameters:
file- the source file- Returns:
- the created asset
- Since:
- 2.0.0
-
of
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
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
- Specified by:
compareToin interfaceComparable<ModelAsset>
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
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. -
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. -
rawName
Returns the value of therawNamerecord component.- Returns:
- the value of the
rawNamerecord component
-
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
sizeAssume
public long sizeAssume()Returns the value of thesizeAssumerecord component.- Returns:
- the value of the
sizeAssumerecord component
-
supplier
Returns the value of thesupplierrecord component.- Returns:
- the value of the
supplierrecord component
-