    @Override
    protected void onCreateButton(JButton create) {
        validateVehicleInput();
        create.addActionListener(actionListener -> {
            VehicleTableModel tableModel = (VehicleTableModel) Shortcut.getTableModel(TableCategory.VEHICLES);
            Vehicle vehicle = new Vehicle(
                    licensePlate.getText(),
                    brand.getText(),
                    type.getText(),
                    Integer.parseInt(capacity.getText().trim()),
                    Float.parseFloat(consumption.getText().trim()),
                    (FuelType) fuelType.getSelectedItem());

            tableModel.addRow(vehicle);
            dispose();
        });
    }

    @Override
    protected void onCreateButton(JButton create) {
        create.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //if (!Validator.isValidAddVehicleInputValid()) {
                //    return;
                //}

                VehicleTableModel tableModel = (VehicleTableModel) Shortcut.getTableModel(TableCategory.VEHICLES);
                Vehicle vehicle = new Vehicle(
                        licensePlate.getText(),
                        brand.getText(),
                        type.getText(),
                        Integer.parseInt(capacity.getText().trim()),
                        Float.parseFloat(consumption.getText()),
                        (FuelType) fuelType.getSelectedItem());

                tableModel.addRow(vehicle);
                dispose();
            }
        });
    }

Replace Anonymous With Lambda cz.muni.fi.pv168.seminar01.beta.ui.dialogs.AddEditVehicleDialog.onCreateButton.addActionListener.new ActionListener with actionListener -> {VehicleTableModel tableModel=(VehicleTableModel)Shortcut.getTableModel(TableCategory.VEHICLES); in method protected onCreateButton(create JButton) : void from class cz.muni.fi.pv168.seminar01.beta.ui.dialogs.AddEditVehicleDialog


    protected void onCreateButton(JButton create) {
        create.addActionListener(actionListener -> {
            //TODO - there need to be validation of data inserted

                String[] departureParsedTime = (departure.getText().split("[:.]"));
                LocalTime departureTime = LocalTime.of(Integer.parseInt(departureParsedTime[0]), Integer.parseInt(departureParsedTime[1]));
                String[] arrivalParsedTime = arrival.getText().split("[:.]");
                LocalTime arrivalTime = LocalTime.of(Integer.parseInt(arrivalParsedTime[0]), Integer.parseInt(arrivalParsedTime[1]));
                int parsedDistance = Integer.parseInt(distance.getText());
                RideTableModel tableModel = (RideTableModel) Shortcut.getTableModel(TableCategory.RIDES);

                Ride ride = new Ride(
                        JDatePickerDateGetter.getLocalDate(date),
                        departureTime,
                        arrivalTime,
                        startDestination.getText(),
                        endDestination.getText(),
                        parsedDistance,
                        new HashSet<>(),
                        passengersList.getSelectedValuesList(),
                        (Vehicle) vehicle.getSelectedItem(),
                        (Repetition) repetition.getSelectedItem(),
                        description.getText()
                );
                tableModel.addRow(ride);
                dispose();
            });
    }

    protected void onCreateButton(JButton create) {
        create.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //TODO - there need to be validation of data inserted

                String[] departureParsedTime = (departure.getText().split("[:.]"));
                LocalTime departureTime = LocalTime.of(Integer.parseInt(departureParsedTime[0]), Integer.parseInt(departureParsedTime[1]));
                String[] arrivalParsedTime = arrival.getText().split("[:.]");
                LocalTime arrivalTime = LocalTime.of(Integer.parseInt(arrivalParsedTime[0]), Integer.parseInt(arrivalParsedTime[1]));
                int parsedDistance = Integer.parseInt(distance.getText());
                RideTableModel tableModel = (RideTableModel) Shortcut.getTableModel(TableCategory.RIDES);

                Ride ride = new Ride(
                        JDatePickerDateGetter.getLocalDate(date),
                        departureTime,
                        arrivalTime,
                        startDestination.getText(),
                        endDestination.getText(),
                        parsedDistance,
                        new HashSet<>(),
                        passengersList.getSelectedValuesList(),
                        (Vehicle) vehicle.getSelectedItem(),
                        (Repetition) repetition.getSelectedItem(),
                        description.getText()
                );
                tableModel.addRow(ride);
                dispose();
            }
        });
    }

Replace Anonymous With Lambda cz.muni.fi.pv168.seminar01.beta.ui.dialogs.AddEditRideDialog.onCreateButton.addActionListener.new ActionListener with actionListener -> {String[] departureParsedTime=(departure.getText().split("[:.]")); in method protected onCreateButton(create JButton) : void from class cz.muni.fi.pv168.seminar01.beta.ui.dialogs.AddEditRideDialog


    private void onSaveEditButton(JButton save) {
        save.addActionListener(actionListener -> {
            PassengerTableModel tableModel = (PassengerTableModel) Shortcut.getTableModel(TableCategory.PASSENGERS);
            String nameText = name.getText();
            String surnameText = surname.getText();
            String phoneNumberText = phoneNumber.getText();

            try {
                PassengerValidator.validatePassenger(nameText, surnameText, phoneNumberText);
            }
            catch (ValidationException e) {
                new ErrorDialog(MainWindow.getFrame(), e);
            }
            passenger.setFirstName(nameText);
            passenger.setLastName(surnameText);
            passenger.setPhoneNumber(phoneNumberText);
            passenger.setCategories(getSelectedCategories());
            tableModel.updateRow(passenger);
        });
    }

    private void onSaveEditButton(JButton save) {
        save.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                PassengerTableModel tableModel = (PassengerTableModel) Shortcut.getTableModel(TableCategory.PASSENGERS);
                passenger.setFirstName(name.getText());
                passenger.setLastName(surname.getText());
                passenger.setPhoneNumber(phoneNumber.getText());
                passenger.setCategories(getSelectedCategories());
                tableModel.updateRow(passenger);
            }
        });
    }

Replace Anonymous With Lambda cz.muni.fi.pv168.seminar01.beta.ui.dialogs.AddEditPassengerDialog.onSaveEditButton.addActionListener.new ActionListener with actionListener -> {PassengerTableModel tableModel=(PassengerTableModel)Shortcut.getTableModel(TableCategory.PASSENGERS); in method private onSaveEditButton(save JButton) : void from class cz.muni.fi.pv168.seminar01.beta.ui.dialogs.AddEditPassengerDialog


    @Override
    protected void onCreateButton(JButton create) {
        create.addActionListener(actionListener -> {
            try {
                Passenger passenger = new Passenger(
                        name.getText(),
                        surname.getText(),
                        phoneNumber.getText(),
                        getSelectedCategories()
                );

                PassengerTableModel tableModel = (PassengerTableModel) Shortcut.getTableModel(TableCategory.PASSENGERS);
                tableModel.addRow(passenger);
                dispose();
            } catch (IllegalArgumentException exception) {
                new ErrorDialog(MainWindow.getFrame(), exception.getMessage());
            }
        });
    }

    @Override
    protected void onCreateButton(JButton create) {
        create.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                try {
                    Passenger passenger = new Passenger(
                            name.getText(),
                            surname.getText(),
                            phoneNumber.getText(),
                            getSelectedCategories()
                    );

                    PassengerTableModel tableModel = (PassengerTableModel) Shortcut.getTableModel(TableCategory.PASSENGERS);
                    tableModel.addRow(passenger);
                    dispose();
                } catch (IllegalArgumentException exception) {
                    new ErrorDialog(MainWindow.getFrame(), exception.getMessage());
                }
            }
        });
    }

Replace Anonymous With Lambda cz.muni.fi.pv168.seminar01.beta.ui.dialogs.AddEditPassengerDialog.onCreateButton.addActionListener.new ActionListener with actionListener -> {tryPassenger passenger=new Passenger(name.getText(),surname.getText(),phoneNumber.getText(),getSelectedCategories()); in method protected onCreateButton(create JButton) : void from class cz.muni.fi.pv168.seminar01.beta.ui.dialogs.AddEditPassengerDialog


    @Override
    protected void setAttributes() {
        this.name = UIConstants.createTextField();
        this.surname = UIConstants.createTextField();
        this.phoneNumber = UIConstants.createTextField();
        this.category = new JComboBox<>();
        UIConstants.formatComponentDialog(category);
    }

    @Override
    protected void setAttributes() {
        this.name = UIConstants.createTextField();
        this.surname = UIConstants.createTextField();
        this.phoneNumber = UIConstants.createTextField();
        this.category = new JComboBox<Integer>();
        UIConstants.formatComponentDialog(category);
    }

Replace Generic With Diamond JComboBox<Integer> with JComboBox<> in method protected setAttributes() : void from class cz.muni.fi.pv168.seminar01.beta.UI.Dialogs.AddPassengerDialog


    protected void setAttributes() {
        this.date = new JDatePicker();
        UIConstants.formatComponentDialog(date);
        this.time = UIConstants.createTextField();
        this.startDestination = UIConstants.createTextField();
        this.endDestination = UIConstants.createTextField();
        this.distance = UIConstants.createTextField();
        this.vehicle = new JComboBox<>();
        UIConstants.formatComponentDialog(vehicle);

        // This should be for selecting multiple passengers
        JList<Passenger> passengerList = new JList<Passenger>();
        UIConstants.formatComponentDialog(passengerList);
        passengerList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        JScrollPane passengersScroll = new JScrollPane();
        UIConstants.formatComponentDialog(passengersScroll);
        this.passengers = passengersScroll;

        this.repetition = new JComboBox<Integer>();
        UIConstants.formatComponentDialog(repetition);
    }

    protected void setAttributes() {
        this.date = new JDatePicker();
        UIConstants.formatComponentDialog(date);
        this.time = UIConstants.createTextField();
        this.startDestination = UIConstants.createTextField();
        this.endDestination = UIConstants.createTextField();
        this.distance = UIConstants.createTextField();
        this.vehicle = new JComboBox<Vehicle>();
        UIConstants.formatComponentDialog(vehicle);

        // This should be for selecting multiple passengers
        JList<Passenger> passengerList = new JList<Passenger>();
        UIConstants.formatComponentDialog(passengerList);
        passengerList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        JScrollPane passengersScroll = new JScrollPane();
        UIConstants.formatComponentDialog(passengersScroll);
        this.passengers = passengersScroll;

        this.repetition = new JComboBox<Integer>();
        UIConstants.formatComponentDialog(repetition);
    }

Replace Generic With Diamond JComboBox<Vehicle> with JComboBox<> in method protected setAttributes() : void from class cz.muni.fi.pv168.seminar01.beta.UI.Dialogs.AddRideDialog


    public int inserirAdministrador(Administrador administrador) {
        String sql = "INSERT INTO administrador(nome, email, senha) VALUES (?, ?, ?)";
        try (Connection conn = getConnection();
             PreparedStatement pstmt = conn.prepareStatement(sql)) {

            pstmt.setString(1, administrador.getNome());
            pstmt.setString(2, administrador.getEmail());
            pstmt.setString(3, administrador.getSenha());

            return pstmt.executeUpdate() > 0 ? 1 : 0;

        } catch (SQLException sqlException) {
            sqlException.printStackTrace();
            return -1; // Erro na execução da query
        }
    }

    public int inserirAdministrador(Administrador administrador) {
        Conexao conexao = new Conexao();
        conexao.conectar(); // Conecta ao banco de dados
        Connection conn = conexao.getConn();
        try {
            // Prepara o comando SQL
            PreparedStatement pstmt = conn.prepareStatement("INSERT INTO administrador(nome, email, senha) VALUES (?, ?, ?)");

            // Coloca como parâmetro cada atributo do objeto Administrador por meio dos getters
            pstmt.setString(1, administrador.getNome());
            pstmt.setString(2, administrador.getEmail());
            pstmt.setString(3, administrador.getSenha());

            // Retorna 1 se a execução da query for bem-sucedida, caso contrário, retorna 0
            int rows = pstmt.executeUpdate();
            if (rows > 0){
                return 1;
            }
            return 0;

        } catch (SQLException sqlException) {
            sqlException.printStackTrace();
            return -1; // Retorna -1 se a execução da query for mal-sucedida
        } finally {
            conexao.desconectar(); // Desconecta do banco de dados
        }
    }

Try With Resources try(Connection conn=getConnection(); PreparedStatement pstmt=conn.prepareStatement(sql)) in method public inserirAdministrador(administrador Administrador) : int from class org.constroocrud.crud.DAOs.AdministradorDAO


    public int removerAdministrador(int id) {
        if (buscarAdministradorPeloID(id) == null) {
            return 0; // Não encontrado
        }

        String remover = "DELETE FROM administrador WHERE id = ?";
        try (Connection conn = getConnection();
             PreparedStatement pstmt = conn.prepareStatement(remover)) {

            pstmt.setInt(1, id);
            return pstmt.executeUpdate() > 0 ? 1 : 0;

        } catch (SQLException sqlException) {
            sqlException.printStackTrace();
            return -1; // Erro na execução da query
        }
    }

    public int removerAdministrador(int id) {
        Conexao conexao = new Conexao();
        conexao.conectar(); // Conecta ao banco de dados
        Connection conn = conexao.getConn();

        try {
            // Verifica se existe um administrador com o ID fornecido
            ResultSet resultSet = buscarAdministradorPeloID(id);
            if (!resultSet.next()) {
                return 0; // Retorna 0 se não encontrar o administrador
            }

            // Executa a query
            String remover = "DELETE FROM administrador WHERE id = ?";
            PreparedStatement pstmt = conn.prepareStatement(remover);
            pstmt.setInt(1, id);

            // Retorna 1 se a execução da query for bem-sucedida, caso contrário, retorna 0
            int rows = pstmt.executeUpdate();
            if (rows > 0){
                return 1;
            }
            return 0;

        } catch (SQLException sqlException) {
            sqlException.printStackTrace();
            return -1; // Retorna -1 se a execução da query for mal-sucedida
        } finally {
            conexao.desconectar(); // Desconecta do banco de dados
        }
    }

Try With Resources try(Connection conn=getConnection(); PreparedStatement pstmt=conn.prepareStatement(remover)) in method public removerAdministrador(id int) : int from class org.constroocrud.crud.DAOs.AdministradorDAO


    public int alterarAdministrador(int id, Administrador administrador) {
        String sql = "UPDATE administrador SET nome = ?, email = ?, senha = ? WHERE id = ?";
        try (Connection conn = getConnection();
             PreparedStatement pstmt = conn.prepareStatement(sql)) {

            pstmt.setString(1, administrador.getNome());
            pstmt.setString(2, administrador.getEmail());
            pstmt.setString(3, administrador.getSenha());
            pstmt.setInt(4, id);

            return pstmt.executeUpdate() > 0 ? 1 : 0;

        } catch (SQLException sqlException) {
            sqlException.printStackTrace();
            return -1; // Erro na execução da query
        }
    }

    public int alterarAdministrador(int id, Administrador administrador) {
        Conexao conexao = new Conexao();
        conexao.conectar(); // Conecta ao banco de dados
        Connection conn = conexao.getConn();

        try {
            // Prepara a instrução de atualização
            PreparedStatement pstmt = conn.prepareStatement("UPDATE administrador SET nome = ?, email = ?, senha = ? WHERE id = ?");

            // Define os parâmetros
            pstmt.setString(1, administrador.getNome());
            pstmt.setString(2, administrador.getEmail());
            pstmt.setString(3, administrador.getSenha());
            pstmt.setInt(4, id);

            // Retorna 1 se a execução da query for bem-sucedida, caso contrário, retorna 0
            int rows = pstmt.executeUpdate();
            if (rows > 0){
                return 1;
            }
            return 0;

        } catch (SQLException sqlException) {
            sqlException.printStackTrace();
            return -1; // Retorna -1 se a execução da query for mal-sucedida
        } finally {
            conexao.desconectar(); // Desconecta do banco de dados
        }
    }

Try With Resources try(Connection conn=getConnection(); PreparedStatement pstmt=conn.prepareStatement(sql)) in method public alterarAdministrador(id int, administrador Administrador) : int from class org.constroocrud.crud.DAOs.AdministradorDAO


    public int removerCategoriaProduto(int id) {
        if (buscarCategoriaProdutoPeloID(id) == null) {
            return 0; // Não encontrado
        }

        String remover = "DELETE FROM categoria_produto WHERE id = ?";
        try (Connection conn = getConnection();
             PreparedStatement pstmt = conn.prepareStatement(remover)) {

            pstmt.setInt(1, id);
            return pstmt.executeUpdate() > 0 ? 1 : 0;

        } catch (SQLException sqlException) {
            sqlException.printStackTrace();
            return -1; // Erro na execução da query
        }
    }

    public int removerCategoriaProduto(int id){
        PreparedStatement pstmt;
        Conexao conexao = new Conexao();
        conexao.conectar();
        Connection conn = conexao.getConn();
        try {

            //Verifica se existe um comprador e vendedor nesse ID e atribui ao boolean possuiRegistros
            ResultSet resultSet = buscarCategoriaProdutoPeloID(id);
            if (!resultSet.next()){
                return 0;
            }

            //executa a query
            String remover = "DELETE FROM categoria_produto WHERE id = ?";
            pstmt = conn.prepareStatement(remover);

            pstmt.setInt(1, id);

            // Retorna 1 caso a execução da query seja bem sucedida e 0 caso não ache
            int rows = pstmt.executeUpdate();

            if (rows > 0){
                return 1;
            }else {
                return 0;
            }
        }catch (SQLException sqlException){
            sqlException.printStackTrace();

            // Retorna -1 caso a execução da query seja mal sucedida
            return -1;
        }finally {
            conexao.desconectar();
        }
    }

Try With Resources try(Connection conn=getConnection(); PreparedStatement pstmt=conn.prepareStatement(remover)) in method public removerCategoriaProduto(id int) : int from class org.constroocrud.crud.DAOs.CategoriaProdutoDAO


    public int alterarCategoriaProduto(int id, CategoriaProduto categoriaProduto) {
        String sql = "UPDATE categoria_produto SET nome = ?, descricao = ? WHERE id = ?";
        try (Connection conn = getConnection();
             PreparedStatement pstmt = conn.prepareStatement(sql)) {

            pstmt.setString(1, categoriaProduto.getNome());
            pstmt.setString(2, categoriaProduto.getDescricao());
            pstmt.setInt(3, id);

            return pstmt.executeUpdate() > 0 ? 1 : 0;

        } catch (SQLException sqlException) {
            sqlException.printStackTrace();
            return -1; // Erro na execução da query
        }
    }

    public int alterarCategoriaProduto(int id, CategoriaProduto categoriaProduto) {
        PreparedStatement pstmt = null;
        Conexao conexao = new Conexao();
        conexao.conectar();
        Connection conn = conexao.getConn();
        try {
            // Prepare a single statement with placeholders for all columns
            pstmt = conn.prepareStatement("UPDATE categoria_produto SET nome = ?, descricao = ? WHERE id = ?");

            // Set parameters without quotation marks
            pstmt.setString(1, categoriaProduto.getNome());
            pstmt.setString(2, categoriaProduto.getDescricao());

            pstmt.setInt(3, id);

            // Retorna 1 caso a execução da query seja bem sucedida e 0 caso não ache
            int rows = pstmt.executeUpdate();

            if (rows > 0) {
                return 1;
            } else {
                return 0;
            }
        }catch (SQLException sqlException){
            sqlException.printStackTrace();

            // Retorna -1 caso a execução da query seja mal sucedida
            return -1;
        } finally {
            conexao.desconectar();
        }
    }

Try With Resources try(Connection conn=getConnection(); PreparedStatement pstmt=conn.prepareStatement(sql)) in method public alterarCategoriaProduto(id int, categoriaProduto CategoriaProduto) : int from class org.constroocrud.crud.DAOs.CategoriaProdutoDAO


    @Override
    public boolean readInFile() {
        boolean isRead = false;
        try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                System.out.println(line);
            }
            isRead = true;
        } catch (IOException e) {
            throw new FileReadException("Error reading details from file", 500);
        }
        return isRead;
    }

    @Override
    public boolean readInFile() {
        BufferedReader bufferedReader = null;
        boolean isRead = false;
        try {
            bufferedReader = new BufferedReader(new FileReader(file));
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                System.out.println(line);

            }
            isRead = true;

        } catch (IOException e) {

            throw new FileReadException("Error reading details from file", 500);
        } finally {
            closeBufferedReader(bufferedReader);
        }
        return isRead;

    }

