public class AvroServiceImpl extends Object implements AvroService
Modifier and Type | Field and Description |
---|---|
protected Map<Class<?>,Class<AvroSchemaFactory<?>>> |
factories |
protected Map<Class<?>,AvroMapper<?,?>> |
mappers |
protected List<AvroReplacementDescriptor> |
replacements |
protected AvroSchemaStore |
schemaStore |
Constructor and Description |
---|
AvroServiceImpl(Collection<AvroReplacementDescriptor> replacements,
Map<Class<?>,Class<AvroSchemaFactory<?>>> factories) |
Modifier and Type | Method and Description |
---|---|
protected AvroSchemaFactoryContext |
createContext() |
<D> org.apache.avro.Schema |
createSchema(D input)
Creates the Avro schema from an object.
An AvroSchemaFactory handling the object class has to be implemented and registered to the AvroComponent.. |
String |
decodeName(String input)
Decodes a valid Avro name to its actual value.
|
String |
encodeName(String input)
Encodes a name for it to be eligible to Avro limitations (alphanumeric and _).
By default Nuxeo can encode - and : Other replacements can be registered to the AvroComponent. |
<D,M> D |
fromAvro(org.apache.avro.Schema schema,
Class<D> clazz,
M input)
Map an Avro data to an instance of the given class.
An AvroMapper handling the given class has to be implemented and registered to the AvroComponent.. |
protected <D,M> AvroMapper<D,M> |
getMapper(Class<D> clazz) |
AvroSchemaStore |
getSchemaStore()
Gets the Schema store
|
void |
setMappers(Map<Class<?>,AvroMapper<?,?>> mappers) |
<D,M> M |
toAvro(org.apache.avro.Schema schema,
D input)
Map an object to an Avro data.
An AvroMapper handling the given class has to be implemented and registered. |
protected final Map<Class<?>,Class<AvroSchemaFactory<?>>> factories
protected final List<AvroReplacementDescriptor> replacements
protected final AvroSchemaStore schemaStore
protected Map<Class<?>,AvroMapper<?,?>> mappers
public AvroServiceImpl(Collection<AvroReplacementDescriptor> replacements, Map<Class<?>,Class<AvroSchemaFactory<?>>> factories)
public AvroSchemaStore getSchemaStore()
AvroService
getSchemaStore
in interface AvroService
public <D> org.apache.avro.Schema createSchema(D input)
AvroService
createSchema
in interface AvroService
input
- any objectpublic String decodeName(String input)
AvroService
decodeName
in interface AvroService
input
- the name to decodepublic String encodeName(String input)
AvroService
encodeName
in interface AvroService
input
- the name to encodepublic <D,M> D fromAvro(org.apache.avro.Schema schema, Class<D> clazz, M input)
AvroService
fromAvro
in interface AvroService
schema
- the Avro schemaclazz
- the class to map the Avro object toinput
- the Avro datapublic void setMappers(Map<Class<?>,AvroMapper<?,?>> mappers)
public <D,M> M toAvro(org.apache.avro.Schema schema, D input)
AvroService
toAvro
in interface AvroService
schema
- the Avro schemainput
- the object to map to an Avro dataprotected AvroSchemaFactoryContext createContext()
protected <D,M> AvroMapper<D,M> getMapper(Class<D> clazz)
Copyright © 2019 Nuxeo. All rights reserved.