Skip to content

Package: Wrapper

Wrapper

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2023 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.ontodriver;
19:
20: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
21:
22: /**
23: * Interface for retrieving concrete implementations of the OntoDriver API and/or classes the implementations use (e.g.
24: * classes of the underlying storage framework).
25: */
26: @FunctionalInterface
27: public interface Wrapper {
28:
29: /**
30: * Returns an object that implements the given interface to allow access to non-standard methods, or standard
31: * methods not exposed by the proxy. If the receiver implements the interface then the result is the receiver or a
32: * proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the
33: * result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of calling unwrap
34: * recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not
35: * implement the interface, then an {@link OntoDriverException} is thrown.
36: *
37: * @param cls The type of the required result
38: * @param <T> The type of the class modelled by this Class object
39: * @return An object implementing the interface
40: * @throws OntoDriverException If no matching object is found
41: */
42: <T> T unwrap(Class<T> cls) throws OntoDriverException;
43: }