Record Class ImageBlock
java.lang.Object
java.lang.Record
com.nsdev.lettergenerator.model.block.ImageBlock
- Record Components:
data- encoded PNG/JPEG/static SVG bytes; null is retained for generation-time validationmimeType- exact supported MIME type,image/png,image/jpegorimage/svg+xmlwidthMm- maximum rendered width in millimeters; required and positive at generationheightMm- maximum rendered height in millimeters; required and positive at generationstyle- nullable block overrides for alignment and spacingaltText- optional human-readable image description for tagged output
- All Implemented Interfaces:
Block
public record ImageBlock(byte[] data, String mimeType, Double widthMm, Double heightMm, Style style, String altText)
extends Record
implements Block
PNG/JPEG/static SVG image scaled proportionally to fit an explicit box in millimeters. The
rendered image participates in body flow or the containing positioned region. The block style
controls alignment and surrounding spacing. Generation checks the MIME type, signature,
decodability, positive finite dimensions, and available width.
The constructor and data() clone bytes, so callers cannot mutate stored image
content. Equality and hashing use byte contents along with all other record components. The
constructor itself does not validate the image.
-
Constructor Summary
ConstructorsConstructorDescriptionImageBlock(byte[] data, String mimeType, Double widthMm, Double heightMm, Style style) Preserves construction without an image description.ImageBlock(byte[] data, String mimeType, Double widthMm, Double heightMm, Style style, String altText) Defensively copies image bytes without decoding or validating the supplied properties. -
Method Summary
Modifier and TypeMethodDescriptionaltText()Returns the value of thealtTextrecord component.byte[]data()Returns a defensive copy of the encoded image.booleanCompares image byte contents and every other record component.inthashCode()Hashes byte contents and every other record component consistently with equality.heightMm()Returns the value of theheightMmrecord component.mimeType()Returns the value of themimeTyperecord component.style()Returns the value of thestylerecord component.final StringtoString()Returns a string representation of this record class.widthMm()Returns the value of thewidthMmrecord component.withAltText(String value) Replaces the description while preserving the image and its geometry.Replaces local style overrides while preserving the description.
-
Constructor Details
-
ImageBlock
public ImageBlock(byte[] data, String mimeType, Double widthMm, Double heightMm, Style style, String altText) Defensively copies image bytes without decoding or validating the supplied properties.- Parameters:
data- bytes to clone, or nullmimeType- declared image MIME typewidthMm- image box width in millimetersheightMm- image box height in millimetersstyle- optional block overridesaltText- optional accessible image description
-
ImageBlock
Preserves construction without an image description.- Parameters:
data- image bytesmimeType- declared formatwidthMm- image box widthheightMm- image box heightstyle- optional style
-
-
Method Details
-
withAltText
Replaces the description while preserving the image and its geometry.- Parameters:
value- optional accessible description- Returns:
- independent image block
-
withStyle
Replaces local style overrides while preserving the description.- Parameters:
value- new style- Returns:
- independent image block
-
data
public byte[] data()Returns a defensive copy of the encoded image.- Returns:
- a new byte array, or null when no bytes were supplied
-
equals
Compares image byte contents and every other record component. -
hashCode
public int hashCode()Hashes byte contents and every other record component consistently with equality. -
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. -
mimeType
Returns the value of themimeTyperecord component.- Returns:
- the value of the
mimeTyperecord component
-
widthMm
Returns the value of thewidthMmrecord component.- Returns:
- the value of the
widthMmrecord component
-
heightMm
Returns the value of theheightMmrecord component.- Returns:
- the value of the
heightMmrecord component
-
style
Returns the value of thestylerecord component. -
altText
Returns the value of thealtTextrecord component.- Returns:
- the value of the
altTextrecord component
-