Try With Resources try(BufferedReader bufferedReader=new BufferedReader(new FileReader(file))) in method public readInFile() : boolean from class com.wavemaker.file.repository.impl.FileMethodsRepositoryImpl


    @Override
    public boolean writeInFile(String text) {
        boolean isWrite = false;
        try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file, true))) {
            bufferedWriter.write(text);
            isWrite = true;
        } catch (IOException e) {
            throw new FileWriteException("Error writing details to file", 500);
        }
        return isWrite;
    }

    @Override
    public boolean writeInFile(String text) {
        boolean isWrite = false;
        BufferedWriter bufferedWriter = null;
        try {
            bufferedWriter = new BufferedWriter(new FileWriter(file, true));
            bufferedWriter.write(text);
            isWrite = true;

        } catch (IOException e) {

            throw new FileWriteException("Error writing details from file", 500);
        } finally {
            closeBufferedWriter(bufferedWriter);
        }
        return isWrite;
    }

Try With Resources try(BufferedWriter bufferedWriter=new BufferedWriter(new FileWriter(file,true))) in method public writeInFile(text String) : boolean from class com.wavemaker.file.repository.impl.FileMethodsRepositoryImpl


    @Override
    public List<CharacterSearchResult> getCharacterSearchDetailsInFile(char charSearch) {
        List<CharacterSearchResult> listOfCharacterSearchResult = new ArrayList<>();
        int currentLineNumber = 0;
        int position = 0;

        try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                currentLineNumber++;
                position = 0;
                for (char ch : line.toCharArray()) {
                    position++;
                    if (ch == charSearch) {
                        CharacterSearchResult characterSearchResult = new CharacterSearchResult();
                        characterSearchResult.setCharToSearch(charSearch);
                        characterSearchResult.setFileName(file.getName());
                        characterSearchResult.setFilePath(file.getPath());
                        characterSearchResult.setLineNumber(currentLineNumber);
                        characterSearchResult.setLinePosition(position);
                        listOfCharacterSearchResult.add(characterSearchResult);
                    }
                }
            }
        } catch (IOException e) {
            throw new FileReadException("Error reading details from file", 500);
        }

        return listOfCharacterSearchResult;
    }

    @Override
    public List<CharacterSearchResult> getCharacterSearchDetailsInFile(char charSearch) {
        CharacterSearchResult characterSearchResult = null;
        List<CharacterSearchResult> listOfcharacterSearchResult = new ArrayList<>();
        BufferedReader bufferedReader = null;
        int currentLineNumber = 0;
        int position = 0;
        try {
            bufferedReader = new BufferedReader(new FileReader(file));
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                currentLineNumber++;
                position = 0;
                for (char ch : line.toCharArray()) {
                    position++;
                    if (ch == charSearch) {
                        characterSearchResult = new CharacterSearchResult();
                        characterSearchResult.setCharToSearch(charSearch);
                        characterSearchResult.setFileName(file.getName());
                        characterSearchResult.setFilePath(file.getPath());
                        characterSearchResult.setLineNumber(currentLineNumber);
                        characterSearchResult.setLinePosition(position);
                        listOfcharacterSearchResult.add(characterSearchResult);
                    }
                }

            }
        } catch (IOException e) {
            throw new FileReadException("Error reading details from file", 500);
        } finally {
            closeBufferedReader(bufferedReader);
        }

        return listOfcharacterSearchResult;
    }

