Skip to content

Package: ModuleContext

ModuleContext

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017, 2022 Red Hat Inc and others.
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Red Hat Inc - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.client.gateway.spi;
14:
15: import java.util.Optional;
16:
17: import org.eclipse.kapua.client.gateway.Client;
18:
19: public interface ModuleContext {
20:
21: /**
22: * Get the client instance this module is registered to
23: *
24: * @return the client instance, never returns {@code null}
25: */
26: public Client getClient();
27:
28: /**
29: * Adapt the module context to the requested class
30: *
31: * @param clazz
32: * the class to adapt to
33: * @return the result, never returns {@code null}, but may return {@link Optional#empty()}
34: */
35: public <T> Optional<T> adapt(Class<T> clazz);
36: }