Package com.tnsai.channels.model
Record Class Attachment
java.lang.Object
java.lang.Record
com.tnsai.channels.model.Attachment
- Record Components:
fileName- original file namemimeType- MIME type (e.g. "image/png", "audio/ogg")url- remote URL if availabledata- raw bytes if downloaded locally (may be null)sizeBytes- file size in bytes (-1 if unknown)type- semantic type of the attachment
public record Attachment(String fileName, String mimeType, String url, byte[] data, long sizeBytes, Attachment.AttachmentType type)
extends Record
A file or media item attached to a message or response.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionAttachment(String fileName, String mimeType, String url, byte[] data, long sizeBytes, Attachment.AttachmentType type) Creates an instance of aAttachmentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]data()Returns the value of thedatarecord component.final booleanIndicates whether some other object is "equal to" this one.fileName()Returns the value of thefileNamerecord component.final inthashCode()Returns a hash code value for this object.mimeType()Returns the value of themimeTyperecord component.static AttachmentofData(String fileName, String mimeType, byte[] data, Attachment.AttachmentType type) static AttachmentofUrl(String fileName, String mimeType, String url, Attachment.AttachmentType type) longReturns the value of thesizeBytesrecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.url()Returns the value of theurlrecord component.
-
Constructor Details
-
Attachment
public Attachment(String fileName, String mimeType, String url, byte[] data, long sizeBytes, Attachment.AttachmentType type) Creates an instance of aAttachmentrecord class.- Parameters:
fileName- the value for thefileNamerecord componentmimeType- the value for themimeTyperecord componenturl- the value for theurlrecord componentdata- the value for thedatarecord componentsizeBytes- the value for thesizeBytesrecord componenttype- the value for thetyperecord component
-
-
Method Details
-
ofUrl
public static Attachment ofUrl(String fileName, String mimeType, String url, Attachment.AttachmentType type) -
ofData
public static Attachment ofData(String fileName, String mimeType, byte[] data, Attachment.AttachmentType type) -
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 '=='. -
fileName
Returns the value of thefileNamerecord component.- Returns:
- the value of the
fileNamerecord component
-
mimeType
Returns the value of themimeTyperecord component.- Returns:
- the value of the
mimeTyperecord component
-
url
Returns the value of theurlrecord component.- Returns:
- the value of the
urlrecord component
-
data
public byte[] data()Returns the value of thedatarecord component.- Returns:
- the value of the
datarecord component
-
sizeBytes
public long sizeBytes()Returns the value of thesizeBytesrecord component.- Returns:
- the value of the
sizeBytesrecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-