Class Provider<T>
java.lang.Object
net.tangly.core.providers.Provider<T>
- Type Parameters:
T- type of the instances
- Direct Known Subclasses:
ProviderHasOid,ProviderInMemory,ProviderPersistence,ProviderView
Define the provider abstraction responsible for handling instances of a specific type. The provider declares the regular CRUD operations: Create, Read, Update, and
Delete. The provider is the repository and often the factory in the domain-driven design terminology.
You should store domain-driven domain aggregates in a provider. Each aggregate should have a root with an identifier. All objects of an aggregate are owned by the aggregate and are always edited through the root. The concept defines a natural job and transactional boundary.
- Create
- The creation operation is integrated with the update operation
update(Object) - Read
- The read all items operation maps to the
items()operation. The read an item with a unique key operation maps tofindBy(Function, Object). - Update
- The update operation maps to the operation
update(Object). - Delete
- The delete operation maps to the operation
delete(Object).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsById(@NotNull Provider<? extends HasId> provider, @NotNull String id) abstract voidDeletes the data associated with the entity.abstract voidDeletes all the entities managed by the provider.protected voidReturns the first entity which property matches the value.items()Returns a list containing all known instances of the entity type.protected ReentrantReadWriteLockmutex()voidReplaces an existing value with a new one.abstract voidUpdates the data associated with the entity.voidUpdates the data associated with all entities.
-
Constructor Details
-
Provider
public Provider() -
Provider
-
-
Method Details
-
findByOid
-
findById
-
containsById
-
items
-
update
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.- Parameters:
entity- entity to update
-
delete
Deletes the data associated with the entity. The object identifier is invalidated.- Parameters:
entity- entity to delete
-
deleteAll
public abstract void deleteAll()Deletes all the entities managed by the provider. -
replace
-
updateAll
-
findBy
Returns the first entity which property matches the value.- Type Parameters:
U- type of the property- Parameters:
getter- getter to retrieve the propertyvalue- value to compare with- Returns:
- optional of the first matching entity otherwise empty
-
mutex
-
execute
-