Interface InstanceLoader<E>

All Superinterfaces:
DataLoader
All Known Implementing Classes:
InstanceLoaderImpl

@InstallSubject("loadDelegate") public interface InstanceLoader<E> extends DataLoader
Loader of a single entity instance.
  • Method Details

    • getContainer

      InstanceContainer<E> getContainer()
      Returns the container which accepts the loaded entity.
      Specified by:
      getContainer in interface DataLoader
    • setContainer

      void setContainer(InstanceContainer<E> container)
      Sets the container which accepts the loaded entity.
    • getEntityId

      @Nullable Object getEntityId()
      Returns id of the entity to load.
    • setEntityId

      void setEntityId(Object entityId)
      Sets the id of the entity to load.
    • getFetchPlan

      FetchPlan getFetchPlan()
      Returns the fetch plan used for loading the entity.
    • setFetchPlan

      void setFetchPlan(FetchPlan fetchPlan)
      Sets the fetch plan to use for loading the entity.
    • setFetchPlan

      void setFetchPlan(String fetchPlanName)
      Sets the name of the fetch plan to use for loading the entity.
      Throws:
      IllegalStateException - if the fetch plan has already been set by setFetchPlan(FetchPlan)
    • getLoadDelegate

      Function<LoadContext<E>,E> getLoadDelegate()
      Returns a function which will be used to load data instead of standard implementation.
    • setLoadDelegate

      void setLoadDelegate(Function<LoadContext<E>,E> delegate)
      Sets a function which will be used to load data instead of standard implementation.
    • addPreLoadListener

      Subscription addPreLoadListener(Consumer<InstanceLoader.PreLoadEvent<E>> listener)
      Adds a listener to InstanceLoader.PreLoadEvent.

      You can also add an event listener declaratively using a controller method annotated with Subscribe:

          @Subscribe(id = "fooDl", target = Target.DATA_LOADER)
           private void onFooDlPreLoad(InstanceLoader.PreLoadEvent<Foo> event) {
               // handle event here
           }
       
      Parameters:
      listener - listener
      Returns:
      subscription
    • addPostLoadListener

      Subscription addPostLoadListener(Consumer<InstanceLoader.PostLoadEvent<E>> listener)
      Adds a listener to InstanceLoader.PostLoadEvent.

      You can also add an event listener declaratively using a controller method annotated with Subscribe:

          @Subscribe(id = "fooDl", target = Target.DATA_LOADER)
           private void onFooDlPostLoad(InstanceLoader.PostLoadEvent<Foo> event) {
               // handle event here
           }
       
      Parameters:
      listener - listener
      Returns:
      subscription