-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(specs): make the searchParams compatible with v4 [skip-bc] (gener…
…ated) algolia/api-clients-automation#4108 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
- Loading branch information
1 parent
58d3451
commit 2a0eef2
Showing
14 changed files
with
617 additions
and
585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
algoliasearch/src/main/java/com/algolia/model/recommend/InsideBoundingBox.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost | ||
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. | ||
|
||
package com.algolia.model.recommend; | ||
|
||
import com.algolia.exceptions.AlgoliaRuntimeException; | ||
import com.fasterxml.jackson.annotation.*; | ||
import com.fasterxml.jackson.core.*; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.*; | ||
import com.fasterxml.jackson.databind.annotation.*; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.logging.Logger; | ||
|
||
/** InsideBoundingBox */ | ||
@JsonDeserialize(using = InsideBoundingBox.Deserializer.class) | ||
public interface InsideBoundingBox { | ||
// InsideBoundingBox as String wrapper. | ||
static InsideBoundingBox of(String value) { | ||
return new StringWrapper(value); | ||
} | ||
|
||
// InsideBoundingBox as List<List<Double>> wrapper. | ||
static InsideBoundingBox of(List<List<Double>> value) { | ||
return new ListOfListOfDoubleWrapper(value); | ||
} | ||
|
||
// InsideBoundingBox as String wrapper. | ||
@JsonSerialize(using = StringWrapper.Serializer.class) | ||
class StringWrapper implements InsideBoundingBox { | ||
|
||
private final String value; | ||
|
||
StringWrapper(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
static class Serializer extends JsonSerializer<StringWrapper> { | ||
|
||
@Override | ||
public void serialize(StringWrapper value, JsonGenerator gen, SerializerProvider provider) throws IOException { | ||
gen.writeObject(value.getValue()); | ||
} | ||
} | ||
} | ||
|
||
// InsideBoundingBox as List<List<Double>> wrapper. | ||
@JsonSerialize(using = ListOfListOfDoubleWrapper.Serializer.class) | ||
class ListOfListOfDoubleWrapper implements InsideBoundingBox { | ||
|
||
private final List<List<Double>> value; | ||
|
||
ListOfListOfDoubleWrapper(List<List<Double>> value) { | ||
this.value = value; | ||
} | ||
|
||
public List<List<Double>> getValue() { | ||
return value; | ||
} | ||
|
||
static class Serializer extends JsonSerializer<ListOfListOfDoubleWrapper> { | ||
|
||
@Override | ||
public void serialize(ListOfListOfDoubleWrapper value, JsonGenerator gen, SerializerProvider provider) throws IOException { | ||
gen.writeObject(value.getValue()); | ||
} | ||
} | ||
} | ||
|
||
class Deserializer extends JsonDeserializer<InsideBoundingBox> { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(Deserializer.class.getName()); | ||
|
||
@Override | ||
public InsideBoundingBox deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { | ||
JsonNode tree = jp.readValueAsTree(); | ||
// deserialize String | ||
if (tree.isTextual()) { | ||
try (JsonParser parser = tree.traverse(jp.getCodec())) { | ||
String value = parser.readValueAs(String.class); | ||
return new InsideBoundingBox.StringWrapper(value); | ||
} catch (Exception e) { | ||
// deserialization failed, continue | ||
LOGGER.finest("Failed to deserialize oneOf String (error: " + e.getMessage() + ") (type: String)"); | ||
} | ||
} | ||
// deserialize List<List<Double>> | ||
if (tree.isArray()) { | ||
try (JsonParser parser = tree.traverse(jp.getCodec())) { | ||
List<List<Double>> value = parser.readValueAs(new TypeReference<List<List<Double>>>() {}); | ||
return new InsideBoundingBox.ListOfListOfDoubleWrapper(value); | ||
} catch (Exception e) { | ||
// deserialization failed, continue | ||
LOGGER.finest("Failed to deserialize oneOf List<List<Double>> (error: " + e.getMessage() + ") (type: List<List<Double>>)"); | ||
} | ||
} | ||
throw new AlgoliaRuntimeException(String.format("Failed to deserialize json element: %s", tree)); | ||
} | ||
|
||
/** Handle deserialization of the 'null' value. */ | ||
@Override | ||
public InsideBoundingBox getNullValue(DeserializationContext ctxt) throws JsonMappingException { | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.