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
,SchemaListJsonWriter
,TaskListWriter
public abstract class DefaultListJsonWriter<EntityType> extends AbstractJsonWriter<List<EntityType>>
Base class to convertList
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 JsonWriter
compatible with the required type must be registered.- Since:
- 7.2
-
-
Field Summary
-
Fields inherited from class org.nuxeo.ecm.core.io.marshallers.json.AbstractJsonWriter
ctx, registry
-
-
Constructor Summary
Constructors Constructor Description DefaultListJsonWriter(String entityType, Class<EntityType> elClazz)
Use this constructor if the element of the list are not based on Java generic type.DefaultListJsonWriter(String entityType, Class<EntityType> elClazz, Type elGenericType)
Use this constructor if the element of the list are based on Java generic type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
extend(List<EntityType> list, com.fasterxml.jackson.core.JsonGenerator jg)
Override this method to write additional information in the list.void
write(List<EntityType> list, com.fasterxml.jackson.core.JsonGenerator jg)
Implement this method to writes the entity in the providedJsonGenerator
.-
Methods inherited from class org.nuxeo.ecm.core.io.marshallers.json.AbstractJsonWriter
accept, getGenerator, write, writeEntity, writeEntity, writeEntityField, writeSerializable, writeSerializableField, writeSerializableListField, writeSerializableMapField
-
-
-
-
Constructor Detail
-
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 useto generate it
-
-
Method Detail
-
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 providedJsonGenerator
.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 providedJsonGenerator
. It may be used is another marshaller calling this one.- Specified by:
write
in classAbstractJsonWriter<List<EntityType>>
- Parameters:
list
- The entity to marshall as Json.jg
- TheJsonGenerator
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
- TheJsonGenerator
which point inside the list object at the end of standard properties.- Throws:
IOException
- Since:
- 7.2
-
-