docs: public byte [] writeDocument(JSONAPIDocument<?> document, SerializationSettings settings)
  			throws DocumentSerializationException {
  		try {
  			resourceCache.init();
  
  			Map<String, ObjectNode> includedDataMap = new HashMap<>();
  
  			ObjectNode result = objectMapper.createObjectNode();
  
  			// Serialize data if present
  			if (document.get() != null) {
  				ObjectNode dataNode = getDataNode(document.get(), includedDataMap, settings);
  				result.set(DATA, dataNode);
  
  				// It is possible that relationships point back to top-level resource, in this case remove it from
  				// included section since it is already present (as a top level resource)
  				String identifier = String.valueOf(getIdValue(document.get()))
  						.concat(configuration.getTypeName(document.get().getClass()));
  				includedDataMap.remove(identifier);
  				result = addIncludedSection(result, includedDataMap);
  			}
  
  			// Serialize errors if present
  			if (document.getErrors() != null) {
  				ArrayNode errorsNode = objectMapper.createArrayNode();
  				for (Error error : document.getErrors()) {
  					errorsNode.add(objectMapper.valueToTree(error));
  				}
  
  				result.set(ERRORS, errorsNode);
  			}
  
  			// Serialize global links and meta
  			serializeMeta(document, result, settings);
  			serializeLinks(document, result, settings);
  			return objectMapper.writeValueAsBytes(result);
  		} catch (Exception e) {
  			throw new DocumentSerializationException(e);
  		} finally {
  			resourceCache.clear();
  		}
  	}