com.algolia.model.recommend.RecommendationsRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of algoliasearch Show documentation
Show all versions of algoliasearch Show documentation
Java client for Algolia Search API
// 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.algolia.utils.CompoundType;
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.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import java.io.IOException;
import java.util.logging.Logger;
/** RecommendationsRequest */
@JsonDeserialize(using = RecommendationsRequest.Deserializer.class)
@JsonSerialize(using = RecommendationsRequest.Serializer.class)
public interface RecommendationsRequest extends CompoundType {
static RecommendationsRequest of(RecommendationsQuery inside) {
return new RecommendationsRequestRecommendationsQuery(inside);
}
static RecommendationsRequest of(TrendingFacetsQuery inside) {
return new RecommendationsRequestTrendingFacetsQuery(inside);
}
static RecommendationsRequest of(TrendingItemsQuery inside) {
return new RecommendationsRequestTrendingItemsQuery(inside);
}
class Serializer extends StdSerializer {
public Serializer(Class t) {
super(t);
}
public Serializer() {
this(null);
}
@Override
public void serialize(RecommendationsRequest value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
jgen.writeObject(value.get());
}
}
class Deserializer extends StdDeserializer {
private static final Logger LOGGER = Logger.getLogger(Deserializer.class.getName());
public Deserializer() {
this(RecommendationsRequest.class);
}
public Deserializer(Class> vc) {
super(vc);
}
@Override
public RecommendationsRequest deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode tree = jp.readValueAsTree();
// deserialize RecommendationsQuery
if (tree.isObject()) {
try (JsonParser parser = tree.traverse(jp.getCodec())) {
RecommendationsQuery value = parser.readValueAs(new TypeReference() {});
return RecommendationsRequest.of(value);
} catch (Exception e) {
// deserialization failed, continue
LOGGER.finest("Failed to deserialize oneOf RecommendationsQuery (error: " + e.getMessage() + ") (type: RecommendationsQuery)");
}
}
// deserialize TrendingFacetsQuery
if (tree.isObject()) {
try (JsonParser parser = tree.traverse(jp.getCodec())) {
TrendingFacetsQuery value = parser.readValueAs(new TypeReference() {});
return RecommendationsRequest.of(value);
} catch (Exception e) {
// deserialization failed, continue
LOGGER.finest("Failed to deserialize oneOf TrendingFacetsQuery (error: " + e.getMessage() + ") (type: TrendingFacetsQuery)");
}
}
// deserialize TrendingItemsQuery
if (tree.isObject()) {
try (JsonParser parser = tree.traverse(jp.getCodec())) {
TrendingItemsQuery value = parser.readValueAs(new TypeReference() {});
return RecommendationsRequest.of(value);
} catch (Exception e) {
// deserialization failed, continue
LOGGER.finest("Failed to deserialize oneOf TrendingItemsQuery (error: " + e.getMessage() + ") (type: TrendingItemsQuery)");
}
}
throw new AlgoliaRuntimeException(String.format("Failed to deserialize json element: %s", tree));
}
/** Handle deserialization of the 'null' value. */
@Override
public RecommendationsRequest getNullValue(DeserializationContext ctxt) throws JsonMappingException {
throw new JsonMappingException(ctxt.getParser(), "RecommendationsRequest cannot be null");
}
}
}
class RecommendationsRequestRecommendationsQuery implements RecommendationsRequest {
private final RecommendationsQuery value;
RecommendationsRequestRecommendationsQuery(RecommendationsQuery value) {
this.value = value;
}
@Override
public RecommendationsQuery get() {
return value;
}
}
class RecommendationsRequestTrendingFacetsQuery implements RecommendationsRequest {
private final TrendingFacetsQuery value;
RecommendationsRequestTrendingFacetsQuery(TrendingFacetsQuery value) {
this.value = value;
}
@Override
public TrendingFacetsQuery get() {
return value;
}
}
class RecommendationsRequestTrendingItemsQuery implements RecommendationsRequest {
private final TrendingItemsQuery value;
RecommendationsRequestTrendingItemsQuery(TrendingItemsQuery value) {
this.value = value;
}
@Override
public TrendingItemsQuery get() {
return value;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy