UrlSerializationAdapter<G extends Generator, P extends Parser, DC extends DeserializationContext<Parser> , SC extends SerializationContext<Generator> > class
final
Serializes and deserializes Dart Url values to and from strings.
The UrlSerializationAdapter provides a unified adapter for handling
Url objects in both serialization and deserialization, supporting JSON
and generic generators/parsers.
Serialization Rules
- Converts the
Urlto its string representation usingtoString(). - Writes the value using
generator.writeString().
Deserialization Rules
- Accepts string values and converts them to
UrlusingUri.parse(raw).toUrl(). - Uses the context's
ConversionServiceif available for type conversion. - Throws FormatException if the input is not a valid string.
Example
final adapter = UrlSerializationAdapter();
final url = Url.parse("https://example.com/path");
adapter.serialize(url, generator, context);
// JSON output: "https://example.com/path"
final parsed = adapter.deserialize(parser, context, Class.forType(Url));
// parsed is a Url instance
Notes
- This adapter expects valid URL strings; malformed strings will result in a runtime exception.
- Implemented types
-
- ObjectSerializable
- ObjectSerializer<
T, G, SC> - ObjectDeserializer<
T, P, DC>
- Annotations
-
- @Generic.new(UrlSerializationAdapter)
Constructors
- UrlSerializationAdapter()
- Creates a new UrlSerializationAdapter.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
canDeserialize(
Class type) → bool -
Returns whether the given
typecan be deserialized by the system.override -
canSerialize(
Class type) → bool -
Returns whether the given
typecan be serialized by the system.override -
deserialize(
P parser, DC ctxt, Class toClass) → Url? -
Deserializes an object of type
Tusing the givenPand DeserializationContext.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
serialize(
Url value, G generator, SC serializer) → void -
Serializes an object of type
Tinto an object using the provided Generator and SerializationContext.override -
supports(
DeserializationContext< Parser> context) → bool -
Determines whether this deserializer supports the given deserialization context.
inherited
-
supportsContext(
SerializationContext< Generator> context) → bool -
Determines whether this serializer supports the given serialization context.
inherited
-
toClass(
) → Class< Url> -
Provides a contract for types capable of exposing their associated
runtime
Classmetadata representation within the Jetleaf reflection system. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited