Record Class Format
java.lang.Object
java.lang.Record
is.galia.image.Format
- Record Components:
key
- Unique format key, used internally to identify formats but not relevant outside of the application.name
- Human-readable name.mediaTypes
- All media types associated with this format, in descending preference order.extensions
- All extensions associated with this format, in descending preference order.isRaster
- Whether the format is raster (pixel-based still image).isVideo
- Whether the format is video (moving image).supportsTransparency
- Whether the format supports transparency.
- All Implemented Interfaces:
Comparable<Format>
public record Format(String key, String name, List<MediaType> mediaTypes, List<String> extensions, boolean isRaster, boolean isVideo, boolean supportsTransparency)
extends Record
implements Comparable<Format>
File format.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionall()
Alias ofFormatRegistry.allFormats()
.int
Compares by case-insensitive name.final boolean
Indicates whether some other object is "equal to" this one.Returns the value of theextensions
record component.static Format
Alias ofFormatRegistry.formatWithKey(String)
.final int
hashCode()
Returns a hash code value for this object.static Format
inferFormat
(Identifier identifier) Attempts to infer a format from the given identifier.static Format
inferFormat
(String pathname) Attempts to infer a format from the given pathname.boolean
isRaster()
Returns the value of theisRaster
record component.boolean
isVideo()
Returns the value of theisVideo
record component.key()
Returns the value of thekey
record component.Returns the value of themediaTypes
record component.name()
Returns the value of thename
record component.boolean
Returns the value of thesupportsTransparency
record component.toString()
Returns a string representation of this record class.static Format
withExtension
(String extension)
-
Field Details
-
UNKNOWN
Represents an unknown format.
-
-
Constructor Details
-
Format
public Format(String key, String name, List<MediaType> mediaTypes, List<String> extensions, boolean isRaster, boolean isVideo, boolean supportsTransparency) Creates an instance of aFormat
record class.- Parameters:
key
- the value for thekey
record componentname
- the value for thename
record componentmediaTypes
- the value for themediaTypes
record componentextensions
- the value for theextensions
record componentisRaster
- the value for theisRaster
record componentisVideo
- the value for theisVideo
record componentsupportsTransparency
- the value for thesupportsTransparency
record component
-
-
Method Details
-
all
Alias ofFormatRegistry.allFormats()
.- Returns:
- All registered formats.
-
get
Alias ofFormatRegistry.formatWithKey(String)
.- Parameters:
key
- One of the keys in formats.yml.- Returns:
- Instance corresponding to the given argument, or
null
if no such format exists.
-
inferFormat
Attempts to infer a format from the given identifier.
It is usually more reliable (but also maybe more expensive) to obtain this information from
Source.getFormatIterator()
.- Parameters:
identifier
-- Returns:
- The source format corresponding to the given identifier,
assuming that its value will have a recognizable filename
extension. If not,
UNKNOWN
is returned.
-
inferFormat
Attempts to infer a format from the given pathname.
It is usually more reliable (but also maybe more expensive) to obtain this information from
Source.getFormatIterator()
.- Parameters:
pathname
- Full pathname of an image file.- Returns:
- The source format corresponding to the given identifier,
assuming that its value will have a recognizable filename
extension. If not,
UNKNOWN
is returned.
-
withExtension
-
compareTo
Compares by case-insensitive name.- Specified by:
compareTo
in interfaceComparable<Format>
-
getPreferredExtension
- Returns:
- The most appropriate extension for the format.
-
getPreferredMediaType
- Returns:
- The most appropriate media type for the format.
-
toString
-
hashCode
-
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 thecompare
method from their corresponding wrapper classes. -
key
-
name
-
mediaTypes
Returns the value of themediaTypes
record component.- Returns:
- the value of the
mediaTypes
record component
-
extensions
Returns the value of theextensions
record component.- Returns:
- the value of the
extensions
record component
-
isRaster
-
isVideo
-
supportsTransparency
public boolean supportsTransparency()Returns the value of thesupportsTransparency
record component.- Returns:
- the value of the
supportsTransparency
record component
-