Class AbstractD2Writer<EntityType>

java.lang.Object
org.nuxeo.ecm.core.io.marshallers.d2.AbstractD2Writer<EntityType>
All Implemented Interfaces:
Marshaller<EntityType>, Writer<EntityType>
Direct Known Subclasses:
StreamIntrospectionD2Writer

@Supports("text/vnd.d2") public abstract class AbstractD2Writer<EntityType> extends Object implements Writer<EntityType>
Since:
2025.12
  • Field Details

  • Constructor Details

    • AbstractD2Writer

      public AbstractD2Writer()
  • Method Details

    • 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>
      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 final void write(EntityType entity, Class<?> clazz, Type genericType, javax.ws.rs.core.MediaType mediatype, OutputStream out) throws IOException
      Description copied from interface: Writer
      Writes the entity to out OutputStream using mediatype format.

      This method implementation can use injected properties.

      Specified by:
      write in interface Writer<EntityType>
      Parameters:
      entity - The entity to marshall.
      clazz - The requested marshalled class.
      genericType - The requested marshalled generic type.
      mediatype - The target mediatype.
      out - The output of this marshaller.
      Throws:
      IOException - If some error append while writing entity to out.
    • write

      protected abstract void write(EntityType entity, D2Printer d2Printer) throws IOException
      Throws:
      IOException
    • getD2Printer

      protected D2Printer getD2Printer(OutputStream out)