Class LoadStateDescriptorFactory

java.lang.Object
cz.cvut.kbss.jopa.sessions.descriptor.LoadStateDescriptorFactory

public class LoadStateDescriptorFactory extends Object
Builds LoadStateDescriptors on various occasions.
  • Method Details

    • createNotLoaded

      public static <T> LoadStateDescriptor<T> createNotLoaded(T instance, EntityType<T> et)
      Creates an instance descriptor which marks all attributes except the identifier as not loaded.
      Type Parameters:
      T - Instance type
      Parameters:
      instance - Instance to create descriptor for
      et - Entity type of the instance
      Returns:
      Fresh instance descriptor
    • createAllLoaded

      public static <T> LoadStateDescriptor<T> createAllLoaded(T instance, EntityType<T> et)
      Creates an instance descriptor which marks all attributes as loaded.
      Type Parameters:
      T - Instance type
      Parameters:
      instance - Instance to create descriptor for
      et - Entity type of the instance
      Returns:
      Fresh instance descriptor with all loaded
    • createAllUnknown

      public static <T> LoadStateDescriptor<T> createAllUnknown(T instance, EntityType<T> et)
      Creates an instance descriptor which marks all attributes except the identifier as having an unknown load state.
      Type Parameters:
      T - Instance type
      Parameters:
      instance - Instance to create descriptor for
      et - Entity type of the instance
      Returns:
      Fresh instance descriptor
    • create

      public static <T> LoadStateDescriptor<T> create(T instance, EntityType<T> et)
      Creates an instance descriptor which sets load status of attributes based on their value in the specified instance as follows:

      If the attribute value is not null, its status is set to LoadState.LOADED. If the value is null and the attribute fetch type is FetchType.EAGER, the status is also set to LOADED. Otherwise, the status is set to LoadState.UNKNOWN.

      Type Parameters:
      T - Instance type
      Parameters:
      instance - Instance to create descriptor for
      et - Entity type of the instance
      Returns:
      Fresh instance descriptor
    • createCopy

      public static <T> LoadStateDescriptor<T> createCopy(T instance, LoadStateDescriptor<T> original)
      Copies the load states from the specified original descriptor into a new descriptor for the specified instance.
      Type Parameters:
      T - Instance type
      Parameters:
      instance - Instance to create descriptor for
      original - Load state to copy
      Returns:
      Fresh instance descriptor with state copied from the specified one