Class ProviderHasOid<T extends HasOid>

java.lang.Object
net.tangly.core.providers.Provider<T>
net.tangly.core.providers.ProviderHasOid<T>
Type Parameters:
T - type of the items handled in the provider

public class ProviderHasOid<T extends HasOid> extends Provider<T>
The class is a decorator for a provider with entities having a unique object identifier which should be handled through the provider.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ProviderHasOid(@NotNull net.tangly.commons.generator.IdGenerator generator, @NotNull Provider<T> provider)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canBeAdded(T entity)
    Checks if the entity can be added through the provider.
    void
    delete(T entity)
    Deletes the data associated with the entity.
    void
    Deletes all the entities managed by the provider.
    Returns a list containing all known instances of the entity type.
    static <T extends HasOid>
    Provider<T>
    of(@NotNull net.tangly.commons.generator.IdGenerator generator)
     
    static <T extends HasOid>
    Provider<T>
    of(@NotNull net.tangly.commons.generator.IdGenerator generator, @NotNull Iterable<T> items)
     
    static <T extends HasOid>
    Provider<T>
    of(@NotNull net.tangly.commons.generator.IdGenerator generator, @NotNull org.eclipse.store.storage.embedded.types.EmbeddedStorageManager storageManager, @NotNull List<T> items)
     
    void
    update(T entity)
    Updates the data associated with the entity.

    Methods inherited from class net.tangly.core.providers.Provider

    containsById, execute, findBy, findById, findByOid, mutex, replace, updateAll

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ProviderHasOid

      public ProviderHasOid(@NotNull @NotNull net.tangly.commons.generator.IdGenerator generator, @NotNull @NotNull Provider<T> provider)
  • Method Details

    • of

      public static <T extends HasOid> Provider<T> of(@NotNull @NotNull net.tangly.commons.generator.IdGenerator generator)
    • of

      public static <T extends HasOid> Provider<T> of(@NotNull @NotNull net.tangly.commons.generator.IdGenerator generator, @NotNull @NotNull Iterable<T> items)
    • of

      public static <T extends HasOid> Provider<T> of(@NotNull @NotNull net.tangly.commons.generator.IdGenerator generator, @NotNull @NotNull org.eclipse.store.storage.embedded.types.EmbeddedStorageManager storageManager, @NotNull @NotNull List<T> items)
    • canBeAdded

      public boolean canBeAdded(@NotNull T entity)
      Checks if the entity can be added through the provider. The entity can be added either if no entity with the same oid is already stored in the provider, or the stored entity and the entity we shall add is the same Java object.
      Parameters:
      entity - entity to be added
      Returns:
      flag indicating if it is allowed to add the object
    • items

      public List<T> items()
      Description copied from class: Provider
      Returns a list containing all known instances of the entity type.
      Specified by:
      items in class Provider<T extends HasOid>
      Returns:
      list of all instances
    • update

      public void update(@NotNull T entity)
      Description copied from class: Provider
      Updates the data associated with the entity. If the entity is new, the update is handled as a create operation. The update is transitive and all referenced entities are also updated. The entity given as a parameter becomes the instance managed through the provider.
      Specified by:
      update in class Provider<T extends HasOid>
      Parameters:
      entity - entity to update
    • delete

      public void delete(@NotNull T entity)
      Description copied from class: Provider
      Deletes the data associated with the entity. The object identifier is invalidated.
      Specified by:
      delete in class Provider<T extends HasOid>
      Parameters:
      entity - entity to delete
    • deleteAll

      public void deleteAll()
      Description copied from class: Provider
      Deletes all the entities managed by the provider.
      Specified by:
      deleteAll in class Provider<T extends HasOid>