Record Class InputFile
java.lang.Object
java.lang.Record
org.teleight.teleightbots.api.objects.InputFile
- All Implemented Interfaces:
Serializable,ApiResult
Represents a file that can be used as an input for API requests.
The file can be provided from various sources such as a local file system,
a resource from the classpath, a file identified by a Telegram ID stored on the Telegram servers, or a URL.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.file()Returns the value of thefilerecord component.fileName()Returns the value of thefileNamerecord component.static @NotNull InputFileCreates anInputFileinstance from aFileobject.static @NotNull InputFileCreates anInputFileinstance from a file path asString.static @NotNull InputFileCreates anInputFileinstance from a file path asPath.static @NotNull InputFileCreates anInputFileinstance from a Telegram file ID or URL.static @NotNull InputFilefromResource(@NotNull String resource) Creates anInputFileinstance from a resource on the classpath.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
InputFile
Creates an instance of aInputFilerecord class.- Parameters:
id- the value for theidrecord componentfile- the value for thefilerecord componentfileName- the value for thefileNamerecord component
-
-
Method Details
-
fromFile
Creates anInputFileinstance from aFileobject.- Parameters:
file- the file to be used as input- Returns:
- a new
InputFileinstance containing the provided file - Throws:
NullPointerException- if the providedfileis null
-
fromFile
Creates anInputFileinstance from a file path asString.- Parameters:
filePath- the path to the file- Returns:
- a new
InputFileinstance containing the file located at the specified path - Throws:
NullPointerException- if the providedfilePathis null
-
fromFile
Creates anInputFileinstance from a file path asPath.- Parameters:
filePath- the path to the file- Returns:
- a new
InputFileinstance containing the file located at the specified path - Throws:
NullPointerException- if the providedfilePathis null
-
fromResource
Creates anInputFileinstance from a resource on the classpath.The resource will be copied to a temporary file, which will be used as the input.
- Parameters:
resource- the path to the resource within the classpath- Returns:
- a new
InputFileinstance containing the resource as a file - Throws:
IllegalStateException- if an I/O error occurs while accessing the resourceNullPointerException- if the providedresourceis null
-
fromId
Creates anInputFileinstance from a Telegram file ID or URL.- Parameters:
id- the Telegram file ID, or URL- Returns:
- a new
InputFileinstance containing the Telegram file ID - Throws:
NullPointerException- if the providedidis null
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
file
Returns the value of thefilerecord component.- Returns:
- the value of the
filerecord component
-
fileName
Returns the value of thefileNamerecord component.- Returns:
- the value of the
fileNamerecord component
-