AdaptableSet constructor
AdaptableSet()
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
Implementation
AdaptableSet();