Package org.mule.metadata.catalog.api
Interface TypeResolver
-
public interface TypeResolverThis object is responsible of looking for aMetadataTypefrom a given reference by delegating the resolution to the rightTypeLoader, where if found aMetadataTypewill be returned. SeeresolveType(String)- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static StringARRAY_SUFFIXstatic StringCATALOG_SEPARATOR
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static TypeResolvercreate(ClassLoader classLoader)Reads the entire file to properly load aTypeResolverstatic TypeResolvercreateFrom(String data, ClassLoader classLoader)Reads the entire content to properly load aTypeResolverstatic TypeResolvercreateFrom(URL url, ClassLoader classLoader)Reads the entire file to properly load aTypeResolverOptional<MetadataType>resolveType(String reference)Returns theMetadataTypeof the specified type if found.
-
-
-
Field Detail
-
CATALOG_SEPARATOR
static final String CATALOG_SEPARATOR
- See Also:
- Constant Field Values
-
ARRAY_SUFFIX
static final String ARRAY_SUFFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
resolveType
Optional<MetadataType> resolveType(String reference) throws TypeResolverException
Returns theMetadataTypeof the specified type if found. The value ofreferencemust be a conjunction of information where it could have the following pieces- The type loader's ID
- The type identifier that might, or might not, contain a selector
TypeResolverwas instantiated by 3 catalogs:- one from an XML schema named "xml-types", with a targetNamespace="http://uri", and two elements named "User" and "Account"
- one from an JSON schema named "json-types", with a definition named "address"
referencemust have one of the following values:- "xml-types::{http://uri}User": to reference the "User" element of the XML schema
- "xml-types::{http://uri}Account": to reference the "Account" element of the XML schema
- "xml-types::{http://uri}Account[]": to reference an array of "Account" element of the XML schema
- "json-types::#/": to reference the complete JSON schema
- "json-types::#/address": to reference the "address" type from within the JSON schema
- "json-types": similarly to "json-types::#/", we will allow that reference to the type loader's ID will map to the root element of the schema (if possible). Useful for samples, and JSON schemas
- "json-types[]": to reference an array of the type loader's ID will map to the root.
TypeResolverwill held the responsibility of providing a fixed set of primitive types, seePrimitiveTypesTypeLoader.PRIMITIVE_TYPES. To reference them, the literal name will be enough:- "string": to reference a
StringType - "boolean": to reference a
BooleanType
- Parameters:
reference- The identifier name of the type- Returns:
- The type if found
- Throws:
TypeResolverException- if thereferencehas a type loader's ID that is absent in the current manager.
-
create
static TypeResolver create(ClassLoader classLoader)
Reads the entire file to properly load aTypeResolver- Parameters:
classLoader- context class loader where the catalog is being created- Returns:
- a
TypeResolver
-
createFrom
static TypeResolver createFrom(URL url, ClassLoader classLoader)
Reads the entire file to properly load aTypeResolver- Parameters:
url- targeting the catalog's URLs locationclassLoader- context class loader where the catalog is being created- Returns:
- a
TypeResolver
-
createFrom
static TypeResolver createFrom(String data, ClassLoader classLoader)
Reads the entire content to properly load aTypeResolver- Parameters:
data- content of an XML with the catalog's documentclassLoader- context class loader where the catalog is being created- Returns:
- a
TypeResolver
-
-