-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more support for consumer identity provider
- Loading branch information
1 parent
11106c9
commit 7158463
Showing
9 changed files
with
133 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Open Component Model contributors. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package utils | ||
|
||
type Unwrappable interface { | ||
Unwrap() interface{} | ||
} | ||
|
||
func Unwrap(o interface{}) interface{} { | ||
if o != nil { | ||
if u, ok := o.(Unwrappable); ok { | ||
return u.Unwrap() | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func UnwrappingCast[I interface{}](o interface{}) I { | ||
var _nil I | ||
|
||
for o != nil { | ||
if i, ok := o.(I); ok { | ||
return i | ||
} | ||
if i := Unwrap(o); i != o { | ||
o = i | ||
} else { | ||
o = nil | ||
} | ||
} | ||
return _nil | ||
} | ||
|
||
func UnwrappingCall[R any, I any](o interface{}, f func(I) R) R { | ||
var _nil R | ||
|
||
for o != nil { | ||
if i, ok := o.(I); ok { | ||
return f(i) | ||
} | ||
if i := Unwrap(o); i != o { | ||
o = i | ||
} else { | ||
o = nil | ||
} | ||
} | ||
return _nil | ||
} |