Interface ClientRepository
- All Known Implementing Classes:
ClientMongoRepository,ClientPostgresRepository
public interface ClientRepository
Facade of repository layer for Client entities.
-
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves the unique specified client from the database, if it exists, otherwise it does nothing.findAll()Retrieves all the clients from the database in a list.Retrieves the unique client with the specified identifier from the database, if it exists.findByName(String firstName, String lastName) Retrieves the unique client with the specified name and surname from the database, if it exists.Inserts a new Client in the database or saves changes of an existing one.
-
Method Details
-
findAll
Retrieves all the clients from the database in a list.- Returns:
- the
ListofClients found in the repository.
-
findById
Retrieves the unique client with the specified identifier from the database, if it exists.- Parameters:
id- the identifier of the client to find.- Returns:
- an
Optionalcontained theClientidentified byid, if it exists; anOptionalempty, otherwise.
-
findByName
Retrieves the unique client with the specified name and surname from the database, if it exists.- Parameters:
firstName- the name of the client to find.lastName- the surname of the client to find.- Returns:
- an
Optionalcontained theClientnamedfirstNameandlastName, if it exists; anOptionalempty, otherwise.
-
save
Client save(Client client) throws IllegalArgumentException, UpdateFailureException, NotNullConstraintViolationException, UniquenessConstraintViolationException Inserts a new Client in the database or saves changes of an existing one.- Parameters:
client- the client to save.- Returns:
- the
Clientsaved. - Throws:
IllegalArgumentException- ifclientis null.UpdateFailureException- if the update fails.NotNullConstraintViolationException- if a not-null constraint is violated.UniquenessConstraintViolationException- if a uniqueness constraint is violated.
-
delete
Removes the unique specified client from the database, if it exists, otherwise it does nothing.- Parameters:
client- the client to delete.- Throws:
IllegalArgumentException- ifclientis null.
-