class StudentService {

    public Student insertStudent(Student student) throws ResourceAlreadyExistsException {
        Optional<Student> optionalStudent = studentRepository.findById(student.getId());
        if (optionalStudent.isPresent()) {
            throw new ResourceAlreadyExistsException(student.getId() + "");
        } else {
            return studentRepository.save(student);
        }
    }

    public  StudentService(StudentRepository studentRepository);

}