MimeType class

An immutable, industry-standard value object representing a Multipurpose Internet Mail Extensions (MIME) type, as defined in RFC 2045 and RFC 2046.

MimeType serves as a core communication descriptor across serialization systems, data binding boundaries, and HTTP network infrastructure (e.g., managing the Content-Type header). It decomposes media format descriptors into a main type, a localized subtype, and an unmodifiable parameters map.

Structural Anatomy

     application /  json  ;  charset = utf-8
    |____.____|   |__.__|   |______.______|
        type       subtype      parameters

Precedence, Inclusions, and Compatibility Rules

This class encapsulates advanced framework routing logic to determine structural compatibility matching:

  • Inclusion (includes): Evaluates whether a generic MIME expression fully spans another target structure (e.g., text/* includes text/html).
  • Compatibility (isCompatibleWith): Evaluates whether two media envelopes intersect dynamically, taking wildcard definitions and vendor suffixes (+xml, +json) into account.
  • Specificity (isMoreSpecific): Orders dynamic media types to resolve content negotiation loops, prioritizing fully concrete representations over loose wildcard structures.

Immutability & Thread Safety

Once constructed, a MimeType instance is functionally stateless and immutable. String representations are lazily calculated and cached inside _toStringValue using a safe thread-isolated layout to eliminate redundant allocations during repeated logging or serialization phases.

Implemented types

Constructors

MimeType(String type, [String? subtype, Map<String, String>? parameters])
Generates a validated MimeType entry by binding an explicit type, an optional subtype, and a parameters tracking map.
MimeType.copyOf(MimeType other, {Map<String, String>? parameters})
Assembles a fresh MimeType copy from an existing other baseline while selectively overriding or appending extra dictionary parameters.
MimeType.fromCharset(String type, String subtype, String charset)
Specialized generative shortcut constructor binding an explicit type and subtype directly to a tracking charset property.

Properties

charset → String?
Diagnostic getter checking the parameters map for the presence of a localized text charset option.
no setter
hashCode → int
The hash code for this object.
no setteroverride
isConcrete → bool
Returns true if this instance contains completely verified concrete components, lacking any wildcard markers.
no setter
isWildcardSubtype → bool
Returns true if the subtype segment matches a broad wildcard (*) or features a structured trailing wildcard suffix mapping (*+json).
no setter
isWildcardType → bool
Returns true if the core type segment matches the catch-all wildcard token value (*).
no setter
parameters → Map<String, String>
An unmodifiable, case-insensitive mapping tracking secondary media payload attributes (e.g., charset=utf-8, boundary=something).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
subtype → String
The secondary format resolution segment identifier (e.g., "html", "json", "*"). Always lowercased.
final
subtypeSuffix → String?
Extracts the structural suffix extension format out of structured custom subtypes (e.g., returning "xml" out of "application/xhtml+xml").
no setter
type → String
The primary media segment identifier (e.g., "text", "application", "image"). Always lowercased.
final

Methods

compareTo(MimeType other) → int
Standard sorting implementation to arrange media lists alphabetically by type, subtype, and attributes.
override
equalsTypeAndSubtype(MimeType? other) → bool
Shallow comparison checking segment matching keys exclusively, completely ignoring secondary parameters map weights.
getParameter(String name) → String?
Direct parameter retrieval lookup helper sourcing data values straight out of the parameters context index map.
includes(MimeType? other) → bool
Core evaluation routine establishing whether this instance completely spans or encompasses the other mime boundary.
isCompatibleWith(MimeType? other) → bool
Structural evaluation routine verifying whether two MIME types intersect or can coexist within content exchange channels.
isLessSpecific(MimeType other) → bool
Inverse logic proxy matching for specific priority weight calculations. Delegates directly to isMoreSpecific.
isMoreSpecific(MimeType other) → bool
Advanced sorting algorithm tracking media priority weightings for resource routing systems.
isPresentIn(Iterable<MimeType> mimeTypes) → bool
Iterates a dynamic collection of mime contexts to see if any element matches the explicit type and subtype of this instance.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
Serializes the entire configuration state into a canonical, lowercase structural string layout.
override

Operators

operator ==(Object other) → bool
The equality operator.
override

Static Methods

valueOf(String value) → MimeType
Global factory method parsing an un-tokenized string directly into a fully configured MimeType instance. Delegates processing logic to MimeTypeUtils.parseMimeType.