code: private void writeSingleton(XMLStreamWriter writer) throws XMLStreamException, ODataRenderException {
          List<Singleton> singletons = getEntityContainer().getSingletons();
          LOG.debug("Number of singletons to be written in service document are {}", singletons.size());
          for (Singleton singleton : singletons) {
              writeElement(writer, METADATA, SERVICE_SINGLETON, ODATA_METADATA_NS,
                      singleton.getName(), singleton.getName());
          }
      }
docs: This writes all singletons in entity data model as collection of "metadata:singleton".
  
  @param writer which writes to stream.
  @throws XMLStreamException   in case of any xml errors
  @throws ODataRenderException if entity container is null.