Interface ClientRepository
- All Known Implementing Classes:
ClientMongoRepository
,ClientPostgresRepository
public interface ClientRepository
Facade of repository layer for Client entities.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Removes 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
List
ofClient
s 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
Optional
contained theClient
identified byid
, if it exists; anOptional
empty, 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
Optional
contained theClient
namedfirstName
andlastName
, if it exists; anOptional
empty, 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
Client
saved. - Throws:
IllegalArgumentException
- ifclient
is 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
- ifclient
is null.
-