Class DefaultListJsonWriter<EntityType>

java.lang.Object
org.nuxeo.ecm.core.io.marshallers.json.AbstractJsonWriter<List<EntityType>>
org.nuxeo.ecm.core.io.marshallers.json.DefaultListJsonWriter<EntityType>
Type Parameters:
EntityType - The type of the element of this list.
All Implemented Interfaces:
Marshaller<List<EntityType>>, Writer<List<EntityType>>
Direct Known Subclasses:
AnnotationListJsonWriter, AuthenticationTokenListWriter, CommentListJsonWriter, ConstraintListJsonWriter, DirectoryEntryListJsonWriter, DirectoryListJsonWriter, DocumentModelListJsonWriter, DocumentRouteListWriter, DocumentTypeListJsonWriter, FacetListJsonWriter, LogEntryListJsonWriter, MigrationListJsonWriter, NuxeoGroupListJsonWriter, NuxeoOAuth2ServiceProviderListWriter, NuxeoOAuth2TokenListWriter, NuxeoPrincipalListJsonWriter, OAuth2ClientListWriter, ProbeInfoListJsonWriter, SavedSearchListWriter, ScheduleListJsonWriter, SchemaListJsonWriter, TaskListWriter

public abstract class DefaultListJsonWriter<EntityType> extends AbstractJsonWriter<List<EntityType>>
Base class to convert List as json.

It follow the classic Nuxeo list format :

 {
   "entity-type": "GIVEN_ENTITY_TYPE",
                                  <-- pagination info if available are here.
   "entries": [
     {...}, <-- A Writer must be able to manage this format.
     {...},
     ...
     {...}
   ]
 }
 

This list generates pagination information if the list is a Paginable.

This reader delegates the marshalling of entries to the MarshallerRegistry. A Json Writer compatible with the required type must be registered.

Since:
7.2
  • Constructor Details

    • DefaultListJsonWriter

      public DefaultListJsonWriter(String entityType, Class<EntityType> elClazz)
      Use this constructor if the element of the list are not based on Java generic type.
      Parameters:
      entityType - The list "entity-type".
      elClazz - The class of the element of the list.
    • DefaultListJsonWriter

      public DefaultListJsonWriter(String entityType, Class<EntityType> elClazz, Type elGenericType)
      Use this constructor if the element of the list are based on Java generic type.
      Parameters:
      entityType - The list "entity-type".
      elClazz - The class of the element of the list.
      elGenericType - The generic type of the list (you can use to generate it
  • Method Details

    • write

      public void write(List<EntityType> list, com.fasterxml.jackson.core.JsonGenerator jg) throws IOException
      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<List<EntityType>>
      Parameters:
      list - The entity to marshall as Json.
      jg - The JsonGenerator used to produce Json output.
      Throws:
      IOException
    • extend

      protected void extend(List<EntityType> list, com.fasterxml.jackson.core.JsonGenerator jg) throws IOException
      Override this method to write additional information in the list.
      Parameters:
      list - The list to marshal.
      jg - The JsonGenerator which point inside the list object at the end of standard properties.
      Throws:
      IOException
      Since:
      7.2