Class AbstractJsonEnricher<EntityType>

    • Field Detail

      • MAPPER

        protected static final com.fasterxml.jackson.databind.ObjectMapper MAPPER
    • Constructor Detail

      • AbstractJsonEnricher

        public AbstractJsonEnricher​(String name)
    • Method Detail

      • accept

        public boolean accept​(Class<?> clazz,
                              Type genericType,
                              javax.ws.rs.core.MediaType mediatype)
        Description copied from interface: Marshaller
        Checks if this marshaller can handle the marshalling request.

        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.

        Specified by:
        accept in interface Marshaller<EntityType>
        Overrides:
        accept in class AbstractJsonWriter<Enriched<EntityType>>
        Parameters:
        clazz - The type to marshall.
        genericType - The generic type to marshall.
        mediatype - The managed mimetype.
        Returns:
        true if this converter handle the request, false otherwise.
      • write

        public void write​(Enriched<EntityType> enrichable,
                          com.fasterxml.jackson.core.JsonGenerator jg)
        Description copied from class: AbstractJsonWriter
        Implement this method to writes the entity in the provided 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.

        Specified by:
        write in class AbstractJsonWriter<Enriched<EntityType>>
        Parameters:
        enrichable - The entity to marshall as Json.
        jg - The JsonGenerator used to produce Json output.
      • safeReadBuffer

        protected String safeReadBuffer​(com.fasterxml.jackson.databind.util.TokenBuffer tb)
      • write

        public abstract void write​(com.fasterxml.jackson.core.JsonGenerator jg,
                                   EntityType enriched)
                            throws IOException
        When implementing this method, the provided JsonGenerator expect you write a field name and a field value (or many).
        Parameters:
        jg - The JsonGenerator to use.
        enriched - The enriched entity.
        Throws:
        IOException
        Since:
        7.2