Package de.hirola.sportslibrary
Class DataRepository
- java.lang.Object
-
- de.hirola.sportslibrary.DataRepository
-
public final class DataRepository extends Object
Copyright 2021 by Michael Schmidt, Hirola Consulting This software us licensed under the AGPL-3.0 or later. Adds a persistence layer, encapsulating the actual data storage technology used.- Since:
- 1.1.1
- Author:
- Michael Schmidt (Hirola)
-
-
Constructor Summary
Constructors Constructor Description DataRepository(@NotNull String packageName, @Nullable DatastoreDelegate delegate)Create the local datastore access layer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(PersistentObject object)Adds a new object to the local datastore.List<? extends PersistentObject>findAll(Class<? extends PersistentObject> fromType)Get all objects with a given type.booleanisEmpty()Get a flag to determine if the datastore is empty.booleanisOpen()Get a flag to determine if the datastore is open.voidremove(PersistentObject object)Removes an existing object from the local datastore.voidupdate(PersistentObject object)Update an existing object on the local datastore.
-
-
-
Constructor Detail
-
DataRepository
public DataRepository(@NotNull @NotNull String packageName, @Nullable @Nullable DatastoreDelegate delegate) throws SportsLibraryExceptionCreate the local datastore access layer.- Parameters:
packageName- of the app using this librarydelegate- to inform about datastore events, can be null- Throws:
SportsLibraryException- if the datalayer could not initialize
-
-
Method Detail
-
isEmpty
public boolean isEmpty() throws SportsLibraryExceptionGet a flag to determine if the datastore is empty. Some templates are required, which must be imported at the first start.- Returns:
- A flag to determine if the datastore is empty
- Throws:
SportsLibraryException- if an error occurred
-
isOpen
public boolean isOpen()
Get a flag to determine if the datastore is open.- Returns:
- A flag to determine if the datastore is open.
-
add
public void add(PersistentObject object) throws SportsLibraryException
Adds a new object to the local datastore.- Parameters:
object- to be added- Throws:
SportsLibraryException- if an error occurred while adding
-
update
public void update(PersistentObject object) throws SportsLibraryException
Update an existing object on the local datastore.- Parameters:
object- to be updated- Throws:
SportsLibraryException- if an error occurred while updating
-
remove
public void remove(PersistentObject object) throws SportsLibraryException
Removes an existing object from the local datastore.- Parameters:
object- to be removed- Throws:
SportsLibraryException- if an error occurred while removing
-
findAll
public List<? extends PersistentObject> findAll(Class<? extends PersistentObject> fromType) throws SportsLibraryException
Get all objects with a given type.- Parameters:
fromType- of object to get- Returns:
- A list of objects with the given type.
- Throws:
SportsLibraryException- if an error occurred while getting
-
-