element method
Validates whether a specific element can be added to the collective.
Parameters:
element
: The element to validatecollective
: The target collectiveaction
: Optional action context for the validation
Returns true if the element is allowed, false otherwise.
Implementation
bool element(E element, C collective, {Function? action}) {
final tested = Set<TestObject>.identity();
bool process(TestObject obj) {
if (tested.add(obj)) {
for (var e in obj) {
if (e is TestCollectiveElementRule<E,C>) {
try {
if (e.element(element, collective, action: action) == false) {
return false;
}
} on Exception catch(_) {}
}
else if (e is TestObject) {
return process(e);
}
}
}
return true;
}
return process(this);
}