Skip to content

Package: ProviderUtil

ProviderUtil

Coverage

1: /**
2: * Copyright (C) 2022 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.model;
16:
17: /**
18: * Utility interface implemented by the persistence provider. This interface is invoked by the PersistenceUtil
19: * implementation to determine the load status of an entity or entity attribute.
20: */
21: public interface ProviderUtil {
22:
23: /**
24: * If the provider determines that the entity has been provided by itself and that the state of the specified
25: * attribute has been loaded, this method returns LoadState.LOADED.
26: * <p>
27: * If the provider determines that the entity has been provided by itself and that either entity attributes with
28: * FetchType EAGER have not been loaded or that the state of the specified attribute has not been loaded, this
29: * methods returns LoadState.NOT_LOADED.
30: * <p>
31: * If the provider cannot determine the load state, this method returns LoadState.UNKNOWN.
32: * <p>
33: * The provider's implementation of this method must not obtain a reference to an attribute value, as this could
34: * trigger the loading of entity state if the entity has been provided by a different provider.
35: *
36: * @param entity entity instance
37: * @param attributeName name of attribute whose load status is to be determined
38: * @return load status of the attribute
39: */
40: LoadState isLoadedWithoutReference(Object entity, String attributeName);
41:
42: /**
43: * If the provider determines that the entity has been provided by itself and that the state of the specified
44: * attribute has been loaded, this method returns LoadState.LOADED.
45: * <p>
46: * If the provider determines that the entity has been provided by itself and that either entity attributes with
47: * FetchType EAGER have not been loaded or that the state of the specified attribute has not been loaded, this
48: * methods returns LoadState.NOT_LOADED.
49: * <p>
50: * If the provider cannot determine the load state, this method returns LoadState.UNKNOWN.
51: * <p>
52: * The provider's implementation of this method is permitted to obtain a reference to the attribute value. (This
53: * access is safe, because providers which might trigger the loading of the attribute state will have already been
54: * determined by isLoadedWithoutReference.)
55: *
56: * @param entity entity instance
57: * @param attributeName name of attribute whose load status is to be determined
58: * @return load status of the attribute
59: */
60: LoadState isLoadedWithReference(Object entity, String attributeName);
61:
62: /**
63: * If the provider determines that the entity has been provided by itself and that the state of all attributes for
64: * which {@code FetchType.EAGER} has been specified have been loaded, this method returns {@code LoadState.LOADED}.
65: * If the provider determines that the entity has been provided by itself and that not all attributes with {@code
66: * FetchType.EAGER} have been loaded, this method returns {@code LoadState.NOT_LOADED}.
67: * <p>
68: * If the provider cannot determine if the entity has been provided by itself, this method returns {@code
69: * LoadState.UNKNOWN}.
70: * <p>
71: * The provider's implementation of this method must not obtain a reference to any attribute value, as this could
72: * trigger the loading of entity state if the entity has been provided by a different provider.
73: *
74: * @param entity whose loaded status is to be determined
75: * @return load status of the entity
76: */
77: LoadState isLoaded(Object entity);
78: }