SetAdapter<E> class
A TypeAdapter
that adapts a raw Object into a strongly typed Set of
type E
.
Jetleaf’s conversion service may return Iterable<Object>
, Set<Object>
,
or HashSet
. This adapter ensures that the raw input is converted into a
Dart Set<E>
.
- If
source
isnull
, an empty set is returned. - If
source
is aSet
, it is directly converted usingSet<E>.from
. - If
source
is aHashSet
, elements are cast and added to a new set. - Otherwise, an
IllegalArgumentException
is thrown.
Example
final adapter = SetAdapter<int>();
final set = adapter.adapt({1, 2, 3}); // {1, 2, 3}
final rawHashSet = HashSet()..addAll([5, 6, 7]);
final adapted = adapter.adapt(rawHashSet); // {5, 6, 7}
final empty = adapter.adapt(null); // {}
- Implemented types
-
- TypeAdapter<
Set< E> >
- TypeAdapter<
- Annotations
-
- @Generic.new(SetAdapter)
Constructors
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
-
adapt(
Object? source) → Set< E> -
A Jetleaf-specific adapter that lifts generic conversion results
into strongly-typed values.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited