Package com.nsdev.lettergenerator.model
Record Class LetterDocument
java.lang.Object
java.lang.Record
com.nsdev.lettergenerator.model.LetterDocument
- Record Components:
schemaVersion- input schema version; generation currently requiresSUPPORTED_SCHEMA_VERSIONpage- physical layout, or null forPageSpec.defaults()defaultStyle- nullable overrides applied before section, block, cell, and run stylessections- body sections in reading order; generation requires at least one body blockfixedElements- positioned top/bottom content; null means no fixed elementssignature- optional visual signature; null means no signaturewatermark- optional decoration behind page content; null means no watermarktheme- optional document-local role and named style defaultscomponents- optional document-local reusable content; null becomes an empty mapsettings- optional formatting and output metadata; null selects stable defaultsattachments- optional PDFs appended unchanged after the generated letter
public record LetterDocument(int schemaVersion, PageSpec page, Style defaultStyle, List<Section> sections, List<FixedElement> fixedElements, Signature signature, Watermark watermark, LetterTheme theme, Map<String,LetterComponent> components, DocumentSettings settings, List<PdfAttachment> attachments)
extends Record
Complete immutable input to PDF generation, shared by the Java builders and JSON input. A
document contains body
sections, optional positioned content, a visual signature,
and a watermark. The schema version is checked during generation; constructing this record does
not validate content, fonts, geometry, or image formats.
Supplied lists and the component map are copied into unmodifiable collections, preserving null entries for later validation. A null sections list remains null; only a null fixed-elements list becomes empty. Themes and reusable components resolve before ordinary validation, without global registrations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intSchema version accepted by generation and by the JSON document model. -
Constructor Summary
ConstructorsConstructorDescriptionLetterDocument(int schemaVersion, PageSpec page, Style defaultStyle, List<Section> sections, List<FixedElement> fixedElements, Signature signature, Watermark watermark) Preserves the original constructor with no theme or reusable-content registrations.LetterDocument(int schemaVersion, PageSpec page, Style defaultStyle, List<Section> sections, List<FixedElement> fixedElements, Signature signature, Watermark watermark, LetterTheme theme, Map<String, LetterComponent> components) Preserves composition-aware construction without additional settings or attachments.LetterDocument(int schemaVersion, PageSpec page, Style defaultStyle, List<Section> sections, List<FixedElement> fixedElements, Signature signature, Watermark watermark, LetterTheme theme, Map<String, LetterComponent> components, DocumentSettings settings, List<PdfAttachment> attachments) Substitutes the default page and snapshots both lists without validating their contents. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theattachmentsrecord component.Returns the value of thecomponentsrecord component.Returns the value of thedefaultStylerecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefixedElementsrecord component.final inthashCode()Returns a hash code value for this object.page()Returns the value of thepagerecord component.intReturns the value of theschemaVersionrecord component.sections()Returns the value of thesectionsrecord component.settings()Returns the value of thesettingsrecord component.Returns the value of thesignaturerecord component.theme()Returns the value of thethemerecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thewatermarkrecord component.withAttachments(List<PdfAttachment> value) Replaces appended PDF registrations while retaining the letter.withComponents(Map<String, LetterComponent> value) Replaces component registrations with a defensive snapshot.withSettings(DocumentSettings value) Replaces document settings while preserving all content and attachments.withTheme(LetterTheme value) Replaces the theme while retaining content and component registrations.
-
Field Details
-
SUPPORTED_SCHEMA_VERSION
public static final int SUPPORTED_SCHEMA_VERSIONSchema version accepted by generation and by the JSON document model.- See Also:
-
-
Constructor Details
-
LetterDocument
public LetterDocument(int schemaVersion, PageSpec page, Style defaultStyle, List<Section> sections, List<FixedElement> fixedElements, Signature signature, Watermark watermark, LetterTheme theme, Map<String, LetterComponent> components, DocumentSettings settings, List<PdfAttachment> attachments) Substitutes the default page and snapshots both lists without validating their contents.- Parameters:
schemaVersion- schema identifier stored unchangedpage- page specification, or null to use the defaultdefaultStyle- optional document-wide style overridessections- ordered body sections, copied if nonnullfixedElements- positioned elements, copied or replaced with an empty listsignature- optional visual signaturewatermark- optional page decorationtheme- nullable role and named-style definitionscomponents- nullable reusable-content registrations, defensively copiedsettings- optional document settingsattachments- optional appended PDF snapshots
-
LetterDocument
public LetterDocument(int schemaVersion, PageSpec page, Style defaultStyle, List<Section> sections, List<FixedElement> fixedElements, Signature signature, Watermark watermark, LetterTheme theme, Map<String, LetterComponent> components) Preserves composition-aware construction without additional settings or attachments.- Parameters:
schemaVersion- input schemapage- physical layoutdefaultStyle- document stylesections- body sectionsfixedElements- fixed contentsignature- optional signaturewatermark- optional decorationtheme- optional themecomponents- optional reusable registrations
-
LetterDocument
public LetterDocument(int schemaVersion, PageSpec page, Style defaultStyle, List<Section> sections, List<FixedElement> fixedElements, Signature signature, Watermark watermark) Preserves the original constructor with no theme or reusable-content registrations.- Parameters:
schemaVersion- input schema versionpage- nullable page specificationdefaultStyle- nullable document overridessections- ordered body sectionsfixedElements- nullable positioned contentsignature- nullable visual signaturewatermark- nullable decoration
-
-
Method Details
-
withTheme
Replaces the theme while retaining content and component registrations.- Parameters:
value- nullable theme- Returns:
- immutable document copy
-
withComponents
Replaces component registrations with a defensive snapshot.- Parameters:
value- nullable document-local component registrations- Returns:
- immutable document copy
-
withSettings
Replaces document settings while preserving all content and attachments.- Parameters:
value- formatting/output metadata- Returns:
- independent immutable model
-
withAttachments
Replaces appended PDF registrations while retaining the letter.- Parameters:
value- appended PDFs, snapshotted- Returns:
- immutable model
-
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 '=='. -
schemaVersion
public int schemaVersion()Returns the value of theschemaVersionrecord component.- Returns:
- the value of the
schemaVersionrecord component
-
page
Returns the value of thepagerecord component.- Returns:
- the value of the
pagerecord component
-
defaultStyle
Returns the value of thedefaultStylerecord component.- Returns:
- the value of the
defaultStylerecord component
-
sections
Returns the value of thesectionsrecord component.- Returns:
- the value of the
sectionsrecord component
-
fixedElements
Returns the value of thefixedElementsrecord component.- Returns:
- the value of the
fixedElementsrecord component
-
signature
Returns the value of thesignaturerecord component.- Returns:
- the value of the
signaturerecord component
-
watermark
Returns the value of thewatermarkrecord component.- Returns:
- the value of the
watermarkrecord component
-
theme
Returns the value of thethemerecord component.- Returns:
- the value of the
themerecord component
-
components
Returns the value of thecomponentsrecord component.- Returns:
- the value of the
componentsrecord component
-
settings
Returns the value of thesettingsrecord component.- Returns:
- the value of the
settingsrecord component
-
attachments
Returns the value of theattachmentsrecord component.- Returns:
- the value of the
attachmentsrecord component
-