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

com.algolia.model.insights.EventsItems Maven / Gradle / Ivy

There is a newer version: 4.10.2
Show newest version
// 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.insights;

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;

/** EventsItems */
@JsonDeserialize(using = EventsItems.Deserializer.class)
@JsonSerialize(using = EventsItems.Serializer.class)
public interface EventsItems extends CompoundType {
  static EventsItems of(ClickedFilters inside) {
    return new EventsItemsClickedFilters(inside);
  }

  static EventsItems of(ClickedObjectIDs inside) {
    return new EventsItemsClickedObjectIDs(inside);
  }

  static EventsItems of(ClickedObjectIDsAfterSearch inside) {
    return new EventsItemsClickedObjectIDsAfterSearch(inside);
  }

  static EventsItems of(ConvertedFilters inside) {
    return new EventsItemsConvertedFilters(inside);
  }

  static EventsItems of(ConvertedObjectIDs inside) {
    return new EventsItemsConvertedObjectIDs(inside);
  }

  static EventsItems of(ConvertedObjectIDsAfterSearch inside) {
    return new EventsItemsConvertedObjectIDsAfterSearch(inside);
  }

  static EventsItems of(ViewedFilters inside) {
    return new EventsItemsViewedFilters(inside);
  }

  static EventsItems of(ViewedObjectIDs inside) {
    return new EventsItemsViewedObjectIDs(inside);
  }

  class Serializer extends StdSerializer {

    public Serializer(Class t) {
      super(t);
    }

    public Serializer() {
      this(null);
    }

    @Override
    public void serialize(EventsItems 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(EventsItems.class);
    }

    public Deserializer(Class vc) {
      super(vc);
    }

    @Override
    public EventsItems deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
      JsonNode tree = jp.readValueAsTree();

      // deserialize ClickedFilters
      if (tree.isObject()) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          ClickedFilters value = parser.readValueAs(new TypeReference() {});
          return EventsItems.of(value);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf ClickedFilters (error: " + e.getMessage() + ") (type: ClickedFilters)");
        }
      }

      // deserialize ClickedObjectIDs
      if (tree.isObject()) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          ClickedObjectIDs value = parser.readValueAs(new TypeReference() {});
          return EventsItems.of(value);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf ClickedObjectIDs (error: " + e.getMessage() + ") (type: ClickedObjectIDs)");
        }
      }

      // deserialize ClickedObjectIDsAfterSearch
      if (tree.isObject()) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          ClickedObjectIDsAfterSearch value = parser.readValueAs(new TypeReference() {});
          return EventsItems.of(value);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest(
            "Failed to deserialize oneOf ClickedObjectIDsAfterSearch (error: " + e.getMessage() + ") (type: ClickedObjectIDsAfterSearch)"
          );
        }
      }

      // deserialize ConvertedFilters
      if (tree.isObject()) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          ConvertedFilters value = parser.readValueAs(new TypeReference() {});
          return EventsItems.of(value);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf ConvertedFilters (error: " + e.getMessage() + ") (type: ConvertedFilters)");
        }
      }

      // deserialize ConvertedObjectIDs
      if (tree.isObject()) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          ConvertedObjectIDs value = parser.readValueAs(new TypeReference() {});
          return EventsItems.of(value);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf ConvertedObjectIDs (error: " + e.getMessage() + ") (type: ConvertedObjectIDs)");
        }
      }

      // deserialize ConvertedObjectIDsAfterSearch
      if (tree.isObject()) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          ConvertedObjectIDsAfterSearch value = parser.readValueAs(new TypeReference() {});
          return EventsItems.of(value);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest(
            "Failed to deserialize oneOf ConvertedObjectIDsAfterSearch (error: " +
            e.getMessage() +
            ") (type: ConvertedObjectIDsAfterSearch)"
          );
        }
      }

      // deserialize ViewedFilters
      if (tree.isObject()) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          ViewedFilters value = parser.readValueAs(new TypeReference() {});
          return EventsItems.of(value);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf ViewedFilters (error: " + e.getMessage() + ") (type: ViewedFilters)");
        }
      }

      // deserialize ViewedObjectIDs
      if (tree.isObject()) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          ViewedObjectIDs value = parser.readValueAs(new TypeReference() {});
          return EventsItems.of(value);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf ViewedObjectIDs (error: " + e.getMessage() + ") (type: ViewedObjectIDs)");
        }
      }
      throw new AlgoliaRuntimeException(String.format("Failed to deserialize json element: %s", tree));
    }

    /** Handle deserialization of the 'null' value. */
    @Override
    public EventsItems getNullValue(DeserializationContext ctxt) throws JsonMappingException {
      throw new JsonMappingException(ctxt.getParser(), "EventsItems cannot be null");
    }
  }
}

class EventsItemsClickedFilters implements EventsItems {

  private final ClickedFilters value;

  EventsItemsClickedFilters(ClickedFilters value) {
    this.value = value;
  }

  @Override
  public ClickedFilters get() {
    return value;
  }
}

class EventsItemsClickedObjectIDs implements EventsItems {

  private final ClickedObjectIDs value;

  EventsItemsClickedObjectIDs(ClickedObjectIDs value) {
    this.value = value;
  }

  @Override
  public ClickedObjectIDs get() {
    return value;
  }
}

class EventsItemsClickedObjectIDsAfterSearch implements EventsItems {

  private final ClickedObjectIDsAfterSearch value;

  EventsItemsClickedObjectIDsAfterSearch(ClickedObjectIDsAfterSearch value) {
    this.value = value;
  }

  @Override
  public ClickedObjectIDsAfterSearch get() {
    return value;
  }
}

class EventsItemsConvertedFilters implements EventsItems {

  private final ConvertedFilters value;

  EventsItemsConvertedFilters(ConvertedFilters value) {
    this.value = value;
  }

  @Override
  public ConvertedFilters get() {
    return value;
  }
}

class EventsItemsConvertedObjectIDs implements EventsItems {

  private final ConvertedObjectIDs value;

  EventsItemsConvertedObjectIDs(ConvertedObjectIDs value) {
    this.value = value;
  }

  @Override
  public ConvertedObjectIDs get() {
    return value;
  }
}

class EventsItemsConvertedObjectIDsAfterSearch implements EventsItems {

  private final ConvertedObjectIDsAfterSearch value;

  EventsItemsConvertedObjectIDsAfterSearch(ConvertedObjectIDsAfterSearch value) {
    this.value = value;
  }

  @Override
  public ConvertedObjectIDsAfterSearch get() {
    return value;
  }
}

class EventsItemsViewedFilters implements EventsItems {

  private final ViewedFilters value;

  EventsItemsViewedFilters(ViewedFilters value) {
    this.value = value;
  }

  @Override
  public ViewedFilters get() {
    return value;
  }
}

class EventsItemsViewedObjectIDs implements EventsItems {

  private final ViewedObjectIDs value;

  EventsItemsViewedObjectIDs(ViewedObjectIDs value) {
    this.value = value;
  }

  @Override
  public ViewedObjectIDs get() {
    return value;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy