All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ee.carlrobert.llm.client.DeserializationUtil Maven / Gradle / Ivy

There is a newer version: 0.8.28
Show newest version
package ee.carlrobert.llm.client;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import okhttp3.Response;

public class DeserializationUtil {

  private DeserializationUtil() {
  }

  public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
      .setSerializationInclusion(JsonInclude.Include.NON_NULL);

  public static  T mapResponse(Response response, Class clazz) {
    var body = response.body();
    try {
      return OBJECT_MAPPER.readValue(body.string(), clazz);
    } catch (IOException ex) {
      throw new RuntimeException("Could not deserialize response", ex);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy