code: public <T> IMetadataDictionary getMetadataFor(T instance) {
          if (instance == null) {
              throw new IllegalArgumentException("Instance cannot be null");
          }
  
          DocumentInfo documentInfo = getDocumentInfo(instance);
          if (documentInfo.getMetadataInstance() != null) {
              return documentInfo.getMetadataInstance();
          }
  
          ObjectNode metadataAsJson = documentInfo.getMetadata();
          MetadataAsDictionary metadata = new MetadataAsDictionary(metadataAsJson);
          documentInfo.setMetadataInstance(metadata);
          return metadata;
      }
docs: Gets the metadata for the specified entity.
  
  @param <T>      instance class
  @param instance Instance to get metadata from
  @return document metadata