Skip to content

Commit

Permalink
Use AtomicInteger in PatientServiceImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
mrts authored Nov 26, 2023
1 parent 839e7ad commit 7d46b4a
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@

import javax.enterprise.context.ApplicationScoped;

import java.util.concurrent.atomic.AtomicInteger;

@ApplicationScoped
public class PatientServiceImpl implements PatientService {

private static int patientNumberGenerator = 1;
private static final AtomicInteger patientNumberGenerator = new AtomicInteger(1);

private CrudService<Patient> service = new CrudService<>();
private final CrudService<Patient> service = new CrudService<>();

@Override
public Patient save(Patient patient) {
patient.setId(String.valueOf(patientNumberGenerator++));
patient.setId(String.valueOf(patientNumberGenerator.getAndIncrement()));
service.save(patient);
return patient;
}
Expand Down

0 comments on commit 7d46b4a

Please sign in to comment.