Record Class MeshParseContext
java.lang.Object
java.lang.Record
io.github.toxicity188.javamesh.parser.MeshParseContext
- Record Components:
name- logical mesh name used by parsersscale- global scale applied while reading mesh coordinatesloaders- asset loaders keyed by file extension
public record MeshParseContext(@NotNull String name, float scale, @NotNull @Unmodifiable Map<String,MeshParseContext.StreamLoader> loaders)
extends Record
Input configuration for mesh parsers.
The context supplies a logical asset name, a global scale factor, and lazily-opened streams for source files such as OBJ and MTL so they can be converted into Minecraft resource-pack models.
MeshParseContext context = MeshParseContext.builder("sword")
.scale(0.5f)
.asset("obj", () -> Files.newInputStream(objPath))
.asset("mtl", () -> Files.newInputStream(mtlPath))
.build();
- Since:
- 0.0.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFluent builder forMeshParseContext.static interfaceOpens an asset stream used by a mesh parser. -
Constructor Summary
ConstructorsConstructorDescriptionMeshParseContext(@NotNull String name, float scale, @NotNull @Unmodifiable Map<String, MeshParseContext.StreamLoader> loaders) Creates an instance of aMeshParseContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull MeshParseContext.BuilderStarts building a parser context for the given mesh asset name.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull @Unmodifiable Map<String, MeshParseContext.StreamLoader> loaders()Returns the value of theloadersrecord component.@NotNull InputStreamloadExtension(@NotNull String extension) Opens the stream registered for the given extension.@Nullable InputStreamloadExtensionOrNull(@NotNull String extension) Opens the stream registered for the given extension when available.@NotNull Stringname()Returns the value of thenamerecord component.floatscale()Returns the value of thescalerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
MeshParseContext
public MeshParseContext(@NotNull @NotNull String name, float scale, @NotNull @NotNull @Unmodifiable Map<String, MeshParseContext.StreamLoader> loaders) Creates an instance of aMeshParseContextrecord class.
-
-
Method Details
-
builder
Starts building a parser context for the given mesh asset name.- Parameters:
name- logical mesh name- Returns:
- a new builder
- Since:
- 0.0.1
-
loadExtension
@NotNull public @NotNull InputStream loadExtension(@NotNull @NotNull String extension) throws IOException Opens the stream registered for the given extension.- Parameters:
extension- asset extension such as"obj"or"mtl"- Returns:
- the opened stream
- Throws:
IOException- if the underlying loader fails while opening the streamNullPointerException- if no loader is registered forextension- Since:
- 0.0.1
-
loadExtensionOrNull
@Nullable public @Nullable InputStream loadExtensionOrNull(@NotNull @NotNull String extension) throws IOException Opens the stream registered for the given extension when available.- Parameters:
extension- asset extension such as"obj"or"mtl"- Returns:
- the opened stream, or
nullwhen the extension is not registered - Throws:
IOException- if the underlying loader fails while opening the stream- Since:
- 0.0.1
-
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. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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 '=='. -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
scale
public float scale()Returns the value of thescalerecord component.- Returns:
- the value of the
scalerecord component
-
loaders
Returns the value of theloadersrecord component.- Returns:
- the value of the
loadersrecord component
-