code: private <T extends TypeMetadata> T getMetadata(Class<?> type, Class<T> metadataType) {
          TypeMetadata typeMetadata = metadataByType.get(type);
          if (typeMetadata == null) {
              throw new XOException("Cannot resolve metadata for type " + type.getName() + ".");
          }
          if (!metadataType.isAssignableFrom(typeMetadata.getClass())) {
              throw new XOException(
                      "Expected metadata of type '" + metadataType.getName() + "' but got '" + typeMetadata.getClass() + "' for type '" + type + "'");
          }
          return metadataType.cast(typeMetadata);
      }
docs: Return the {@link TypeMetadata} instance representing the given type.
  
  @param type
  The type.
  @param metadataType
  The expected metadata type.
  @param <T>
  The metadata type.
  @return The {@link TypeMetadata} instance.