1 package org.synchronoss.cpo.core.meta;
2
3 /*-
4 * [[
5 * core
6 * ==
7 * Copyright (C) 2003 - 2026 Exaxis LLC, Synchronoss Technologies Inc
8 * ==
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Lesser Public License for more details.
18 *
19 * You should have received a copy of the GNU General Lesser Public
20 * License along with this program. If not, see
21 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22 * ]]
23 */
24
25 import java.util.List;
26 import org.synchronoss.cpo.core.CpoException;
27 import org.synchronoss.cpo.core.meta.domain.CpoAttribute;
28 import org.synchronoss.cpo.core.meta.domain.CpoClass;
29 import org.synchronoss.cpo.core.parser.ExpressionParser;
30
31 /**
32 * {@code CpoMetaAdapter} is the datastore-agnostic view over a loaded CPO metadata source: it
33 * resolves the {@link CpoClass} for a given bean, exposes the classes it knows about, and bridges
34 * between the datastore's native data type names/ids and their Java equivalents via the
35 * implementation's {@link DataTypeMapper}.
36 *
37 * @author dberry
38 */
39 public interface CpoMetaAdapter {
40
41 /**
42 * Returns the metadata for the class that is contained within the metadata source
43 *
44 * @param <T> The bean Type
45 * @param bean The java bean whose metaclass is needed
46 * @return the {@link CpoClass} metadata for {@code bean}'s class
47 * @throws CpoException Thrown if there are errors accessing the datasource
48 */
49 <T> CpoClass getMetaClass(T bean) throws CpoException;
50
51 /**
52 * Returns a list of the cpo class objects that the meta adapter is aware of.
53 *
54 * @return java.util.List of CpoClass
55 * @throws CpoException Thrown if there are errors accessing the datasource
56 */
57 List<CpoClass> getCpoClasses() throws CpoException;
58
59 /**
60 * Gets the parser used to extract bind-marker/column information from this metadata source's
61 * native function expressions.
62 *
63 * @return the expression parser for this meta adapter
64 * @throws CpoException if the parser cannot be created
65 */
66 ExpressionParser getExpressionParser() throws CpoException;
67
68 /**
69 * Gets the Java class name that the given attribute's native data type maps to.
70 *
71 * @param attribute the attribute whose data type is being resolved
72 * @return the fully-qualified Java class name (array types are reported as {@code byte[]} or
73 * {@code char[]})
74 * @throws CpoException if the data type cannot be resolved
75 */
76 String getDataTypeName(CpoAttribute attribute) throws CpoException;
77
78 /**
79 * Gets the Java class that the given attribute's native data type maps to.
80 *
81 * @param attribute the attribute whose data type is being resolved
82 * @return the Java class the attribute's value is represented as
83 * @throws CpoException if the data type cannot be resolved
84 */
85 Class<?> getDataTypeJavaClass(CpoAttribute attribute) throws CpoException;
86
87 /**
88 * Gets the integer identifier for a named native data type.
89 *
90 * @param dataTypeName the native data type name
91 * @return the integer identifier registered for {@code dataTypeName}
92 * @throws CpoException if the data type name is not recognized
93 */
94 int getDataTypeInt(String dataTypeName) throws CpoException;
95
96 /**
97 * Gets the full data type mapping entry for a given native data type identifier.
98 *
99 * @param dataTypeInt the integer identifier of the native data type
100 * @return the {@link DataTypeMapEntry} registered for {@code dataTypeInt}
101 * @throws CpoException if the data type identifier is not recognized
102 */
103 DataTypeMapEntry<?> getDataTypeMapEntry(int dataTypeInt) throws CpoException;
104
105 /**
106 * Gets the names of all native data types this meta adapter knows how to map.
107 *
108 * @return the list of allowable native data type names
109 * @throws CpoException if the data types cannot be retrieved
110 */
111 List<String> getAllowableDataTypes() throws CpoException;
112 }