whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- XrayAddress address,
- XrayAddress? clientIp,
- int? port,
- bool? skipFallback,
- XrayStringList? domains,
- XrayStringList? expectedIPs,
- XrayStringList? expectIPs,
- DnsQueryStrategy? queryStrategy,
- String? tag,
- int? timeoutMs,
- bool? disableCache,
- bool? serveStale,
- int? serveExpiredTTL,
- bool? finalQuery,
- XrayStringList? unexpectedIPs,
- bool? simplified,
A variant of when that fallback to returning null
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( XrayAddress address, XrayAddress? clientIp, int? port, bool? skipFallback, XrayStringList? domains, XrayStringList? expectedIPs, XrayStringList? expectIPs, DnsQueryStrategy? queryStrategy, String? tag, int? timeoutMs, bool? disableCache, bool? serveStale, int? serveExpiredTTL, bool? finalQuery, XrayStringList? unexpectedIPs, bool? simplified)? $default,) {final _that = this;
switch (_that) {
case _NameServerConfig() when $default != null:
return $default(_that.address,_that.clientIp,_that.port,_that.skipFallback,_that.domains,_that.expectedIPs,_that.expectIPs,_that.queryStrategy,_that.tag,_that.timeoutMs,_that.disableCache,_that.serveStale,_that.serveExpiredTTL,_that.finalQuery,_that.unexpectedIPs,_that.simplified);case _:
return null;
}
}