Try With Resources try(BufferedReader bufferedReader=new BufferedReader(new FileReader(file))) in method public getCharacterSearchDetailsInFile(charSearch char) : List<CharacterSearchResult> from class com.wavemaker.file.repository.impl.FileMethodsRepositoryImpl


    @Override
    public List<StringSearchResult> getStringSearchDetailsInFile(String stringSearch) {
        List<StringSearchResult> listOfStringSearchResult = new ArrayList<>();
        int currentLineNumber = 0;

        if (stringSearch.isEmpty()) {
            return listOfStringSearchResult;
        }

        try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                currentLineNumber++;
                int index = 0;
                String lineContent = line.toLowerCase();
                String searchString = stringSearch.toLowerCase();
                while ((index = lineContent.indexOf(searchString, index)) != -1) {
                    StringSearchResult stringSearchResult = new StringSearchResult();
                    stringSearchResult.setStringName(stringSearch);
                    stringSearchResult.setFileName(file.getName());
                    stringSearchResult.setFilePath(file.getPath());
                    stringSearchResult.setLineNumber(currentLineNumber);
                    stringSearchResult.setLinePosition(index + 1);
                    listOfStringSearchResult.add(stringSearchResult);
                    index++;
                }
            }
        } catch (IOException e) {
            throw new FileReadException("Error reading details from file", 500);
        }

        return listOfStringSearchResult;
    }

    @Override
    public List<StringSearchResult> getStringSearchDetailsInFile(String stringSearch) {
        StringSearchResult stringSearchResult = null;
        List<StringSearchResult> listOfStringSearchResult = new ArrayList<>();
        int currentLineNumber = 0;
        BufferedReader bufferedReader = null;
        if (stringSearch.isEmpty()) {
            return listOfStringSearchResult;
        }
        try {
            bufferedReader = new BufferedReader(new FileReader(file));
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                currentLineNumber++;
                int index = 0;
                String lineContent = line.toLowerCase();
                String searchString = stringSearch.toLowerCase();
                while ((index = lineContent.indexOf(searchString, index)) != -1) {
                    stringSearchResult = new StringSearchResult();
                    stringSearchResult.setStringName(stringSearch);
                    stringSearchResult.setFileName(file.getName());
                    stringSearchResult.setFilePath(file.getPath());
                    stringSearchResult.setLineNumber(currentLineNumber);
                    stringSearchResult.setLinePosition(index + 1);
                    listOfStringSearchResult.add(stringSearchResult);
                    index++;

                }
            }
        } catch (IOException e) {
            throw new FileReadException("Error reading details from file", 500);
        } finally {
            closeBufferedReader(bufferedReader);
        }
        return listOfStringSearchResult;
    }

Try With Resources try(BufferedReader bufferedReader=new BufferedReader(new FileReader(file))) in method public getStringSearchDetailsInFile(stringSearch String) : List<StringSearchResult> from class com.wavemaker.file.repository.impl.FileMethodsRepositoryImpl


    private void getWordDetailsInFile(File file, String wordSearch, List<WordSearchResult> listOfWordSearchResult) {
        int currentLineNumber = 0;
        int position = 0;

        if (wordSearch.isEmpty()) {
            return;
        }

        try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                currentLineNumber++;
                position = 0;
                String lineContent = line.toLowerCase();
                String searchWord = wordSearch.toLowerCase();
                while ((position = lineContent.indexOf(searchWord, position)) != -1) {
                    WordSearchResult wordSearchResult = new WordSearchResult();
                    wordSearchResult.setWord(wordSearch);
                    wordSearchResult.setFileName(file.getName());
                    wordSearchResult.setFilePath(file.getPath());
                    wordSearchResult.setLineNumber(currentLineNumber);
                    wordSearchResult.setLinePosition(position + 1);
                    listOfWordSearchResult.add(wordSearchResult);
                    position++;
                }
            }
        } catch (IOException e) {
            throw new FileReadException("Error reading details from file", 500);
        }
    }

    private void getWordDetailsInFile(File file, String wordSearch, List<WordSearchResult> listOfWordSearchResult) {
        int currentLineNumber = 0;
        int position = 0;
        BufferedReader bufferedReader = null;
        WordSearchResult wordSearchResult = null;
        if (wordSearch.isEmpty()) {
            return;
        }
        try {
            bufferedReader = new BufferedReader(new FileReader(String.valueOf(file)));
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                currentLineNumber++;
                position = 0;
                String lineContent = line.toLowerCase();
                String searchWord = wordSearch.toLowerCase();
                while ((position = lineContent.indexOf(searchWord, position)) != -1) {
                    wordSearchResult = new WordSearchResult();
                    wordSearchResult.setWord(wordSearch);
                    wordSearchResult.setFileName(file.getName());
                    wordSearchResult.setFilePath(file.getPath());
                    wordSearchResult.setLineNumber(currentLineNumber);
                    wordSearchResult.setLinePosition(position + 1);
                    listOfWordSearchResult.add(wordSearchResult);
                    position++;

                }
            }
        } catch (IOException e) {
            throw new FileReadException("Error reading details from file", 500);
        } finally {
            closeBufferedReader(bufferedReader);
        }

    }

