AdaptableSet class final
A specialized set collection that can adapt itself or another source into a strongly-typed Set of elements.
The AdaptableSet extends HashSet<Object> and provides a generic adapt method that converts:
- JetLeaf-specific HashSet
- Dart collection.HashSet
- Native Dart Set
into a
Set<E>.
Purpose
This class is intended to:
- Facilitate type-safe conversion for heterogeneous sets.
- Enable framework-level or service-level collection adaptation.
- Provide a consistent API across JetLeaf and standard Dart collections.
Features
- Generic adaptation: Converts elements to type
E. - Source flexibility: Supports HashSet, collection.HashSet, and Set.
- Exception safety: Throws IllegalArgumentException when conversion fails.
Lifecycle and Usage
final adaptable = AdaptableSet();
adaptable.addAll([1, 2, 3]);
final typedSet = adaptable.adapt<int>(); // Set<int>
final source = collection.HashSet<dynamic>();
source.addAll(['a', 'b']);
final stringSet = adaptable.adapt<String>(source); // Set<String>
Extensibility
- Subclass to provide custom element conversion rules.
- Integrate with conversion services for automatic type transformations.
Error Handling
- Throws IllegalArgumentException for unsupported or incompatible sources.
See Also
- Inheritance
- Available extensions
Constructors
- AdaptableSet()
- A specialized set collection that can adapt itself or another source into a strongly-typed Set of elements.
-
AdaptableSet.create(List<
Object> entries) -
A specialized set collection that can adapt itself or another source
into a strongly-typed Set of elements.
factory
Properties
- first → Object
-
The first element.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether this collection has no elements.
no setterinherited
- isNotEmpty → bool
-
Whether this collection has at least one element.
no setterinherited
-
iterator
→ Iterator<
Object> -
An iterator that iterates over the elements of this set.
no setterinherited
- last → Object
-
The last element.
no setterinherited
- length → int
-
The number of elements in this Iterable.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- single → Object
-
Checks that this iterable has only one element, and returns that element.
no setterinherited
-
wait
→ Future<
List< T> > -
Available on Iterable<
Waits for futures in parallel.Future< , provided by the FutureIterable extensionT> >no setter
Methods
-
adapt<
E> ([Object? source]) → Set< E> -
Converts the given
sourceorthisinto a strongly-typed Set<E>. -
add(
Object element) → bool -
Adds
valueto the set.inherited -
addAll(
Iterable< Object> elements) → void -
Adds all
elementsto this set.inherited -
any(
bool test(Object element)) → bool -
Checks whether any element of this iterable satisfies
test.inherited -
asNameMap(
) → Map< String, T> -
Available on Iterable<
Creates a map from the names of enum values to the values.T> , provided by the EnumByName extension -
byName(
String name) → T -
Available on Iterable<
Finds the enum value in this list with nameT> , provided by the EnumByName extensionname. -
cast<
R> () → Set< R> -
Provides a view of this set as a set of
Rinstances.inherited -
clear(
) → void -
Removes all elements from the set.
inherited
-
contains(
Object? element) → bool -
Whether
valueis in the set.inherited -
containsAll(
Iterable< Object?> other) → bool -
Whether this set contains all the elements of
other.inherited -
difference(
Set< Object?> other) → Set<Object> -
Creates a new set with the elements of this that are not in
other.inherited -
elementAt(
int index) → Object -
Returns the
indexth element.inherited -
every(
bool test(Object element)) → bool -
Checks whether every element of this iterable satisfies
test.inherited -
expand<
T> (Iterable< T> toElements(Object element)) → Iterable<T> -
Expands each element of this Iterable into zero or more elements.
inherited
-
firstWhere(
bool test(Object element), {Object orElse()?}) → Object -
The first element that satisfies the given predicate
test.inherited -
fold<
T> (T initialValue, T combine(T previousValue, Object element)) → T -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< Object> other) → Iterable<Object> -
Creates the lazy concatenation of this iterable and
other.inherited -
forEach(
void action(Object element)) → void -
Invokes
actionon each element of this iterable in iteration order.inherited -
intersection(
Set< Object?> other) → Set<Object> -
Creates a new set which is the intersection between this set and
other.inherited -
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
lastWhere(
bool test(Object element), {Object orElse()?}) → Object -
The last element that satisfies the given predicate
test.inherited -
lookup(
Object? element) → Object? -
If an object equal to
objectis in the set, return it.inherited -
map<
T> (T toElement(Object e)) → Iterable< T> -
The current elements of this iterable modified by
toElement.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reduce(
Object combine(Object value, Object element)) → Object -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
remove(
Object? value) → bool -
Removes
valuefrom the set.inherited -
removeAll(
Iterable< Object?> elements) → void -
Removes each element of
elementsfrom this set.inherited -
removeWhere(
bool test(Object element)) → void -
Removes all elements of this set that satisfy
test.inherited -
retainAll(
Iterable< Object?> elements) → void -
Removes all elements of this set that are not elements in
elements.inherited -
retainWhere(
bool test(Object element)) → void -
Removes all elements of this set that fail to satisfy
test.inherited -
singleWhere(
bool test(Object element), {Object orElse()?}) → Object -
The single element that satisfies
test.inherited -
skip(
int count) → Iterable< Object> -
Creates an Iterable that provides all but the first
countelements.inherited -
skipWhile(
bool test(Object value)) → Iterable< Object> -
Creates an
Iterablethat skips leading elements whiletestis satisfied.inherited -
sortedByPublicFirst(
) → List< T> -
Available on Iterable<
Sorts declarations with public visibility before private ones.T> , provided by the SortByPublic extension -
sortedByPublicFirstThenSyntheticLast(
) → List< T> -
Available on Iterable<
Sorts declarations with public visibility first and synthetic declarations last.T> , provided by the SortByPublic extension -
take(
int count) → Iterable< Object> -
Creates a lazy iterable of the
countfirst elements of this iterable.inherited -
takeWhile(
bool test(Object value)) → Iterable< Object> -
Creates a lazy iterable of the leading elements satisfying
test.inherited -
toList(
{bool growable = true}) → List< Object> -
Creates a List containing the elements of this Iterable.
inherited
-
toSet(
) → Set< Object> -
Creates a Set with the same elements and behavior as this
Set.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
union(
Set< Object> other) → Set<Object> -
Creates a new set which contains all the elements of this set and
other.inherited -
where(
bool test(Object element)) → Iterable< Object> -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test.inherited -
whereType<
T> () → Iterable< T> -
Creates a new lazy Iterable with all elements that have type
T.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
CLASS
→ Class<
AdaptableMap> -
Represents the metadata class for
AdaptableMap.final