whenOrNull<TResult extends Object?> method
- @optionalTypeArgs
- TResult? $default(
- XrayAddress? address,
- int? port,
- TransportProtocol? network,
- SecurityProtocol? security,
- FinalMask? finalmask,
- TCPConfig? rawSettings,
- TCPConfig? tcpSettings,
- SplitHTTPConfig? xhttpSettings,
- KCPConfig? kcpSettings,
- WebSocketConfig? wsSettings,
- HttpUpgradeConfig? httpupgradeSettings,
- SplitHTTPConfig? splithttpSettings,
- GRPCConfig? grpcSettings,
- HysteriaConfig? hysteriaSettings,
- TLSConfig? tlsSettings,
- REALITYConfig? realitySettings,
- SocketConfig? sockopt,
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, int? port, TransportProtocol? network, SecurityProtocol? security, FinalMask? finalmask, TCPConfig? rawSettings, TCPConfig? tcpSettings, SplitHTTPConfig? xhttpSettings, KCPConfig? kcpSettings, WebSocketConfig? wsSettings, HttpUpgradeConfig? httpupgradeSettings, SplitHTTPConfig? splithttpSettings, GRPCConfig? grpcSettings, HysteriaConfig? hysteriaSettings, TLSConfig? tlsSettings, REALITYConfig? realitySettings, SocketConfig? sockopt)? $default,) {final _that = this;
switch (_that) {
case _StreamConfig() when $default != null:
return $default(_that.address,_that.port,_that.network,_that.security,_that.finalmask,_that.rawSettings,_that.tcpSettings,_that.xhttpSettings,_that.kcpSettings,_that.wsSettings,_that.httpupgradeSettings,_that.splithttpSettings,_that.grpcSettings,_that.hysteriaSettings,_that.tlsSettings,_that.realitySettings,_that.sockopt);case _:
return null;
}
}