001package io.ebean.text.json;
002
003import com.fasterxml.jackson.core.JsonParser;
004import io.ebean.bean.PersistenceContext;
005
006/**
007 * Provides a JSON reader that can hold a persistence context and load context while reading JSON.
008 * <p>
009 * This provides a mechanism such that an object loaded from JSON can have unique instances
010 * by using a persistence context and also support further lazy loading (via a load context).
011 * </p>
012 */
013public interface JsonBeanReader<T> {
014
015  /**
016   * Read the JSON returning a bean.
017   */
018  T read();
019
020  /**
021   * Create a new reader taking the context from the existing one but using a new JsonParser.
022   */
023  JsonBeanReader<T> forJson(JsonParser moreJson, boolean resetContext);
024
025  /**
026   * Add a bean explicitly to the persistence context.
027   */
028  void persistenceContextPut(Object beanId, T currentBean);
029
030  /**
031   * Return the persistence context if one is being used.
032   */
033  PersistenceContext getPersistenceContext();
034
035}