Skip to content

Package: ProviderUtil

ProviderUtil

Coverage

1: /**
2: * Copyright (C) 2016 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
19: * invoked by the PersistenceUtil implementation to determine the load status of
20: * an entity or entity attribute.
21: */
22: public interface ProviderUtil {
23:
24:         /**
25:          * If the provider determines that the entity has been provided by itself
26:          * and that the state of the specified attribute has been loaded, this
27:          * method returns LoadState.LOADED. If the provider determines that the
28:          * entity has been provided by itself and that either entity attributes with
29:          * FetchType EAGER have not been loaded or that the state of the specified
30:          * attribute has not been loaded, this methods returns LoadState.NOT_LOADED.
31:          * If the provider cannot determine the load state, this method returns
32:          * LoadState.UNKNOWN. The provider's implementation of this method must not
33:          * obtain a reference to an attribute value, as this could trigger the
34:          * loading of entity state if the entity has been provided by a different
35:          * provider.
36:          *
37:          * @param entity
38:          * @param attributeName
39:          * name of attribute whose load status is to be determined
40:          * @return load status of the attribute
41:          */
42:         public LoadState isLoadedWithoutReference(Object entity,
43:                         String attributeName);
44:
45:         /**
46:          * If the provider determines that the entity has been provided by itself
47:          * and that the state of the specified attribute has been loaded, this
48:          * method returns LoadState.LOADED. If the provider determines that the
49:          * entity has been provided by itself and that either entity attributes with
50:          * FetchType EAGER have not been loaded or that the state of the specified
51:          * attribute has not been loaded, this methods returns LoadState.NOT_LOADED.
52:          * If the provider cannot determine the load state, this method returns
53:          * LoadState.UNKNOWN. The provider's implementation of this method is
54:          * permitted to obtain a reference to the attribute value. (This access is
55:          * safe, because providers which might trigger the loading of the attribute
56:          * state will have already been determined by isLoadedWithoutReference. )
57:          *
58:          * @param entity
59:          * @param attributeName
60:          * name of attribute whose load status is to be determined
61:          * @return load status of the attribute
62:          */
63:         public LoadState isLoadedWithReference(Object entity, String attributeName);
64:
65:         public LoadState isLoaded(Object entity);
66:
67: }