EntityType
- The Java type whose the generated JSON will be enriched.public abstract class AbstractJsonEnricher<EntityType> extends AbstractJsonWriter<Enriched<EntityType>>
ExtensibleEntityJsonWriter
's enricher.Modifier and Type | Field and Description |
---|---|
static String |
ENTITY_ENRICHER_NAME |
Constructor and Description |
---|
AbstractJsonEnricher(String name) |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Class<?> clazz,
Type genericType,
javax.ws.rs.core.MediaType mediatype)
Checks if this marshaller can handle the marshalling request.
|
void |
write(Enriched<EntityType> enrichable,
org.codehaus.jackson.JsonGenerator jg)
Implement this method to writes the entity in the provided
JsonGenerator . |
abstract void |
write(org.codehaus.jackson.JsonGenerator jg,
EntityType enriched)
When implementing this method, the provided
JsonGenerator expect you write a field name and a field value
(or many). |
write
public static final String ENTITY_ENRICHER_NAME
public AbstractJsonEnricher(String name)
public final boolean accept(Class<?> clazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
Marshaller
Please note it's useless to check that clazz is an instance of EntityType or if generic type and entity type are
compatible (unlike JAX-RS which just checks the clazz, not the generic type). It's also useless to check
Supports
is compatible with mediatype. This is already done by the MarshallerRegistry
This method implementation can use injected properties. So you can check the current RenderingContext
to
accept or reject a marshalling request.
accept
in interface Marshaller<Enriched<EntityType>>
accept
in class AbstractJsonWriter<Enriched<EntityType>>
clazz
- The type to marshall.genericType
- The generic type to marshall.mediatype
- The managed mimetype.public void write(Enriched<EntityType> enrichable, org.codehaus.jackson.JsonGenerator jg) throws IOException
AbstractJsonWriter
JsonGenerator
.
This method implementation can use injected properties.
The JsonGenerator
's flushing is done by this abstract class, it's also not not necessary to flush it. Do
not close the provided JsonGenerator
. It may be used is another marshaller calling this one.
write
in class AbstractJsonWriter<Enriched<EntityType>>
enrichable
- The entity to marshall as Json.jg
- The JsonGenerator
used to produce Json output.IOException
public abstract void write(org.codehaus.jackson.JsonGenerator jg, EntityType enriched) throws IOException
JsonGenerator
expect you write a field name and a field value
(or many).jg
- The JsonGenerator
to use.enriched
- The enriched entity.IOException
Copyright © 2015 Nuxeo SA. All rights reserved.