Try With Resources try(BufferedReader bufferedReader=new BufferedReader(new FileReader(file))) in method private getWordDetailsInFile(file File, wordSearch String, listOfWordSearchResult List<WordSearchResult>) : void from class com.wavemaker.file.repository.impl.FileMethodsRepositoryImpl


    @Override
    public void add(ArtMovement entity) {
        if (checkIfExists(entity.getId())) {
            System.out.println("The Art Movement already exists, please try again using an new name!");
            return;
        }
        allArtMovements.add(entity);
//        DB Code:
        String ID = entity.getId();
        String Name = entity.getName();
        java.util.Date StartDate = entity.getStartDate();
        java.util.Date EndDate = entity.getEndDate();

        //----------
        Connection connection;
        try {
            connection = OurConnection.getConnection();
        } catch (ClassNotFoundException | SQLException e) {
            throw new RuntimeException(e);
        }
        try {
            PreparedStatement statement = connection.prepareStatement("INSERT INTO ArtMovement (ID, Name, StartDate, EndDate) VALUES (?, ?, ?, ?)");
            statement.setString(1, ID);
            statement.setString(2, Name);
            java.sql.Date sqlDateStart = new java.sql.Date(StartDate.getTime());
            statement.setDate(3, sqlDateStart);
            java.sql.Date sqlDateEnd = new java.sql.Date(EndDate.getTime());
            statement.setDate(4, sqlDateEnd);
            statement.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        //----------

        System.out.println("Added Art Movement!");
    }

    @Override
    public void add(ArtMovement entity) {
        if (checkIfExists(entity.getId())) {
            System.out.println("The Art Movement already exists, please try again using an new name!");
            return;
        }
        allArtMovements.add(entity);
//        DB Code:
        String ID = entity.getId();
        String Name = entity.getName();
        java.util.Date StartDate = entity.getStartDate();
        java.util.Date EndDate = entity.getEndDate();

        //----------
        Connection connection = null;
        try {
            connection = OurConnection.getConnection();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        try {
            PreparedStatement statement = connection.prepareStatement("INSERT INTO ArtMovement (ID, Name, StartDate, EndDate) VALUES (?, ?, ?, ?)");
            statement.setString(1, ID);
            statement.setString(2, Name);
            java.sql.Date sqlDateStart = new java.sql.Date(StartDate.getTime());
            statement.setDate(3, sqlDateStart);
            java.sql.Date sqlDateEnd = new java.sql.Date(EndDate.getTime());
            statement.setDate(4, sqlDateEnd);
            statement.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        //----------

        System.out.println("Added Art Movement!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public add(entity ArtMovement) : void from class repository.database.ArtMovementDB


    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        ArtMovement ArtMovementToDelete = null;
        for (ArtMovement a : allArtMovements) {
            if (a.getId().equals(id)) {
                found = true;
                ArtMovementToDelete = a;
            }
        }
        if (found) {
            allArtMovements.remove(ArtMovementToDelete);
            ArtMovementToDelete.setName(newName);
            allArtMovements.add(ArtMovementToDelete);
            System.out.println("Updated name!");
            // DB Code:
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE ArtMovement SET Name = ? WHERE ArtMovement.ID = ?");
                statement.setString(1, newName);
                statement.setString(2, id);
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            System.out.println("Updated name!");
            return;
        }
        System.out.println("The Art Movement you want to update does not exist!");
    }

    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        ArtMovement ArtMovementToDelete = null;
        for (ArtMovement a : allArtMovements) {
            if (a.getId().equals(id)) {
                found = true;
                ArtMovementToDelete = a;
            }
        }
        if (found) {
            allArtMovements.remove(ArtMovementToDelete);
            ArtMovementToDelete.setName(newName);
            allArtMovements.add(ArtMovementToDelete);
            System.out.println("Updated name!");
            // DB Code:
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE ArtMovement SET Name = ? WHERE ArtMovement.ID = ?");
                statement.setString(1, newName);
                statement.setString(2, id);
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            System.out.println("Updated name!");
            return;
        }
        System.out.println("The Art Movement you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateName(id String, newName String) : void from class repository.database.ArtMovementDB


    public void updateDateStarted(String id, java.util.Date newDate) {
        for (ArtMovement aToUpdate : allArtMovements) {
            if (id.equals(aToUpdate.getId())) {
                allArtMovements.remove(aToUpdate);
                aToUpdate.setStartDate(newDate);
                allArtMovements.add(aToUpdate);
//                DB Code:
                Connection connection;
                try {
                    connection = OurConnection.getConnection();
                } catch (ClassNotFoundException | SQLException e) {
                    throw new RuntimeException(e);
                }
                try {
                    PreparedStatement statement = connection.prepareStatement("UPDATE ArtMovement SET StartDate = ? WHERE ArtMovement.ID = ?");
                    java.sql.Date sqlDate = new java.sql.Date(newDate.getTime());
                    statement.setDate(1, sqlDate);
                    statement.setString(2, id);
                    statement.executeUpdate();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("Updated date!");
                return;
            }
        }
        System.out.println("Wrong id, please try again using an existing one!");
    }

    public void updateDateStarted(String id, java.util.Date newDate) {
        for (ArtMovement aToUpdate : allArtMovements) {
            if (id.equals(aToUpdate.getId())) {
                allArtMovements.remove(aToUpdate);
                aToUpdate.setStartDate(newDate);
                allArtMovements.add(aToUpdate);
//                DB Code:
                Connection connection = null;
                try {
                    connection = OurConnection.getConnection();
                } catch (ClassNotFoundException e) {
                    throw new RuntimeException(e);
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }
                try {
                    PreparedStatement statement = connection.prepareStatement("UPDATE ArtMovement SET StartDate = ? WHERE ArtMovement.ID = ?");
                    java.sql.Date sqlDate = new java.sql.Date(newDate.getTime());
                    statement.setDate(1, sqlDate);
                    statement.setString(2, id);
                    statement.executeUpdate();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("Updated date!");
                return;
            }
        }
        System.out.println("Wrong id, please try again using an existing one!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateDateStarted(id String, newDate Date) : void from class repository.database.ArtMovementDB


    public void updateDateEnded(String id, java.util.Date newDate) {
        for (ArtMovement aToUpdate : allArtMovements) {
            if (id.equals(aToUpdate.getId())) {
                allArtMovements.remove(aToUpdate);
                aToUpdate.setEndDate(newDate);
                allArtMovements.add(aToUpdate);
                //                DB Code:
                Connection connection;
                try {
                    connection = OurConnection.getConnection();
                } catch (ClassNotFoundException | SQLException e) {
                    throw new RuntimeException(e);
                }
                try {
                    PreparedStatement statement = connection.prepareStatement("UPDATE ArtMovement SET EndDate = ? WHERE ArtMovement.ID = ?");
                    java.sql.Date sqlDate = new java.sql.Date(newDate.getTime());
                    statement.setDate(1, sqlDate);
                    statement.setString(2, id);
                    statement.executeUpdate();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("Successful change! Updated date!");
                return;
            }
        }
        System.out.println("Wrong id, please try again using an existing one!");
    }

    public void updateDateEnded(String id, java.util.Date newDate) {
        for (ArtMovement aToUpdate : allArtMovements) {
            if (id.equals(aToUpdate.getId())) {
                allArtMovements.remove(aToUpdate);
                aToUpdate.setEndDate(newDate);
                allArtMovements.add(aToUpdate);
                //                DB Code:
                Connection connection = null;
                try {
                    connection = OurConnection.getConnection();
                } catch (ClassNotFoundException e) {
                    throw new RuntimeException(e);
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }
                try {
                    PreparedStatement statement = connection.prepareStatement("UPDATE ArtMovement SET EndDate = ? WHERE ArtMovement.ID = ?");
                    java.sql.Date sqlDate = new java.sql.Date(newDate.getTime());
                    statement.setDate(1, sqlDate);
                    statement.setString(2, id);
                    statement.executeUpdate();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("Succesful change! Updated date!");
                return;
            }
        }
        System.out.println("Wrong id, please try again using an existing one!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateDateEnded(id String, newDate Date) : void from class repository.database.ArtMovementDB


    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        Artist artistToDelete = null;
        for (Artist a : allArtists) {
            if (a.getId().equals(id)) {
                found = true;
                artistToDelete = a;
            }
        }
        if (found) {
            allArtists.remove(artistToDelete);
            artistToDelete.setName(newName);
            allArtists.add(artistToDelete);
            // DB Code:
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            System.out.println("Updated name!");
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Artist SET Name = ? WHERE Artist.ID = ?");
                statement.setString(1, newName);
                statement.setString(2, id);
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            System.out.println("Updated name!");
            return;
        }
        System.out.println("The artist you want to update does not exist!");
    }

    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        Artist artistToDelete = null;
        for (Artist a : allArtists) {
            if (a.getId().equals(id)) {
                found = true;
                artistToDelete = a;
            }
        }
        if (found) {
            allArtists.remove(artistToDelete);
            artistToDelete.setName(newName);
            allArtists.add(artistToDelete);
            // DB Code:
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            System.out.println("Updated name!");
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Artist SET Name = ? WHERE Artist.ID = ?");
                statement.setString(1, newName);
                statement.setString(2, id);
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            System.out.println("Updated name!");
            return;
        }
        System.out.println("The artist you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateName(id String, newName String) : void from class repository.database.ArtistDB


    public void updateDateBorn(String id, java.util.Date newDate) {
        for (Artist aToUpdate : allArtists) {
            if (id.equals(aToUpdate.getId())) {
                allArtists.remove(aToUpdate);
                aToUpdate.setBirthDate(newDate);
                allArtists.add(aToUpdate);
//                DB Code:
                Connection connection;
                try {
                    connection = OurConnection.getConnection();
                } catch (ClassNotFoundException | SQLException e) {
                    throw new RuntimeException(e);
                }
                try {
                    PreparedStatement statement = connection.prepareStatement("UPDATE Artist SET BirthDate = ? WHERE Artist.ID = ?");
                    java.sql.Date sqlDate = new java.sql.Date(newDate.getTime());
                    statement.setDate(1, sqlDate);
                    statement.setString(2, id);
                    statement.executeUpdate();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("Updated date!");
                return;
            }
        }
        System.out.println("Wrong id, please try again using an existing one!");
    }

    public void updateDateBorn(String id, java.util.Date newDate) {
        for (Artist aToUpdate : allArtists) {
            if (id.equals(aToUpdate.getId())) {
                allArtists.remove(aToUpdate);
                aToUpdate.setBirthDate(newDate);
                allArtists.add(aToUpdate);
//                DB Code:
                Connection connection = null;
                try {
                    connection = OurConnection.getConnection();
                } catch (ClassNotFoundException e) {
                    throw new RuntimeException(e);
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }
                try {
                    PreparedStatement statement = connection.prepareStatement("UPDATE Artist SET BirthDate = ? WHERE Artist.ID = ?");
                    java.sql.Date sqlDate = new java.sql.Date(newDate.getTime());
                    statement.setDate(1, sqlDate);
                    statement.setString(2, id);
                    statement.executeUpdate();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("Updated date!");
                return;
            }
        }
        System.out.println("Wrong id, please try again using an existing one!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateDateBorn(id String, newDate Date) : void from class repository.database.ArtistDB


    @Override
    public void add(Block entity) {
        if (checkIfExists(entity.getId())) {
            System.out.println("The Block already exists, please try again using an new name!");
            return;
        }
        allBlocks.add(entity);
//        DB Code:
        String Name = entity.getName();
        Museum museum = entity.getMuseum();
        String ID = entity.getId();

        //----------
        Connection connection;
        try {
            connection = OurConnection.getConnection();
        } catch (ClassNotFoundException | SQLException e) {
            throw new RuntimeException(e);
        }
        try {
            PreparedStatement statement = connection.prepareStatement("INSERT INTO Block (ID, Name, Museum) VALUES (?, ?, ?)");
            statement.setString(1, ID);
            statement.setString(2, Name);
            statement.setString(3, museum.getName());
            statement.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        //----------

        System.out.println("Added Block!");
    }

    @Override
    public void add(Block entity) {
        if (checkIfExists(entity.getId())) {
            System.out.println("The Block already exists, please try again using an new name!");
            return;
        }
        allBlocks.add(entity);
//        DB Code:
        String Name = entity.getName();
        Museum museum = entity.getMuseum();
        String ID = entity.getId();

        //----------
        Connection connection = null;
        try {
            connection = OurConnection.getConnection();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        try {
            PreparedStatement statement = connection.prepareStatement("INSERT INTO Block (ID, Name, Museum) VALUES (?, ?, ?)");
            statement.setString(1, ID);
            statement.setString(2, Name);
            statement.setString(3, museum.getName());
            statement.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        //----------

        System.out.println("Added Block!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public add(entity Block) : void from class repository.database.BlockDB


    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        Block BlockToDelete = null;
        for (Block a : allBlocks) {
            if (a.getId().equals(id)) {
                found = true;
                BlockToDelete = a;
            }
        }
        if (found) {
            allBlocks.remove(BlockToDelete);
            BlockToDelete.setName(newName);
            allBlocks.add(BlockToDelete);
            // DB Code:
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Block  SET Name = ? WHERE Block.ID = ?");
                statement.setString(1, String.valueOf(newName));
                statement.setString(2, id);
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            System.out.println("Updated name!");
            return;
        }
        System.out.println("The Block you want to update does not exist!");
    }

    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        Block BlockToDelete = null;
        for (Block a : allBlocks) {
            if (a.getId().equals(id)) {
                found = true;
                BlockToDelete = a;
            }
        }
        if (found) {
            allBlocks.remove(BlockToDelete);
            BlockToDelete.setName(newName);
            allBlocks.add(BlockToDelete);
            // DB Code:
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Block  SET Name = ? WHERE Block.ID = ?");
                statement.setString(1, String.valueOf(newName));
                statement.setString(2, id);
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            System.out.println("Updated name!");
            return;
        }
        System.out.println("The Block you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateName(id String, newName String) : void from class repository.database.BlockDB


    public void updateMuseum(String id, Museum newMuseum) {
        boolean found = false;
        Block BlockToDelete = null;
        for (Block a : allBlocks) {
            if (a.getId().equals(id)) {
                found = true;
                BlockToDelete = a;
            }
        }
        if (found) {
            allBlocks.remove(BlockToDelete);
            BlockToDelete.setMuseum(newMuseum);
            allBlocks.add(BlockToDelete);
            // DB Code:
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Block SET Museum = ? WHERE Block.ID = ?");
                statement.setString(1, newMuseum.getName());
                statement.setString(2, id);
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            System.out.println("Updated name!");
            return;
        }
        System.out.println("The Block you want to update does not exist!");
    }

    public void updateMuseum(String id, Museum newMuseum) {
        boolean found = false;
        Block BlockToDelete = null;
        for (Block a : allBlocks) {
            if (a.getId().equals(id)) {
                found = true;
                BlockToDelete = a;
            }
        }
        if (found) {
            allBlocks.remove(BlockToDelete);
            BlockToDelete.setMuseum(newMuseum);
            allBlocks.add(BlockToDelete);
            // DB Code:
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Block SET Museum = ? WHERE Block.ID = ?");
                statement.setString(1, newMuseum.getName());
                statement.setString(2, id);
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            System.out.println("Updated name!");
            return;
        }
        System.out.println("The Block you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateMuseum(id String, newMuseum Museum) : void from class repository.database.BlockDB


    @Override
    public void add(Client entity) {
        if (checkIfExists(entity.getId())) {
            System.out.println("The Client already exists, please try again using an new name!");
            return;
        }
        allClients.add(entity);
//        DB Code:
        String ID = entity.getId();
        String Name = entity.getName();

        //----------
        Connection connection;
        try {
            connection = OurConnection.getConnection();
        } catch (ClassNotFoundException | SQLException e) {
            throw new RuntimeException(e);
        }
        try {
            PreparedStatement statement = connection.prepareStatement("INSERT INTO Client (ID, Name) VALUES (?, ?)");
            statement.setString(1, ID);
            statement.setString(2, Name);
            statement.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        //----------

        System.out.println("Added Client!");
    }

    @Override
    public void add(Client entity) {
        if (checkIfExists(entity.getId())) {
            System.out.println("The Client already exists, please try again using an new name!");
            return;
        }
        allClients.add(entity);
//        DB Code:
        String ID = entity.getId();
        String Name = entity.getName();

        //----------
        Connection connection = null;
        try {
            connection = OurConnection.getConnection();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        try {
            PreparedStatement statement = connection.prepareStatement("INSERT INTO Client (ID, Name) VALUES (?, ?)");
            statement.setString(1, ID);
            statement.setString(2, Name);
            statement.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        //----------

        System.out.println("Added Client!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public add(entity Client) : void from class repository.database.ClientDB


    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        Client ClientToDelete = null;
        for (Client a : allClients) {
            if (a.getId().equals(id)) {
                found = true;
                ClientToDelete = a;
            }
        }
        if (found) {
            allClients.remove(ClientToDelete);
            ClientToDelete.setName(newName);
            allClients.add(ClientToDelete);
            System.out.println("Updated name!");
            // DB Code:
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Client SET Name = ? WHERE Client.ID = ?");
                statement.setString(1, String.valueOf(newName));
                statement.setString(2, id);
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            return;
        }
        System.out.println("The Client you want to update does not exist!");
    }

    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        Client ClientToDelete = null;
        for (Client a : allClients) {
            if (a.getId().equals(id)) {
                found = true;
                ClientToDelete = a;
            }
        }
        if (found) {
            allClients.remove(ClientToDelete);
            ClientToDelete.setName(newName);
            allClients.add(ClientToDelete);
            System.out.println("Updated name!");
            // DB Code:
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Client SET Name = ? WHERE Client.ID = ?");
                statement.setString(1, String.valueOf(newName));
                statement.setString(2, id);
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            return;
        }
        System.out.println("The Client you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateName(id String, newName String) : void from class repository.database.ClientDB


    @Override
    public void add(Museum entity) {
        if (checkIfExists(entity.getName())) {
            System.out.println("The Museum already exists, please try again using an new name!");
            return;
        }
        allMuseums.add(entity);
//        DB Code:
        String Name = entity.getName();

        //----------
        Connection connection;
        try {
            connection = OurConnection.getConnection();
        } catch (ClassNotFoundException | SQLException e) {
            throw new RuntimeException(e);
        }
        try {
            PreparedStatement statement = connection.prepareStatement("INSERT INTO Museum (Name) VALUES (?)");
            statement.setString(1, Name);
            statement.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        //----------

        System.out.println("Added Museum!");
    }

    @Override
    public void add(Museum entity) {
        if (checkIfExists(entity.getName())) {
            System.out.println("The Museum already exists, please try again using an new name!");
            return;
        }
        allMuseums.add(entity);
//        DB Code:
        String Name = entity.getName();

        //----------
        Connection connection = null;
        try {
            connection = OurConnection.getConnection();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        try {
            PreparedStatement statement = connection.prepareStatement("INSERT INTO Museum (Name) VALUES (?)");
            statement.setString(1, Name);
            statement.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        //----------

        System.out.println("Added Museum!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public add(entity Museum) : void from class repository.database.MuseumDB


    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        Museum MuseumToDelete = null;
        for (Museum a : allMuseums) {
            if (a.getName().equals(newName)) {
                System.out.println("The museum name you want to change to already exists!");
                return;
            }
        }
        for (Museum a : allMuseums) {
            if (a.getName().equals(id)) {
                found = true;
                MuseumToDelete = a;
            }
        }
        if (found) {
            String oldName = MuseumToDelete.getName();
            allMuseums.remove(MuseumToDelete);
            MuseumToDelete.setName(newName);
            allMuseums.add(MuseumToDelete);
            //----------
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("DELETE Museum WHERE Museum.Name = ? INSERT INTO Museum(Name) Values (?)");
                statement.setString(1, oldName);
                statement.setString(2, newName);
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated name!");
            return;
        }
        System.out.println("The Museum you want to update does not exist!");
    }

    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        Museum MuseumToDelete = null;
        for (Museum a : allMuseums) {
            if (a.getName().equals(newName)) {
                System.out.println("The museum name you want to change to already exists!");
                return;
            }
        }
        for (Museum a : allMuseums) {
            if (a.getName().equals(id)) {
                found = true;
                MuseumToDelete = a;
            }
        }
        if (found) {
            String oldName = MuseumToDelete.getName();
            allMuseums.remove(MuseumToDelete);
            MuseumToDelete.setName(newName);
            allMuseums.add(MuseumToDelete);
            //----------
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement  statement = connection.prepareStatement("DELETE Museum WHERE Museum.Name = ? INSERT INTO Museum(Name) Values (?)");
                statement.setString(1, oldName);
                statement.setString(2, newName);
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated name!");
            return;
        }
        System.out.println("The Museum you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateName(id String, newName String) : void from class repository.database.MuseumDB


    @Override
    public void add(Painting entity) throws ClassNotFoundException {
        if (checkIfExists(entity.getId())) {
            System.out.println("The Painting already exists, please try again using an new name!");
            return;
        }
        allPaintings.add(entity);
        BlockDB.getInstance().findById(entity.getLocation().getId()).addMovement(entity.getArtMovement());
        BlockDB.getInstance().findById(entity.getLocation().getId()).addArtist(entity.getPainter());
//        DB Code:
        Artist Painter = entity.getPainter();
        ArtMovement Artmovement = entity.getArtMovement();
        Block Location = entity.getLocation();
        double Price = entity.getPrice();
        java.util.Date Creation = entity.getCreation();
        String Name = entity.getName();
        String ID = entity.getId();

        //----------
        Connection connection;
        try {
            connection = OurConnection.getConnection();
        } catch (ClassNotFoundException | SQLException e) {
            throw new RuntimeException(e);
        }
        try {
            PreparedStatement statement = connection.prepareStatement("INSERT INTO Painting (ID, Name, Creation, Price, Location, ArtMovement, Painter) VALUES (?, ?, ?, ?, ?, ?, ?)");
            statement.setString(1, ID);
            statement.setString(2, Name);
            java.sql.Date sqlDate = new java.sql.Date(Creation.getTime());
            statement.setDate(3, sqlDate);
            statement.setDouble(4, Price);
            statement.setString(5, Location.getId());
            statement.setString(6, Artmovement.getId());
            statement.setString(7, Painter.getId());
            statement.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        //----------

        System.out.println("Added Painting!");
    }

    @Override
    public void add(Painting entity) throws ClassNotFoundException {
        if (checkIfExists(entity.getId())) {
            System.out.println("The Painting already exists, please try again using an new name!");
            return;
        }
        allPaintings.add(entity);
        BlockDB.getInstance().findById(entity.getLocation().getId()).addMovement(entity.getArtMovement());
        BlockDB.getInstance().findById(entity.getLocation().getId()).addArtist(entity.getPainter());
//        DB Code:
        Artist Painter = entity.getPainter();
        ArtMovement Artmovement = entity.getArtMovement();
        Block Location = entity.getLocation();
        Double Price = entity.getPrice();
        java.util.Date Creation = entity.getCreation();
        String Name = entity.getName();
        String ID = entity.getId();

        //----------
        Connection connection = null;
        try {
            connection = OurConnection.getConnection();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        try {
            PreparedStatement statement = connection.prepareStatement("INSERT INTO Painting (ID, Name, Creation, Price, Location, ArtMovement, Painter) VALUES (?, ?, ?, ?, ?, ?, ?)");
            statement.setString(1, ID);
            statement.setString(2, Name);
            java.sql.Date sqlDate = new java.sql.Date(Creation.getTime());
            statement.setDate(3, sqlDate);
            statement.setDouble(4, Price);
            statement.setString(5, Location.getId());
            statement.setString(6, Artmovement.getId());
            statement.setString(7, Painter.getId());
            statement.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        //----------

        System.out.println("Added Painting!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public add(entity Painting) : void from class repository.database.PaintingDB


    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        Painting PaintingToDelete = null;
        for (Painting a : allPaintings) {
            if (a.getId().equals(id)) {
                found = true;
                PaintingToDelete = a;
            }
        }
        if (found) {
            allPaintings.remove(PaintingToDelete);
            PaintingToDelete.setName(newName);
            allPaintings.add(PaintingToDelete);

            //----------
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Painting SET Name = ? WHERE Painting.ID = ?");
                statement.setString(1, newName);
                statement.setString(2, PaintingToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated name!");
            return;
        }
        System.out.println("The Painting you want to update does not exist!");
    }

    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        Painting PaintingToDelete = null;
        for (Painting a : allPaintings) {
            if (a.getId().equals(id)) {
                found = true;
                PaintingToDelete = a;
            }
        }
        if (found) {
            allPaintings.remove(PaintingToDelete);
            PaintingToDelete.setName(newName);
            allPaintings.add(PaintingToDelete);

            //----------
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement  statement = connection.prepareStatement("UPDATE Painting SET Name = ? WHERE Painting.ID = ?");
                statement.setString(1, newName);
                statement.setString(2, PaintingToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated name!");
            return;
        }
        System.out.println("The Painting you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateName(id String, newName String) : void from class repository.database.PaintingDB


    public void updatePrice(String id, Double newPrice) {
        boolean found = false;
        Painting PaintingToDelete = null;
        for (Painting a : allPaintings) {
            if (a.getId().equals(id)) {
                found = true;
                PaintingToDelete = a;
            }
        }
        if (found) {
            allPaintings.remove(PaintingToDelete);
            PaintingToDelete.setPrice(newPrice);
            allPaintings.add(PaintingToDelete);

            //----------
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Painting SET Price = ? WHERE Painting.ID = ?");
                statement.setDouble(1, newPrice);
                statement.setString(2, PaintingToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated price!");
            return;
        }
        System.out.println("The Painting you want to update does not exist!");
    }

    public void updatePrice(String id, Double newPrice) {
        boolean found = false;
        Painting PaintingToDelete = null;
        for (Painting a : allPaintings) {
            if (a.getId().equals(id)) {
                found = true;
                PaintingToDelete = a;
            }
        }
        if (found) {
            allPaintings.remove(PaintingToDelete);
            PaintingToDelete.setPrice(newPrice);
            allPaintings.add(PaintingToDelete);

            //----------
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement  statement = connection.prepareStatement("UPDATE Painting SET Price = ? WHERE Painting.ID = ?");
                statement.setDouble(1, newPrice);
                statement.setString(2, PaintingToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated price!");
            return;
        }
        System.out.println("The Painting you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updatePrice(id String, newPrice Double) : void from class repository.database.PaintingDB


    public void updateCreation(String id, Date newCreation) {
        boolean found = false;
        Painting PaintingToDelete = null;
        for (Painting a : allPaintings) {
            if (a.getId().equals(id)) {
                found = true;
                PaintingToDelete = a;
            }
        }
        if (found) {
            allPaintings.remove(PaintingToDelete);
            PaintingToDelete.setCreation(newCreation);
            allPaintings.add(PaintingToDelete);

            //----------
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Painting SET Creation = ? WHERE Painting.ID = ?");
                java.sql.Date sqlDate = new java.sql.Date(newCreation.getTime());
                statement.setDate(1, sqlDate);
                statement.setString(2, PaintingToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated Creation!");
            return;
        }
        System.out.println("The Painting you want to update does not exist!");
    }

    public void updateCreation(String id, Date newCreation) {
        boolean found = false;
        Painting PaintingToDelete = null;
        for (Painting a : allPaintings) {
            if (a.getId().equals(id)) {
                found = true;
                PaintingToDelete = a;
            }
        }
        if (found) {
            allPaintings.remove(PaintingToDelete);
            PaintingToDelete.setCreation(newCreation);
            allPaintings.add(PaintingToDelete);

            //----------
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement  statement = connection.prepareStatement("UPDATE Painting SET Creation = ? WHERE Painting.ID = ?");
                java.sql.Date sqlDate = new java.sql.Date(newCreation.getTime());
                statement.setDate(1, sqlDate);
                statement.setString(2, PaintingToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated Creation!");
            return;
        }
        System.out.println("The Painting you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateCreation(id String, newCreation Date) : void from class repository.database.PaintingDB


    public void updatePainter(String id, Artist newPainter) {
        boolean found = false;
        Painting PaintingToDelete = null;
        for (Painting a : allPaintings) {
            if (a.getId().equals(id)) {
                found = true;
                PaintingToDelete = a;
            }
        }
        if (found) {
            allPaintings.remove(PaintingToDelete);
            PaintingToDelete.setPainter(newPainter);
            allPaintings.add(PaintingToDelete);

            //----------
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Painting SET Painter = ? WHERE Painting.ID = ?");
                statement.setString(1, newPainter.getId());
                statement.setString(2, PaintingToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated Painter!");
            return;
        }
        System.out.println("The Painting you want to update does not exist!");
    }

    public void updatePainter(String id, Artist newPainter) {
        boolean found = false;
        Painting PaintingToDelete = null;
        for (Painting a : allPaintings) {
            if (a.getId().equals(id)) {
                found = true;
                PaintingToDelete = a;
            }
        }
        if (found) {
            allPaintings.remove(PaintingToDelete);
            PaintingToDelete.setPainter(newPainter);
            allPaintings.add(PaintingToDelete);

            //----------
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement  statement = connection.prepareStatement("UPDATE Painting SET Painter = ? WHERE Painting.ID = ?");
                statement.setString(1, newPainter.getId());
                statement.setString(2, PaintingToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated Painter!");
            return;
        }
        System.out.println("The Painting you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updatePainter(id String, newPainter Artist) : void from class repository.database.PaintingDB


    public void updateArtMovement(String id, ArtMovement newArtMovement) {
        boolean found = false;
        Painting PaintingToDelete = null;
        for (Painting a : allPaintings) {
            if (a.getId().equals(id)) {
                found = true;
                PaintingToDelete = a;
            }
        }
        if (found) {
            allPaintings.remove(PaintingToDelete);
            PaintingToDelete.setArtMovement(newArtMovement);
            allPaintings.add(PaintingToDelete);

            //----------
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Painting SET ArtMovement = ? WHERE Painting.ID = ?");
                statement.setString(1, newArtMovement.getId());
                statement.setString(2, PaintingToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated Art Movement!");
            return;
        }
        System.out.println("The Painting you want to update does not exist!");
    }

    public void updateArtMovement(String id, ArtMovement newArtMovement) {
        boolean found = false;
        Painting PaintingToDelete = null;
        for (Painting a : allPaintings) {
            if (a.getId().equals(id)) {
                found = true;
                PaintingToDelete = a;
            }
        }
        if (found) {
            allPaintings.remove(PaintingToDelete);
            PaintingToDelete.setArtMovement(newArtMovement);
            allPaintings.add(PaintingToDelete);

            //----------
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement  statement = connection.prepareStatement("UPDATE Painting SET ArtMovement = ? WHERE Painting.ID = ?");
                statement.setString(1, newArtMovement.getId());
                statement.setString(2, PaintingToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated Art Movement!");
            return;
        }
        System.out.println("The Painting you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateArtMovement(id String, newArtMovement ArtMovement) : void from class repository.database.PaintingDB


    public void updateLocation(String id, Block newLocation) {
        boolean found = false;
        Painting PaintingToDelete = null;
        for (Painting a : allPaintings) {
            if (a.getId().equals(id)) {
                found = true;
                PaintingToDelete = a;
            }
        }
        if (found) {
            allPaintings.remove(PaintingToDelete);
            PaintingToDelete.setLocation(newLocation);
            allPaintings.add(PaintingToDelete);

            //----------
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Painting SET Location = ? WHERE Painting.ID = ?");
                statement.setString(1, newLocation.getId());
                statement.setString(2, PaintingToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated Location!");
            return;
        }
        System.out.println("The Painting you want to update does not exist!");
    }

    public void updateLocation(String id, Block newLocation) {
        boolean found = false;
        Painting PaintingToDelete = null;
        for (Painting a : allPaintings) {
            if (a.getId().equals(id)) {
                found = true;
                PaintingToDelete = a;
            }
        }
        if (found) {
            allPaintings.remove(PaintingToDelete);
            PaintingToDelete.setLocation(newLocation);
            allPaintings.add(PaintingToDelete);

            //----------
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement  statement = connection.prepareStatement("UPDATE Painting SET Location = ? WHERE Painting.ID = ?");
                statement.setString(1, newLocation.getId());
                statement.setString(2, PaintingToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated Location!");
            return;
        }
        System.out.println("The Painting you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateLocation(id String, newLocation Block) : void from class repository.database.PaintingDB


    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        Statue StatueToDelete = null;
        for (Statue a : allStatues) {
            if (a.getId().equals(id)) {
                found = true;
                StatueToDelete = a;
            }
        }
        if (found) {
            allStatues.remove(StatueToDelete);
            StatueToDelete.setName(newName);
            allStatues.add(StatueToDelete);

            //----------
            Connection connection;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException | SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement statement = connection.prepareStatement("UPDATE Statue SET Name = ? WHERE Statue.ID = ?");
                statement.setString(1, newName);
                statement.setString(2, StatueToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated name!");
            return;
        }
        System.out.println("The Statue you want to update does not exist!");
    }

    @Override
    public void updateName(String id, String newName) {
        boolean found = false;
        Statue StatueToDelete = null;
        for (Statue a : allStatues) {
            if (a.getId().equals(id)) {
                found = true;
                StatueToDelete = a;
            }
        }
        if (found) {
            allStatues.remove(StatueToDelete);
            StatueToDelete.setName(newName);
            allStatues.add(StatueToDelete);

            //----------
            Connection connection = null;
            try {
                connection = OurConnection.getConnection();
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            try {
                PreparedStatement  statement = connection.prepareStatement("UPDATE Statue SET Name = ? WHERE Statue.ID = ?");
                statement.setString(1, newName);
                statement.setString(2, StatueToDelete.getId());
                statement.executeUpdate();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
            //----------

            System.out.println("Updated name!");
            return;
        }
        System.out.println("The Statue you want to update does not exist!");
    }

Merge Catch [catch(ClassNotFoundException e), catch(SQLException e)] to catch(ClassNotFoundException|SQLException e) in method public updateName(id String, newName String) : void from class repository.database.StatueDB