Class ProviderView<T>

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

public class ProviderView<T> extends Provider<T>
Define a filtered view on an underlying provider. The view is defined by a predicate on the items of the provider.
  • Constructor Details

    • ProviderView

      public ProviderView(@NotNull @NotNull Provider<T> provider, @NotNull @NotNull Predicate<T> predicate)
  • Method Details

    • of

      public static <T> Provider<T> of(@NotNull @NotNull Provider<T> provider)
    • of

      public static <T> Provider<T> of(@NotNull @NotNull Provider<T> provider, @NotNull @NotNull Predicate<T> predicate)
    • predicate

      public void predicate(Predicate<T> predicate)
    • 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>
      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>
      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>
      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>