public Client findByName(String name) { for (Client client : clients) { if (client.getNom().equalsIgnoreCase(name)) { return client; } } return null; }
public Client findById(long id) { for (Client client : clients) { if (client.getId_client() == id) { return client; } } return null; }
public void deleteClientById(long id) { for (Iterator<Client> iterator = clients.iterator(); iterator.hasNext(); ) { Client client = iterator.next(); if (client.getId_client() == id) { iterator.remove(); } } }
public boolean isClientExist(Client client) { return findByName(client.getNom()) != null; }
public void saveClient(Client client) { client.setId_client(counter.incrementAndGet()); clients.add(client); }