* Find or create a binding for the given key * @param key - Binding address * @param policy - Binding creation policy
(
key: BindingAddress<T>,
policy?: BindingCreationPolicy,
)
| 845 | * @param policy - Binding creation policy |
| 846 | */ |
| 847 | findOrCreateBinding<T>( |
| 848 | key: BindingAddress<T>, |
| 849 | policy?: BindingCreationPolicy, |
| 850 | ) { |
| 851 | let binding: Binding<T>; |
| 852 | if (policy === BindingCreationPolicy.ALWAYS_CREATE) { |
| 853 | binding = this.bind(key); |
| 854 | } else if (policy === BindingCreationPolicy.NEVER_CREATE) { |
| 855 | binding = this.getBinding(key); |
| 856 | } else if (this.isBound(key)) { |
| 857 | // CREATE_IF_NOT_BOUND - the key is bound |
| 858 | binding = this.getBinding(key); |
| 859 | } else { |
| 860 | // CREATE_IF_NOT_BOUND - the key is not bound |
| 861 | binding = this.bind(key); |
| 862 | } |
| 863 | return binding; |
| 864 | } |
| 865 | |
| 866 | /** |
| 867 | * Get the value bound to the given key. |
no test coverage detected