Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
ThinkModeSerializer.java
Go to the documentation of this file.
1/*
2 * Ollama4j - Java library for interacting with Ollama server.
3 * Copyright (c) 2025 Amith Koujalgi and contributors.
4 *
5 * Licensed under the MIT License (the "License");
6 * you may not use this file except in compliance with the License.
7 *
8*/
9package io.github.ollama4j.models.request;
10
11import com.fasterxml.jackson.core.JsonGenerator;
12import com.fasterxml.jackson.databind.JsonSerializer;
13import com.fasterxml.jackson.databind.SerializerProvider;
14import java.io.IOException;
15
16public class ThinkModeSerializer extends JsonSerializer<ThinkMode> {
17 @Override
18 public void serialize(ThinkMode value, JsonGenerator gen, SerializerProvider serializers)
19 throws IOException {
20 if (value == null) {
21 gen.writeBoolean(false);
22 }
23 if (value == ThinkMode.DISABLED || value == ThinkMode.ENABLED) {
24 gen.writeBoolean((Boolean) value.getValue());
25 } else {
26 gen.writeString(value.getValue().toString());
27 }
28 }
29}
void serialize(ThinkMode value, JsonGenerator gen, SerializerProvider serializers)