	public ThemeSelectionView() {
		setLayout(new MigLayout("", "[][grow]", "[][grow]"));

		JLabel lblSelectTheme = new JLabel("Select Theme");
		add(lblSelectTheme, "cell 0 0,alignx trailing");

		comboSelectTheme = new JComboBox<>();
		String[] themeNames = Themes.all().stream().map(Theme::name).sorted().toArray(String[]::new);
		comboSelectTheme.setModel(new DefaultComboBoxModel<>(themeNames));
		add(comboSelectTheme, "cell 1 0,alignx left");

		JPanel panelPreview = new JPanel();
		panelPreview.setBackground(new Color(0, 23, 61));
		add(panelPreview, "cell 1 1,grow");
		panelPreview.setLayout(new MigLayout("", "[][][][][]", "[][]"));

		lblPacMan = new JLabel("Pac-Man");
		lblPacMan.setPreferredSize(new Dimension(100, 100));
		lblPacMan.setBorder(new LineBorder(Color.WHITE));
		lblPacMan.setVerticalAlignment(SwingConstants.BOTTOM);
		lblPacMan.setForeground(Color.WHITE);
		lblPacMan.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblPacMan.setHorizontalAlignment(SwingConstants.CENTER);
		lblPacMan.setHorizontalTextPosition(SwingConstants.CENTER);
		lblPacMan.setVerticalTextPosition(SwingConstants.BOTTOM);
		panelPreview.add(lblPacMan, "cell 0 0,alignx left,aligny top");

		lblBlinky = new JLabel("Blinky");
		lblBlinky.setBorder(new LineBorder(Color.WHITE));
		lblBlinky.setVerticalAlignment(SwingConstants.BOTTOM);
		lblBlinky.setPreferredSize(new Dimension(100, 100));
		lblBlinky.setForeground(Color.WHITE);
		lblBlinky.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblBlinky.setHorizontalAlignment(SwingConstants.CENTER);
		lblBlinky.setHorizontalTextPosition(SwingConstants.CENTER);
		lblBlinky.setVerticalTextPosition(SwingConstants.BOTTOM);
		panelPreview.add(lblBlinky, "cell 1 0,alignx left,aligny top");

		lblPinky = new JLabel("Pinky");
		lblPinky.setBorder(new LineBorder(Color.WHITE));
		lblPinky.setVerticalAlignment(SwingConstants.BOTTOM);
		lblPinky.setPreferredSize(new Dimension(100, 100));
		lblPinky.setForeground(Color.WHITE);
		lblPinky.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblPinky.setHorizontalAlignment(SwingConstants.CENTER);
		lblPinky.setHorizontalTextPosition(SwingConstants.CENTER);
		lblPinky.setVerticalTextPosition(SwingConstants.BOTTOM);
		panelPreview.add(lblPinky, "cell 2 0,alignx left,aligny top");

		lblInky = new JLabel("Inky");
		lblInky.setBorder(new LineBorder(Color.WHITE));
		lblInky.setVerticalAlignment(SwingConstants.BOTTOM);
		lblInky.setPreferredSize(new Dimension(100, 100));
		lblInky.setForeground(Color.WHITE);
		lblInky.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblInky.setHorizontalAlignment(SwingConstants.CENTER);
		lblInky.setHorizontalTextPosition(SwingConstants.CENTER);
		lblInky.setVerticalTextPosition(SwingConstants.BOTTOM);
		panelPreview.add(lblInky, "cell 3 0,alignx left,aligny top");

		lblClyde = new JLabel("Clyde");
		lblClyde.setBorder(new LineBorder(Color.WHITE));
		lblClyde.setVerticalAlignment(SwingConstants.BOTTOM);
		lblClyde.setPreferredSize(new Dimension(100, 100));
		lblClyde.setForeground(Color.WHITE);
		lblClyde.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblClyde.setHorizontalAlignment(SwingConstants.CENTER);
		lblClyde.setHorizontalTextPosition(SwingConstants.CENTER);
		lblClyde.setVerticalTextPosition(SwingConstants.BOTTOM);
		panelPreview.add(lblClyde, "cell 4 0,alignx left,aligny top");

		lblGhostFrightened = new JLabel("Frightened");
		lblGhostFrightened.setForeground(Color.WHITE);
		lblGhostFrightened.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblGhostFrightened.setVerticalAlignment(SwingConstants.BOTTOM);
		lblGhostFrightened.setVerticalTextPosition(SwingConstants.BOTTOM);
		lblGhostFrightened.setHorizontalTextPosition(SwingConstants.CENTER);
		lblGhostFrightened.setBorder(new LineBorder(Color.WHITE));
		lblGhostFrightened.setPreferredSize(new Dimension(100, 100));
		lblGhostFrightened.setHorizontalAlignment(SwingConstants.CENTER);
		panelPreview.add(lblGhostFrightened, "cell 1 1,alignx right,aligny top");

		lblGhostDead = new JLabel("Dead");
		lblGhostDead.setForeground(Color.WHITE);
		lblGhostDead.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblGhostDead.setHorizontalTextPosition(SwingConstants.CENTER);
		lblGhostDead.setHorizontalAlignment(SwingConstants.CENTER);
		lblGhostDead.setVerticalAlignment(SwingConstants.BOTTOM);
		lblGhostDead.setVerticalTextPosition(SwingConstants.BOTTOM);
		lblGhostDead.setPreferredSize(new Dimension(100, 100));
		lblGhostDead.setBorder(new LineBorder(Color.WHITE));
		panelPreview.add(lblGhostDead, "cell 2 1,alignx left,aligny top");

		lblGhostDeadBounty = new JLabel("Bounty");
		lblGhostDeadBounty.setVerticalTextPosition(SwingConstants.BOTTOM);
		lblGhostDeadBounty.setVerticalAlignment(SwingConstants.BOTTOM);
		lblGhostDeadBounty.setPreferredSize(new Dimension(100, 100));
		lblGhostDeadBounty.setHorizontalTextPosition(SwingConstants.CENTER);
		lblGhostDeadBounty.setHorizontalAlignment(SwingConstants.CENTER);
		lblGhostDeadBounty.setForeground(Color.WHITE);
		lblGhostDeadBounty.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblGhostDeadBounty.setBorder(new LineBorder(Color.WHITE));
		panelPreview.add(lblGhostDeadBounty, "cell 3 1");

		comboSelectTheme.addItemListener(e -> {
			if (e.getStateChange() == ItemEvent.SELECTED) {
				String themeName = comboSelectTheme.getModel().getElementAt(comboSelectTheme.getSelectedIndex());
				gameController.themes.select(themeName);
				updatePreviewLabels();
			}
		});
	}

	public ThemeSelectionView() {
		setLayout(new MigLayout("", "[][grow]", "[][grow]"));

		JLabel lblSelectTheme = new JLabel("Select Theme");
		add(lblSelectTheme, "cell 0 0,alignx trailing");

		comboSelectTheme = new JComboBox<>();
		String[] themeNames = Themes.all().stream().map(Theme::name).sorted().toArray(String[]::new);
		comboSelectTheme.setModel(new DefaultComboBoxModel<String>(themeNames));
		add(comboSelectTheme, "cell 1 0,alignx left");

		JPanel panelPreview = new JPanel();
		panelPreview.setBackground(new Color(0, 23, 61));
		add(panelPreview, "cell 1 1,grow");
		panelPreview.setLayout(new MigLayout("", "[][][][][]", "[][]"));

		lblPacMan = new JLabel("Pac-Man");
		lblPacMan.setPreferredSize(new Dimension(100, 100));
		lblPacMan.setBorder(new LineBorder(Color.WHITE));
		lblPacMan.setVerticalAlignment(SwingConstants.BOTTOM);
		lblPacMan.setForeground(Color.WHITE);
		lblPacMan.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblPacMan.setHorizontalAlignment(SwingConstants.CENTER);
		lblPacMan.setHorizontalTextPosition(SwingConstants.CENTER);
		lblPacMan.setVerticalTextPosition(SwingConstants.BOTTOM);
		panelPreview.add(lblPacMan, "cell 0 0,alignx left,aligny top");

		lblBlinky = new JLabel("Blinky");
		lblBlinky.setBorder(new LineBorder(Color.WHITE));
		lblBlinky.setVerticalAlignment(SwingConstants.BOTTOM);
		lblBlinky.setPreferredSize(new Dimension(100, 100));
		lblBlinky.setForeground(Color.WHITE);
		lblBlinky.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblBlinky.setHorizontalAlignment(SwingConstants.CENTER);
		lblBlinky.setHorizontalTextPosition(SwingConstants.CENTER);
		lblBlinky.setVerticalTextPosition(SwingConstants.BOTTOM);
		panelPreview.add(lblBlinky, "cell 1 0,alignx left,aligny top");

		lblPinky = new JLabel("Pinky");
		lblPinky.setBorder(new LineBorder(Color.WHITE));
		lblPinky.setVerticalAlignment(SwingConstants.BOTTOM);
		lblPinky.setPreferredSize(new Dimension(100, 100));
		lblPinky.setForeground(Color.WHITE);
		lblPinky.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblPinky.setHorizontalAlignment(SwingConstants.CENTER);
		lblPinky.setHorizontalTextPosition(SwingConstants.CENTER);
		lblPinky.setVerticalTextPosition(SwingConstants.BOTTOM);
		panelPreview.add(lblPinky, "cell 2 0,alignx left,aligny top");

		lblInky = new JLabel("Inky");
		lblInky.setBorder(new LineBorder(Color.WHITE));
		lblInky.setVerticalAlignment(SwingConstants.BOTTOM);
		lblInky.setPreferredSize(new Dimension(100, 100));
		lblInky.setForeground(Color.WHITE);
		lblInky.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblInky.setHorizontalAlignment(SwingConstants.CENTER);
		lblInky.setHorizontalTextPosition(SwingConstants.CENTER);
		lblInky.setVerticalTextPosition(SwingConstants.BOTTOM);
		panelPreview.add(lblInky, "cell 3 0,alignx left,aligny top");

		lblClyde = new JLabel("Clyde");
		lblClyde.setBorder(new LineBorder(Color.WHITE));
		lblClyde.setVerticalAlignment(SwingConstants.BOTTOM);
		lblClyde.setPreferredSize(new Dimension(100, 100));
		lblClyde.setForeground(Color.WHITE);
		lblClyde.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblClyde.setHorizontalAlignment(SwingConstants.CENTER);
		lblClyde.setHorizontalTextPosition(SwingConstants.CENTER);
		lblClyde.setVerticalTextPosition(SwingConstants.BOTTOM);
		panelPreview.add(lblClyde, "cell 4 0,alignx left,aligny top");

		lblGhostFrightened = new JLabel("Frightened");
		lblGhostFrightened.setForeground(Color.WHITE);
		lblGhostFrightened.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblGhostFrightened.setVerticalAlignment(SwingConstants.BOTTOM);
		lblGhostFrightened.setVerticalTextPosition(SwingConstants.BOTTOM);
		lblGhostFrightened.setHorizontalTextPosition(SwingConstants.CENTER);
		lblGhostFrightened.setBorder(new LineBorder(Color.WHITE));
		lblGhostFrightened.setPreferredSize(new Dimension(100, 100));
		lblGhostFrightened.setHorizontalAlignment(SwingConstants.CENTER);
		panelPreview.add(lblGhostFrightened, "cell 1 1,alignx right,aligny top");

		lblGhostDead = new JLabel("Dead");
		lblGhostDead.setForeground(Color.WHITE);
		lblGhostDead.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblGhostDead.setHorizontalTextPosition(SwingConstants.CENTER);
		lblGhostDead.setHorizontalAlignment(SwingConstants.CENTER);
		lblGhostDead.setVerticalAlignment(SwingConstants.BOTTOM);
		lblGhostDead.setVerticalTextPosition(SwingConstants.BOTTOM);
		lblGhostDead.setPreferredSize(new Dimension(100, 100));
		lblGhostDead.setBorder(new LineBorder(Color.WHITE));
		panelPreview.add(lblGhostDead, "cell 2 1,alignx left,aligny top");

		lblGhostDeadBounty = new JLabel("Bounty");
		lblGhostDeadBounty.setVerticalTextPosition(SwingConstants.BOTTOM);
		lblGhostDeadBounty.setVerticalAlignment(SwingConstants.BOTTOM);
		lblGhostDeadBounty.setPreferredSize(new Dimension(100, 100));
		lblGhostDeadBounty.setHorizontalTextPosition(SwingConstants.CENTER);
		lblGhostDeadBounty.setHorizontalAlignment(SwingConstants.CENTER);
		lblGhostDeadBounty.setForeground(Color.WHITE);
		lblGhostDeadBounty.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblGhostDeadBounty.setBorder(new LineBorder(Color.WHITE));
		panelPreview.add(lblGhostDeadBounty, "cell 3 1");

		comboSelectTheme.addItemListener(e -> {
			if (e.getStateChange() == ItemEvent.SELECTED) {
				String themeName = comboSelectTheme.getModel().getElementAt(comboSelectTheme.getSelectedIndex());
				gameController.themes.select(themeName);
				updatePreviewLabels();
			}
		});
	}

Replace Generic With Diamond DefaultComboBoxModel<String> with DefaultComboBoxModel<> in method public ThemeSelectionView() from class de.amr.games.pacman.view.dashboard.theme.ThemeSelectionView


	public void load() {
		loginfo("Loading highscore from file '%s'", file);
		try (FileInputStream is = new FileInputStream(file)) {
			data.loadFromXML(is);
			points = Integer.valueOf(data.getProperty("score"));
			level = Integer.valueOf(data.getProperty("level"));
			if (data.getProperty("time") != null) {
				time = ZonedDateTime.parse(data.getProperty("time"), DATE_FORMAT);
			} else {
				time = ZonedDateTime.now();
			}
		} catch (FileNotFoundException e) {
			loginfo("Hiscore file not available, creating new one");
			save();
		} catch (DateTimeParseException e) {
			loginfo("Could not parse time in hiscore file '%s'", file);
			e.printStackTrace();
		} catch (Exception e) {
			loginfo("Could not load hiscore file '%s'", file);
			e.printStackTrace();
		}
	}

	public void load() {
		loginfo("Loading highscore from file '%s'", file);
		try {
			data.loadFromXML(new FileInputStream(file));
			points = Integer.valueOf(data.getProperty("score"));
			level = Integer.valueOf(data.getProperty("level"));
			if (data.getProperty("time") != null) {
				time = ZonedDateTime.parse(data.getProperty("time"), DATE_FORMAT);
			} else {
				time = ZonedDateTime.now();
			}
		} catch (FileNotFoundException e) {
			loginfo("Hiscore file not available, creating new one");
			save();
		} catch (DateTimeParseException e) {
			loginfo("Could not parse time in hiscore file '%s'", file);
			e.printStackTrace();
		} catch (Exception e) {
			loginfo("Could not load hiscore file '%s'", file);
			e.printStackTrace();
		}
	}

Try With Resources try(FileInputStream is=new FileInputStream(file)) in method public load() : void from class de.amr.games.pacman.model.game.Hiscore


	public void save() {
		if (needsUpdate) {
			data.setProperty("score", Integer.toString(points));
			data.setProperty("level", Integer.toString(level));
			if (time == null) {
				time = ZonedDateTime.now();
			}
			data.setProperty("time", time.format(DATE_FORMAT));
			try (FileOutputStream os = new FileOutputStream(file)) {
				data.storeToXML(os, "Pac-Man Highscore");
				needsUpdate = false;
				loginfo("Saved highscore file '%s'", file);
			} catch (IOException e) {
				loginfo("Could not save hiscore file '%s'", file);
				throw new RuntimeException(e);
			}
		}
	}

	public void save() {
		if (needsUpdate) {
			data.setProperty("score", Integer.toString(points));
			data.setProperty("level", Integer.toString(level));
			if (time == null) {
				time = ZonedDateTime.now();
			}
			data.setProperty("time", time.format(DATE_FORMAT));
			try {
				data.storeToXML(new FileOutputStream(file), "Pac-Man Highscore");
				needsUpdate = false;
				loginfo("Saved highscore file '%s'", file);
			} catch (IOException e) {
				loginfo("Could not save hiscore file '%s'", file);
				throw new RuntimeException(e);
			}
		}
	}

Try With Resources try(FileOutputStream os=new FileOutputStream(file)) in method public save() : void from class de.amr.games.pacman.model.game.Hiscore


	/**
	 * Lets the maze mover flee from the given attacker.
	 *
	 * @param attacker
	 *                   the attacker
	 * @return flight behavior
	 */
	public default Navigation<T> flee(Actor attacker) {
		return new EscapeIntoCorner<>(attacker);
	}

	/**
	 * Lets the maze mover flee from the given attacker.
	 *
	 * @param attacker
	 *                   the attacker
	 * @return flight behavior
	 */
	public default Navigation<T> flee(Actor attacker) {
		return new EscapeIntoCorner<T>(attacker);
	}

Replace Generic With Diamond EscapeIntoCorner<T> with EscapeIntoCorner<> in method public flee(attacker Actor) : Navigation<T> from class de.amr.games.pacman.navigation.NavigationSystem


	/**
	 * Lets the maze mover follow a static path to the target. The static path is computed when the
	 * method {@link Navigation#computeStaticRoute(Actor)} is called.
	 *
	 * @param target
	 *                 the target tile
	 * @return behavior following a static route
	 */
	public default Navigation<T> followStaticRoute(Tile target) {
		return new FollowFixedPath<>(target);
	}

	/**
	 * Lets the maze mover follow a static path to the target. The static path is computed when the
	 * method {@link Navigation#computeStaticRoute(Actor)} is called.
	 *
	 * @param target
	 *                 the target tile
	 * @return behavior following a static route
	 */
	public default Navigation<T> followStaticRoute(Tile target) {
		return new FollowFixedPath<T>(target);
	}

Replace Generic With Diamond FollowFixedPath<T> with FollowFixedPath<> in method public followStaticRoute(target Tile) : Navigation<T> from class de.amr.games.pacman.navigation.NavigationSystem


	/**
	 * Tries to reach the possibly unreachable target tile by chosing the best direction at every
	 * intersection.
	 *
	 * @param targetTileSupplier
	 *                             function supplying the target tile at time of decision
	 * @return behavior head for the tile computed by the supplier
	 */
	public default Navigation<T> headFor(Supplier<Tile> targetTileSupplier) {
		return new FollowTargetTile<>(targetTileSupplier);
	}

	/**
	 * Tries to reach the possibly unreachable target tile by chosing the best direction at every
	 * intersection.
	 *
	 * @param targetTileSupplier
	 *                             function supplying the target tile at time of decision
	 * @return behavior head for the tile computed by the supplier
	 */
	public default Navigation<T> headFor(Supplier<Tile> targetTileSupplier) {
		return new FollowTargetTile<T>(targetTileSupplier);
	}

Replace Generic With Diamond FollowTargetTile<T> with FollowTargetTile<> in method public headFor(targetTileSupplier Supplier<Tile>) : Navigation<T> from class de.amr.games.pacman.navigation.NavigationSystem


    private void populateLicenseTab() {
        installationDetailsButton.setVisible(false);
        checkNewVersionButton.setVisible(false);

        if(licenseText.getText().length() == 0) {
            URL url = ArchiPlugin.INSTANCE.getBundle().getEntry("LICENSE.txt"); //$NON-NLS-1$
            if(url != null) {
                try(InputStream in = url.openStream()) {
                    String content = new String(in.readAllBytes());
                    licenseText.setText(content);
                }
                catch(IOException ex) {
                    ex.printStackTrace();
                }
            }
        }
    }

    private void populateLicenseTab() {
        installationDetailsButton.setVisible(false);
        checkNewVersionButton.setVisible(false);

        if(licenseText.getText().length() == 0) {
            File file = new File(ArchiPlugin.INSTANCE.getPluginFolder(), "LICENSE.txt"); //$NON-NLS-1$
            if(file.exists()) {
                try {
                    String content = new String(Files.readAllBytes(Paths.get(file.getPath())));
                    licenseText.setText(content);
                }
                catch(IOException ex) {
                    ex.printStackTrace();
                }
            }
        }
    }

Try With Resources try(InputStream in=url.openStream()) in method private populateLicenseTab() : void from class com.archimatetool.editor.ui.dialog.AboutDialog


                        @Override
                        public void run() {
                            Display.getDefault().asyncExec(() -> {
                                if(!fSearchText.isDisposed()) {
                                    fSearchFilter.setSearchText(fSearchText.getText());
                                }
                            });
                        }

                        @Override
                        public void run() {
                            Display.getDefault().asyncExec(new Runnable() {
                                @Override
                                public void run() {
                                    fSearchFilter.setSearchText(fSearchText.getText());
                                }
                            });
                        }

Replace Anonymous With Lambda com.archimatetool.editor.views.tree.search.SearchWidget.setupSearchTextWidget.addModifyListener.new ModifyListener.modifyText.schedule.new TimerTask.run.asyncExec.new Runnable with () -> {if(!fSearchText.isDisposed()){fSearchFilter.setSearchText(fSearchText.getText()); in method public run() : void from class com.archimatetool.editor.views.tree.search.SearchWidget.setupSearchTextWidget.addModifyListener.new ModifyListener.modifyText.schedule.new TimerTask


    /**
     * Apply a font change preference listener on a control. The control will update when preference changes.
     * @param control
     * @param prefsKey
     */
    public static void applyFontChangePreferenceListener(Control control, String prefsKey) {
        IPropertyChangeListener listener = (event) -> {
            if(prefsKey == event.getProperty()) {
                setFontFromPreferences(control, prefsKey, false);
            }
        };

        Preferences.STORE.addPropertyChangeListener(listener);

        control.addDisposeListener((e) -> {
            Preferences.STORE.removePropertyChangeListener(listener);
        });
    }

    /**
     * Apply a font change preference listener on a control. The control will update when preference changes.
     * @param control
     * @param prefsKey
     */
    public static void applyFontChangePreferenceListener(Control control, String prefsKey) {
        IPropertyChangeListener listener = new IPropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent event) {
                if(prefsKey == event.getProperty()) {
                    setFontFromPreferences(control, prefsKey, false);
                    control.getParent().layout();
                }
            }
        };

        Preferences.STORE.addPropertyChangeListener(listener);

        control.addDisposeListener((e) -> {
            Preferences.STORE.removePropertyChangeListener(listener);
        });
    }

Replace Anonymous With Lambda com.archimatetool.editor.ui.UIUtils.applyFontChangePreferenceListener.listener.new IPropertyChangeListener with (event) -> {if(prefsKey == event.getProperty()){setFontFromPreferences(control,prefsKey,false); in method public applyFontChangePreferenceListener(control Control, prefsKey String) : void from class com.archimatetool.editor.ui.UIUtils


    private File[] findMatchingPlugins(File pluginsFolder, File newPlugin) {
        String pluginName = getPluginName(newPlugin.getName());

        return pluginsFolder.listFiles((file) -> {
            String targetPluginName = getPluginName(file.getName());
            return targetPluginName.equals(pluginName) && !newPlugin.getName().equals(file.getName());
        });
    }

    private File[] findMatchingPlugins(File pluginsFolder, File newPlugin) {
        String pluginName = getPluginName(newPlugin.getName());

        return pluginsFolder.listFiles(new FileFilter() {
            @Override
            public boolean accept(File file) {
                String targetPluginName = getPluginName(file.getName());
                return targetPluginName.equals(pluginName) && !newPlugin.getName().equals(file.getName());
            }
        });
    }

Replace Anonymous With Lambda com.archimatetool.editor.p2.DropinsPluginHandler.findMatchingPlugins.listFiles.new FileFilter with (file) -> {String targetPluginName=getPluginName(file.getName()); in method private findMatchingPlugins(pluginsFolder File, newPlugin File) : File[] from class com.archimatetool.editor.p2.DropinsPluginHandler


    public StyledTextControl(StyledText styledText) {
        fStyledText = styledText;
        fStyledText.setLeftMargin(PlatformUtils.isWindows() ? 4 : 2);
        fStyledText.setKeyBinding(ST.SELECT_ALL, ST.SELECT_ALL);

        fHandCursor = new Cursor(styledText.getDisplay(), SWT.CURSOR_HAND);

        final int[] eventTypes = {SWT.MouseUp, SWT.MouseMove, SWT.MouseVerticalWheel, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn};

        for(int type : eventTypes) {
            fStyledText.addListener(type, this);
        }

        fStyledText.addLineStyleListener(this);

        fStyledText.addDisposeListener((event)-> {
            if(fHandCursor != null && !fHandCursor.isDisposed()) {
                fHandCursor.dispose();
                fHandCursor = null;
            }

            if(fCurrentFont != null && !fCurrentFont.isDisposed()) {
                fCurrentFont.dispose();
                fCurrentFont = null;
            }

            for(int type : eventTypes) {
                fStyledText.removeListener(type, this);
            }

            fStyledText.removeLineStyleListener(this);

            fCurrentCursor = null;
            fLinks = null;
            fStyledText = null;
        });

        // Filter out any illegal xml characters
        UIUtils.applyInvalidCharacterFilter(fStyledText);

        hookContextMenu();

        setInitialFontHeight();
    }

    public StyledTextControl(StyledText styledText) {
        fStyledText = styledText;
        fStyledText.setLeftMargin(PlatformUtils.isWindows() ? 4 : 2);
        fStyledText.setKeyBinding(ST.SELECT_ALL, ST.SELECT_ALL);

        fHandCursor = new Cursor(styledText.getDisplay(), SWT.CURSOR_HAND);

        fStyledText.addDisposeListener(new DisposeListener() {
            @Override
            public void widgetDisposed(DisposeEvent e) {
                if(fHandCursor != null && !fHandCursor.isDisposed()) {
                    fHandCursor.dispose();
                    fHandCursor = null;
                }

                fStyledText.removeListener(SWT.MouseUp, StyledTextControl.this);
                fStyledText.removeListener(SWT.MouseMove, StyledTextControl.this);
                fStyledText.removeListener(SWT.MouseVerticalWheel, StyledTextControl.this);
                fStyledText.removeListener(SWT.KeyDown, StyledTextControl.this);
                fStyledText.removeListener(SWT.KeyUp, StyledTextControl.this);

                fStyledText.removeLineStyleListener(StyledTextControl.this);

                fCurrentCursor = null;
                fLinks = null;

                if(fCurrentFont != null && !fCurrentFont.isDisposed()) {
                    fCurrentFont.dispose();
                    fCurrentFont = null;
                }
            }
        });

        fStyledText.addListener(SWT.MouseUp, this);
        fStyledText.addListener(SWT.MouseMove, this);
        fStyledText.addListener(SWT.MouseVerticalWheel, this);
        fStyledText.addListener(SWT.KeyDown, this);
        fStyledText.addListener(SWT.KeyUp, this);

        fStyledText.addLineStyleListener(this);

        // Filter out any illegal xml characters
        UIUtils.applyInvalidCharacterFilter(fStyledText);

        hookContextMenu();

        setInitialFontHeight();
    }

Replace Anonymous With Lambda com.archimatetool.editor.ui.components.StyledTextControl.StyledTextControl.addDisposeListener.new DisposeListener with (event) -> {if(fHandCursor != null && !fHandCursor.isDisposed()){fHandCursor.dispose(); in method public StyledTextControl(styledText StyledText) from class com.archimatetool.editor.ui.components.StyledTextControl


    public void export() throws IOException {
        File targetFolder = askSaveFolder();
        if(targetFolder == null) {
            return;
        }

        IOException[] exception = new IOException[1];

        // Since this can take a while, show the busy dialog
        IRunnableWithProgress runnable = monitor -> {
            try {
                File file = createReport(targetFolder, "index.html", monitor); //$NON-NLS-1$

                // Open it in external Browser
                IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
                try {
                    monitor.subTask(Messages.HTMLReportExporter_7);
                    IWebBrowser browser = support.getExternalBrowser();
                    // This method supports network URLs
                    browser.openURL(new URL("file", null, file.getAbsolutePath().replace(" ", "%20"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                }
                catch(PartInitException ex) {
                    ex.printStackTrace();
                }
            }
            catch(IOException ex) {
                exception[0] = ex;
            }
        };

        try {
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
            dialog.run(false, true, runnable);
        }
        catch(InvocationTargetException | InterruptedException ex) {
            ex.printStackTrace();
        }

        if(exception[0] != null) {
            if(exception[0] instanceof CancelledException) {
                MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.HTMLReportExporter_2, exception[0].getMessage());
                return;
            }

            throw exception[0];
        }
    }

    public void export() throws IOException {
        File targetFolder = askSaveFolder();
        if(targetFolder == null) {
            return;
        }

        IOException[] exception = new IOException[1];

        BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
            @Override
            public void run() {
                try {
                    File file = createReport(targetFolder, "index.html"); //$NON-NLS-1$

                    // Open it in external Browser
                    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
                    try {
                        IWebBrowser browser = support.getExternalBrowser();
                        // This method supports network URLs
                        browser.openURL(new URL("file", null, file.getAbsolutePath().replace(" ", "%20"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    }
                    catch(PartInitException ex) {
                        ex.printStackTrace();
                    }
                }
                catch(IOException ex) {
                    exception[0] = ex;
                }
            }
        });

        if(exception[0] != null) {
            throw exception[0];
        }
    }

Replace Anonymous With Lambda com.archimatetool.reports.html.HTMLReportExporter.export.showWhile.new Runnable with monitor -> {tryFile file=createReport(targetFolder,"index.html",monitor); in method public export() : void from class com.archimatetool.reports.html.HTMLReportExporter


    /**
     * Create a machine with a loaded ROM
     * @param ROM ROM file
     * @param mode Machine mode to boot into
     * @param saveFile File to save external RAM to (or NULL)
     */
    public Machine(File ROM, MachineMode mode, File saveFile) throws RomException {
        baseNamePath = saveFile.getPath();
        timer = new Timer(this);
        keypad = new Keypad(this);
        soundBoard = new SoundBoard(); // Not yet used
        this.saveFile = saveFile;
        this.mode = mode;
        byte[] header = new byte[0x150];
        try (FileInputStream fis = new FileInputStream(ROM)) {
            // Get the header information of the ROM and use it to determine MBC type, RAM/ROM size
            int read = fis.read(header, 0, 0x150);
            if(read < 0x150) {
                throw new RomException("ROM file too small to be valid!");
            }
            int cartridgeType = header[0x147] & 0xff;
            int colorMode = header[0x143] & 0xff;
            usingColor = (mode.isCgb && (colorMode & 0x6) == 0);
            monochromeCompatibility = usingColor && (colorMode & 0x80) == 0;
            int mbc = 0;
            int romBanks;
            int ramSize = 0;
            if(header[0x149] != 0){
                ramSize = RAM_SIZES[header[0x149]];
            }
            System.out.printf("Cartridge type = %02x, ramkey = %02x, Color? %s (Compatibility? %s)\n", cartridgeType, header[0x149], usingColor, monochromeCompatibility);
            switch(cartridgeType){
                case 0:
                    ramSize = 0; break;
                case 1:
                    ramSize = 0;
                case 2:
                case 3:
                    mbc = 1; break;
                case 5:
                case 6:
                    mbc = 2; ramSize = 512; break;
                case 0xF:
                case 0x10:
                case 0x11:
                case 0x12:
                case 0x13:
                    mbc = 3; break;
                case 0x19:
                case 0x1C:
                    ramSize = 0;
                case 0x1A:
                case 0x1B:
                case 0x1D:
                case 0x1E:
                    mbc = 5; break;
            }
            romBanks = header[0x148];
            if(romBanks <= 8)
                romBanks = 1 << (1 + romBanks);
            else switch(romBanks){
                case 0x52:
                    romBanks = 72; break;
                case 0x53:
                    romBanks = 80; break;
                case 0x54:
                    romBanks = 96; break;
            }
            // Create the memory component
            gpu = new GPU(this, usingColor, monochromeCompatibility);
            mmu = new MMU(this, mbc, romBanks, (ramSize + 0x1fff) >> 13, ramSize, usingColor);
            // Load this ROM file into it
            mmu.loadRom(header, 0, 0x150);
            mmu.loadRom(fis,  0x150, (romBanks << 14) - 0x150);
            try {
                loadExternal();
            } catch (RomException re) {
                System.err.println("Could not load save file: ");
                re.printStackTrace();
            }
        }catch(Exception e){
            throw new RomException(e);
        }
        cpu = new CPU(mode, mmu, null, null, true);
    }

    /**
     * Load a ROM file
     * @param ROM File containing ROM
     */
    public Machine(File ROM, MachineMode mode){
        timer = new Timer(this);
        keypad = new Keypad();
        keypad.machine = this;
        soundBoard = new SoundBoard(); // Not yet used
        this.mode = mode;
        byte[] header = new byte[0x150];
        try{
            FileInputStream fis = new FileInputStream(ROM);
            // Get the header information of the ROM and use it to determine MBC type, RAM/ROM size
            int read = fis.read(header, 0, 0x150);
            if(read < 0x150)
                throw new Exception("ROM file too small to be valid!");
            int cartridgeType = header[0x147] & 0xff;
            int colorMode = header[0x143] & 0xff;
            usingColor = (mode.isCgb && (colorMode & 0x80) != 0xff && (colorMode & 0x6) == 0);
            int mbc = 0;
            int romBanks;
            int ramSize = 0;
            if(header[0x149] != 0){
                ramSize = RAM_SIZES[header[0x149]];
            }
            System.out.printf("Cartridge type = %02x, ramkey = %02x, Color? %s\n", cartridgeType, header[0x149], usingColor);
            switch(cartridgeType){
                case 0:
                    ramSize = 0; break;
                case 1:
                    ramSize = 0;
                case 2:
                case 3:
                    mbc = 1; break;
                case 5:
                case 6:
                    mbc = 2; ramSize = 512; break;
                case 0xF:
                case 0x10:
                case 0x11:
                case 0x12:
                case 0x13:
                    mbc = 3; break;
                case 0x19:
                case 0x1C:
                    ramSize = 0;
                case 0x1A:
                case 0x1B:
                case 0x1D:
                case 0x1E:
                    mbc = 5; break;
            }
            romBanks = header[0x148];
            if(romBanks <= 8)
                romBanks = 1 << (1 + romBanks);
            else switch(romBanks){
                case 0x52:
                    romBanks = 72; break;
                case 0x53:
                    romBanks = 80; break;
                case 0x54:
                    romBanks = 96; break;
            }
            // Create the memory component
            gpu = new GPU(this, usingColor);
            mmu = new MMU(this, mbc, romBanks, (ramSize + 0x1fff) >> 13, ramSize, usingColor);
            // Load this ROM file into it
            mmu.loadRom(header, 0, 0x150);
            mmu.loadRom(fis,  0x150, (romBanks << 14) - 0x150);
            fis.close();
        }catch(Exception e){
            e.printStackTrace();
            System.exit(3);
        }
        Logger logger = null;//new Logger("log.txt");
        cpu = new CPU(mode, mmu, null, logger);
    }

Try With Resources try(FileInputStream fis=new FileInputStream(ROM)) in method public Machine(ROM File, mode MachineMode, saveFile File) from class com.funguscow.gb.Machine


    @Override
    public String getBotUsername() {
        Properties properties = new Properties();
        try (InputStream is = this.getClass().getClassLoader().getResourceAsStream("config.properties")) {
            properties.load(is);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return properties.getProperty("username");
    }

    @Override
    public String getBotUsername() {
        Properties properties = new Properties();
        try {
            properties.load(new FileReader("src/main/resources/config.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return properties.getProperty("username");
    }

Try With Resources try(InputStream is=this.getClass().getClassLoader().getResourceAsStream("config.properties")) in method public getBotUsername() : String from class com.alcorross.Bot


    @Override
    public String getBotToken() {
        Properties properties = new Properties();
        try (InputStream is = this.getClass().getClassLoader().getResourceAsStream("config.properties")) {
            properties.load(is);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return properties.getProperty("token");
    }

    @Override
    public String getBotToken() {
        Properties properties = new Properties();
        try {
            properties.load(new FileReader("src/main/resources/config.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return properties.getProperty("token");
    }

Try With Resources try(InputStream is=this.getClass().getClassLoader().getResourceAsStream("config.properties")) in method public getBotToken() : String from class com.alcorross.Bot


    @FXML
    private void relogin(){
        try {
            wsActions.logout().get();
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }
        appState.setCurrentPlayer(null);
        try {
            LayoutUtil.changeLayoutWithFadeTransition((Stage) changeUserLink.getScene().getWindow(), "/com/zemlovka/haj/client/fxml/login.fxml", wsActions);
        } catch (IOException e) {
            log.error("Failed to return to the login scene", e);
        }
    }

    @FXML
    private void relogin(){
        try {
            wsActions.logout().get();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        }
        appState.setCurrentPlayer(null);
        try {
            LayoutUtil.changeLayoutWithFadeTransition((Stage) changeUserLink.getScene().getWindow(), "/com/zemlovka/haj/client/login.fxml", wsActions);
        } catch (IOException e) {
            log.error("Failed to return to the login scene", e);
        }
    }

Merge Catch [catch(InterruptedException e), catch(ExecutionException e)] to catch(InterruptedException|ExecutionException e) in method private relogin() : void from class com.zemlovka.haj.client.fx.controllers.MenuController


    public static void main(String[] args) {
        TemplateEngine t = new TemplateEngine();
        Path path1 = Path.of("src/main/resources/letter.txt");
        Path path2 = Path.of("src/main/resources/kedvesugyfel.txt");
        try (BufferedReader br = Files.newBufferedReader(path1);
             BufferedWriter bw = Files.newBufferedWriter(path2))
        {
            Map<String, Object> map = new HashMap<>();
            map.put("{nev}", "Kovács József");
            map.put("{datum}", LocalDate.of(2021, 1, 23));
            map.put("{osszeg}", 18753);
            map.put("{hatarido}", LocalDate.of(2021, 2, 15));

            t.merge(br, map, bw);
        } catch (IOException ioe) {
            throw new IllegalStateException("Error while merging template.", ioe);
        }
    }

    public static void main(String[] args) {
        TemplateEngine t = new TemplateEngine();
        Path path1 = Path.of("src/main/resources/letter.txt");
        Path path2 = Path.of("src/main/resources/kedvesugyfel.txt");
        try {
            BufferedReader br = Files.newBufferedReader(path1);
            BufferedWriter bw = Files.newBufferedWriter(path2);
            Map<String, Object> map = new HashMap<>();
            map.put("{nev}", "Kovács József");
            map.put("{datum}", LocalDate.of(2021, 1, 23));
            map.put("{osszeg}", 18753);
            map.put("{hatarido}", LocalDate.of(2021, 2, 15));

            t.merge(br, map, bw);
        } catch (IOException ioe) {
            throw new IllegalStateException("xyz", ioe);
        }
    }

Try With Resources try(BufferedReader br=Files.newBufferedReader(path1); BufferedWriter bw=Files.newBufferedWriter(path2)) in method public main(args String[]) : void from class week13d04.TemplateEngine


    public void readGradesFromFile(String filename) {
        Path path = Path.of("src/main/resources/" + filename);
        try (BufferedReader br = Files.newBufferedReader(path)) {
            String line;
            while ((line = br.readLine()) != null) {
                String[] studentData = line.split(" ");
                String name = studentData[0];
                List<Integer> grades = new ArrayList<>();
                for (int i = 1; i < studentData.length; i++) {
                    int grade = Integer.parseInt(studentData[i]);
                    grades.add(grade);
                }
                students.add (new Student(name, grades));
            }
        } catch (IOException ioe) {
            throw new IllegalStateException("Can not read file.", ioe);
        }
    }

    public void readGradesFromFile(String filename) {
        try {
            Path path = Path.of("src/main/resources/" + filename);
            BufferedReader br = Files.newBufferedReader(path);
            String line;
            while ((line = br.readLine()) != null) {
                String[] studentData = line.split(" ");
                String name = studentData[0];
                List<Integer> grades = new ArrayList<>();
                for (int i = 1; i < studentData.length; i++) {
                    int grade = Integer.parseInt(studentData[i]);
                    grades.add(grade);
                }
                students.add (new Student(name, grades));
            }
        } catch (IOException ioe) {
            throw new IllegalStateException("Can not read file.", ioe);
        }
    }

Try With Resources try(BufferedReader br=Files.newBufferedReader(path)) in method public readGradesFromFile(filename String) : void from class ioreader.grades.SchoolRecordsManager


    public void readStatesFromFile(String stringFileName) {
        Path path = Path.of("src/main/resources/" + stringFileName);
        try (BufferedReader br = Files.newBufferedReader(path)) {
            String line;
            while ((line = br.readLine()) != null) {
                String[] splittedLine = line.split("-");
                states.add(new State(splittedLine[0], splittedLine[1]));
            }
        } catch (IOException ioe) {
            throw new IllegalStateException("Can't read file!");
        }
    }

    public void readStatesFromFile(String stringFileName) {
        try {
            Path path = Path.of("src/main/resources/" + stringFileName);
            BufferedReader br = Files.newBufferedReader(path);
            String line;
            while ((line = br.readLine()) != null) {
                String[] splittedLine = line.split("-");
                states.add(new State(splittedLine[0], splittedLine[1]));
            }
        } catch (IOException ioe) {
            throw new IllegalStateException("Can't read file!");
        }
    }

Try With Resources try(BufferedReader br=Files.newBufferedReader(path)) in method public readStatesFromFile(stringFileName String) : void from class ioreader.states.StateRegister


    public void readIdsFromFile(String fileName) {
        Path path = Path.of("src/main/resources/" + fileName);
        try (BufferedReader br = Files.newBufferedReader(path);) {
            String line;
            while ((line= br.readLine()) != null) {
                ids.add(line);
            }
        } catch (IOException ioe) {
            throw new IllegalStateException("Can not read file.", ioe);
        }

    }

    public void readIdsFromFile(String fileName) {
        try {
            Path path = Path.of("src/main/resources/" + fileName);
            BufferedReader br = Files.newBufferedReader(path);
            String line;
            while ((line= br.readLine()) != null) {
                ids.add(line);
            }
        } catch (IOException ioe) {
            throw new IllegalStateException("Can not read file.", ioe);
        }

    }

Try With Resources try(BufferedReader br=Files.newBufferedReader(path)) in method public readIdsFromFile(fileName String) : void from class ioreader.idread.IdManager


    @Override
    public List<Product> findAll() throws DaoException {
        try (Connection connection = ConnectionPool.getInstance().getConnection();
             PreparedStatement statement = connection.prepareStatement(FIND_ALL)) {
            ResultSet resultSet = statement.executeQuery();
            List<Product> productList = new ArrayList<>();
            while (resultSet.next()) {
                Product product = createProductFromResultSet(resultSet);
                productList.add(product);
            }
            return productList;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Finding all products error", e);
        }
    }

    @Override
    public List<Product> findAll() throws DaoException {
        Connection connection = null;
        PreparedStatement statement = null;
        try {
            connection = ConnectionPool.getInstance().getConnection();
            statement = connection.prepareStatement(FIND_ALL_PRODUCTS);
            ResultSet resultSet = statement.executeQuery();
            List<Product> productList = new ArrayList<>();
            while (resultSet.next()) {
                Product product = createProductFromResultSet(resultSet);
                productList.add(product);
            }
            return productList;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Finding all products error", e);
        } finally {
            close(statement);
            close(connection);
        }
    }

Try With Resources try(Connection connection=ConnectionPool.getInstance().getConnection(); PreparedStatement statement=connection.prepareStatement(FIND_ALL)) in method public findAll() : List<Product> from class com.traulko.project.dao.impl.ProductDaoImpl


    public boolean update(User user) throws DaoException {
        try (Connection connection = ConnectionPool.getInstance().getConnection();
             PreparedStatement statement = connection.prepareStatement(UPDATE_USER)) {
            statement.setString(1, user.getEmail());
            statement.setString(2, user.getName());
            statement.setString(3, user.getSurname());
            statement.setString(4, user.getPatronymic());
            statement.setString(5, String.valueOf(user.getRole()));
            statement.setString(6, String.valueOf(user.getStatus()));
            statement.setInt(7, Integer.valueOf(user.getUserId()));
            return statement.executeUpdate() > 0;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Updating user error", e);
        }
    }

    public boolean update(User user) throws DaoException {
        Connection connection = null;
        PreparedStatement statement = null;
        boolean result;
        try {
            connection = ConnectionPool.getInstance().getConnection();
            statement = connection.prepareStatement(UPDATE_USER);
            statement.setString(1, user.getEmail());
            statement.setString(2, user.getName());
            statement.setString(3, user.getSurname());
            statement.setString(4, user.getPatronymic());
            statement.setString(5, String.valueOf(user.getRole()));
            statement.setString(6, String.valueOf(user.getStatus()));
            statement.setInt(7, Integer.valueOf(user.getUserId()));
            result = statement.executeUpdate() > 0 ? true : false;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Updating user error", e);
        } finally {
            close(statement);
            close(connection);
        }
        return result;
    }

Try With Resources try(Connection connection=ConnectionPool.getInstance().getConnection(); PreparedStatement statement=connection.prepareStatement(UPDATE_USER)) in method public update(user User) : boolean from class com.traulko.project.dao.impl.UserDaoImpl


    @Override
    public List<User> findAll() throws DaoException {
        try (Connection connection = ConnectionPool.getInstance().getConnection();
             PreparedStatement statement = connection.prepareStatement(FIND_ALL_USERS)) {
            ResultSet resultSet = statement.executeQuery();
            List<User> userList = new ArrayList<>();
            while (resultSet.next()) {
                User user = createUserFromResultSet(resultSet);
                userList.add(user);
            }
            return userList;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Finding all users error", e);
        }
    }

    @Override
    public List<User> findAll() throws DaoException {
        Connection connection = null;
        PreparedStatement statement = null;
        try {
            connection = ConnectionPool.getInstance().getConnection();
            statement = connection.prepareStatement(FIND_ALL_USERS);
            ResultSet resultSet = statement.executeQuery();
            List<User> userList = new ArrayList<>();
            while (resultSet.next()) {
                User user = createUserFromResultSet(resultSet);
                userList.add(user);
            }
            return userList;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Finding all users error", e);
        } finally {
            close(statement);
            close(connection);
        }
    }

Try With Resources try(Connection connection=ConnectionPool.getInstance().getConnection(); PreparedStatement statement=connection.prepareStatement(FIND_ALL_USERS)) in method public findAll() : List<User> from class com.traulko.project.dao.impl.UserDaoImpl


    @Override
    public List<User> findBySearchQuery(String searchQuery) throws DaoException {
        try (Connection connection = ConnectionPool.getInstance().getConnection();
             PreparedStatement statement = connection.prepareStatement(FIND_USERS_BY_SEARCH_QUERY)) {
            statement.setString(1, PERCENT + searchQuery + PERCENT);
            ResultSet resultSet = statement.executeQuery();
            List<User> userList = new ArrayList<>();
            while (resultSet.next()) {
                User user = createUserFromResultSet(resultSet);
                userList.add(user);
            }
            return userList;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Finding users by search query error", e);
        }
    }

    @Override
    public List<User> findBySearchQuery(String searchQuery) throws DaoException {
        Connection connection = null;
        PreparedStatement statement = null;
        try {
            connection = ConnectionPool.getInstance().getConnection();
            statement = connection.prepareStatement(FIND_USERS_BY_SEARCH_QUERY);
            statement.setString(1, PERCENT + searchQuery + PERCENT);
            ResultSet resultSet = statement.executeQuery();
            List<User> userList = new ArrayList<>();
            while (resultSet.next()) {
                User user = createUserFromResultSet(resultSet);
                userList.add(user);
            }
            return userList;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Finding users by search query error", e);
        } finally {
            close(statement);
            close(connection);
        }
    }

Try With Resources try(Connection connection=ConnectionPool.getInstance().getConnection(); PreparedStatement statement=connection.prepareStatement(FIND_USERS_BY_SEARCH_QUERY)) in method public findBySearchQuery(searchQuery String) : List<User> from class com.traulko.project.dao.impl.UserDaoImpl


    @Override
    public Optional<User> findByEmail(String email) throws DaoException {
        try (Connection connection = ConnectionPool.getInstance().getConnection();
             PreparedStatement statement = connection.prepareStatement(FIND_USER_BY_EMAIL)) {
            statement.setString(1, email);
            ResultSet resultSet = statement.executeQuery();
            Optional<User> userOptional = Optional.empty();
            if (resultSet.next()) {
                User user = createUserFromResultSet(resultSet);
                userOptional = Optional.of(user);
            }
            return userOptional;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Finding user by email error", e);
        }
    }

    @Override
    public Optional<User> findByEmail(String email) throws DaoException {
        Connection connection = null;
        PreparedStatement statement = null;
        try {
            connection = ConnectionPool.getInstance().getConnection();
            statement = connection.prepareStatement(FIND_USER_BY_EMAIL);
            statement.setString(1, email);
            ResultSet resultSet = statement.executeQuery();
            Optional<User> userOptional = Optional.empty();
            if (resultSet.next()) {
                User user = createUserFromResultSet(resultSet);
                userOptional = Optional.of(user);
            }
            return userOptional;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Finding user by email error", e);
        } finally {
            close(statement);
            close(connection);
        }
    }

Try With Resources try(Connection connection=ConnectionPool.getInstance().getConnection(); PreparedStatement statement=connection.prepareStatement(FIND_USER_BY_EMAIL)) in method public findByEmail(email String) : Optional<User> from class com.traulko.project.dao.impl.UserDaoImpl


    @Override
    public boolean changePassword(String email, String password) throws DaoException {
        try (Connection connection = ConnectionPool.getInstance().getConnection();
             PreparedStatement statement = connection.prepareStatement(CHANGE_PASSWORD)) {
            statement.setString(1, password);
            statement.setString(2, email);
            return statement.executeUpdate() > 0;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Changing password error", e);
        }
    }

    @Override
    public boolean changePassword(String email, String password) throws DaoException {
        Connection connection = null;
        PreparedStatement statement = null;
        boolean result;
        try {
            connection = ConnectionPool.getInstance().getConnection();
            statement = connection.prepareStatement(CHANGE_PASSWORD);
            statement.setString(1, password);
            statement.setString(2, email);
            result = statement.executeUpdate() > 0;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Changing password error", e);
        } finally {
            close(statement);
            close(connection);
        }
        return result;
    }

Try With Resources try(Connection connection=ConnectionPool.getInstance().getConnection(); PreparedStatement statement=connection.prepareStatement(CHANGE_PASSWORD)) in method public changePassword(email String, password String) : boolean from class com.traulko.project.dao.impl.UserDaoImpl


    @Override
    public boolean add(User user, String encryptedPassword) throws DaoException {
        try (Connection connection = ConnectionPool.getInstance().getConnection();
             PreparedStatement statement = connection.prepareStatement(ADD_USER)) {
            statement.setString(1, user.getEmail());
            statement.setString(2, encryptedPassword);
            statement.setString(3, user.getName());
            statement.setString(4, user.getSurname());
            statement.setString(5, user.getPatronymic());
            statement.setString(6, user.getRole().toString());
            statement.setString(7, user.getStatus().toString());
            return statement.executeUpdate() > 0;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Adding user to users table error", e);
        }
    }

    @Override
    public boolean add(User user, String encryptedPassword) throws DaoException {
        Connection connection = null;
        PreparedStatement statement = null;
        boolean result;
        try {
            connection = ConnectionPool.getInstance().getConnection();
            statement = connection.prepareStatement(ADD_USER);
            statement.setString(1, user.getEmail());
            statement.setString(2, encryptedPassword);
            statement.setString(3, user.getName());
            statement.setString(4, user.getSurname());
            statement.setString(5, user.getPatronymic());
            statement.setString(6, user.getRole().toString());
            statement.setString(7, user.getStatus().toString());
            result = statement.executeUpdate() > 0 ? true : false;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Adding user to users table error", e);
        } finally {
            close(statement);
            close(connection);
        }
        return result;
    }

Try With Resources try(Connection connection=ConnectionPool.getInstance().getConnection(); PreparedStatement statement=connection.prepareStatement(ADD_USER)) in method public add(user User, encryptedPassword String) : boolean from class com.traulko.project.dao.impl.UserDaoImpl


    public Optional<User> findByEmailAndPassword(String email, String password) throws DaoException {
        try (Connection connection = ConnectionPool.getInstance().getConnection();
             PreparedStatement statement = connection.prepareStatement(FIND_USER_BY_EMAIL_AND_PASSWORD)) {
            statement.setString(1, email);
            statement.setString(2, password);
            ResultSet resultSet = statement.executeQuery();
            Optional<User> userOptional = Optional.empty();
            if (resultSet.next()) {
                User user = createUserFromResultSet(resultSet);
                userOptional = Optional.of(user);
            }
            return userOptional;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Finding user by email and password error", e);
        }
    }

    public Optional<User> findByEmailAndPassword(String email, String password) throws DaoException {
        Connection connection = null;
        PreparedStatement statement = null;
        try {
            connection = ConnectionPool.getInstance().getConnection();
            statement = connection.prepareStatement(FIND_USER_BY_EMAIL_AND_PASSWORD);
            statement.setString(1, email);
            statement.setString(2, password);
            ResultSet resultSet = statement.executeQuery();
            Optional<User> userOptional = Optional.empty();
            if (resultSet.next()) {
                User user = createUserFromResultSet(resultSet);
                userOptional = Optional.of(user);
            }
            return userOptional;
        } catch (SQLException | ConnectionDatabaseException e) {
            throw new DaoException("Finding user by email and password error", e);
        } finally {
            close(statement);
            close(connection);
        }
    }

Try With Resources try(Connection connection=ConnectionPool.getInstance().getConnection(); PreparedStatement statement=connection.prepareStatement(FIND_USER_BY_EMAIL_AND_PASSWORD)) in method public findByEmailAndPassword(email String, password String) : Optional<User> from class com.traulko.project.dao.impl.UserDaoImpl


    /**
     * Configures the logging for the MaryTTS system.
     */
    private static void configureLogging() {
        if (loggingConfigured.compareAndSet(false, true)) {
            Properties props = new Properties();
            try (InputStream configStream = LocalMaryInterface.class.getResourceAsStream("util/log4j.properties")) {
                props.load(configStream);
            } catch (IOException ignored) {
            }
            String workingDirectory = Paths.get(".").toAbsolutePath().normalize().toString().replace("\\", "/") + '/';
            props.setProperty("log4j.appender.logfile.File", workingDirectory + "log/" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + "/marytts.log");
            LogManager.resetConfiguration();
            PropertyConfigurator.configure(props);
        }
    }

    /**
     * Configures the logging for the MaryTTS system.
     */
    private static void configureLogging() {
        if (loggingConfigured.compareAndSet(false, true)) {
            Properties props = new Properties();
            try {
                InputStream configStream = LocalMaryInterface.class.getResourceAsStream("util/log4j.properties");
                props.load(configStream);
                configStream.close();
            } catch (IOException ignored) {
            }
            String workingDirectory = Paths.get(".").toAbsolutePath().normalize().toString().replace("\\", "/") + '/';
            props.setProperty("log4j.appender.logfile.File", workingDirectory + "log/" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()) + "/marytts.log");
            LogManager.resetConfiguration();
            PropertyConfigurator.configure(props);
        }
    }

Try With Resources try(InputStream configStream=LocalMaryInterface.class.getResourceAsStream("util/log4j.properties")) in method private configureLogging() : void from class commons.io.speech.SpeechSynthesizer


    /**
     * Executes a command on the system command line.
     *
     * @param cmd The command to execute.
     * @return The output.
     */
    public static String executeCmd(String cmd) {
        try {
            ProcessBuilder builder = buildProcess(cmd);
            StringBuilder response = new StringBuilder();

            Process process = builder.start();
            try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {

                String line;
                while (true) {
                    line = reader.readLine();
                    if (line == null) {
                        break;
                    }
                    response.append(line).append(System.lineSeparator());
                }
            }
            process.waitFor();
            process.destroy();

            return response.toString();

        } catch (IOException | InterruptedException e) {
            logger.warn("Error executing command: " + cmd);
        } catch (Exception e) {
            logger.error("Error executing command: " + cmd, e);
        }
        return "";
    }

    /**
     * Executes a command on the system command line.
     *
     * @param cmd  The command to execute.
     * @param wait Whether to wait for the execution to finish or not.
     * @return The output.
     * @see #buildProcess(String, boolean)
     */
    public static String executeCmd(String cmd, boolean wait) {
        try {
            ProcessBuilder builder = buildProcess(cmd, true);

            Process process = builder.start();
            BufferedReader r = new BufferedReader(new InputStreamReader(process.getInputStream()));

            StringBuilder response = new StringBuilder();
            String line;
            while (true) {
                line = r.readLine();
                if (line == null) {
                    break;
                }
                response.append(line).append(System.lineSeparator());
            }

            if (wait) {
                process.waitFor();
            }
            r.close();
            process.destroy();

            return response.toString();

        } catch (IOException | InterruptedException e) {
            logger.warn("Error executing command: " + cmd);
        } catch (Exception e) {
            logger.error("Error executing command: " + cmd, e);
        }
        return "";
    }

Try With Resources try(BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream()))) in method public executeCmd(cmd String) : String from class commons.access.CmdLine


				@Override
				public FileVisitResult visitFile(java.nio.file.Path file, BasicFileAttributes attrs)
						throws IOException {
					File ttf = file.toFile();
					String fontName = ttf.getName();
					if ((fontName.endsWith(EXT_TTF) || fontName.endsWith( EXT_TTF.toUpperCase()))
							&& !fontName.contains("_subset.")) {
						existTTF = Boolean.TRUE;
						String fileName = removeExt(fontName);
						boolean hasText = hasSubstring != null && hasSubstring.trim().length() != 0;
						if (hasText) {
							fileName = fileName + "_subset";
						}
						mkdir(absolutePath, format);
						final String newFileName = absolutePath + File.separatorChar + format + File.separatorChar
								+ fileName + "." + format;
						try (FileOutputStream fos = new FileOutputStream(newFileName)) {
							WriterFactory.getWriter(format).subset(ttf.getAbsolutePath(), fos, hasSubstring,
									stripHinting);
						} catch (Exception e) {
							e.printStackTrace();
							// ignore exception
						}

					}
					return super.visitFile(file, attrs);
				}

				@Override
				public FileVisitResult visitFile(java.nio.file.Path file, BasicFileAttributes attrs)
						throws IOException {
					File ttf = file.toFile();
					String fontName = ttf.getName();
					if ((fontName.endsWith("." + EXT_TTF) || fontName.endsWith("." + EXT_TTF.toUpperCase()))
							&& !fontName.contains("_subset.")) {
						existTTF = Boolean.TRUE;
						String fileName = removeExt(fontName);
						boolean hasText = hasSubstring != null && hasSubstring.trim().length() != 0;
						if (hasText) {
							fileName = fileName + "_subset";
						}
						mkdir(absolutePath, format);
						final String newFileName = absolutePath + File.separatorChar + format + File.separatorChar
								+ fileName;
						try {
							holders.get(format)
									.subset(ttf.getAbsolutePath(), newFileName + "." + format, hasSubstring, stripHinting);
						} catch (Exception e) {
							e.printStackTrace();
							// ignore exception
						}

					}
					return super.visitFile(file, attrs);
				}

Try With Resources try(FileOutputStream fos=new FileOutputStream(newFileName)) in method public visitFile(file Path, attrs BasicFileAttributes) : FileVisitResult from class com.github.sfntly.gui.FontSubEventHandler.handle.walkFileTree.new SimpleFileVisitor<java.nio.file.Path>


    private Builder(FontFactory factory) {
      this.factory = factory;
      this.tableBuilders = new HashMap<>();
    }

    private Builder(FontFactory factory) {
      this.factory = factory;
      this.tableBuilders = new HashMap<Integer, Table.Builder<? extends Table>>();
    }

Replace Generic With Diamond HashMap<Integer,Table.Builder<? extends Table>> with HashMap<> in method private Builder(factory FontFactory) from class com.google.typography.font.sfntly.Font.Builder


  public void lintFontFile(File fontFile) throws IOException {
    try (FileInputStream fis = new FileInputStream(fontFile)) {
      Font[] fontArray = fontFactory.loadFonts(fis);
      for (Font font : fontArray) {
        lintFont(font);
      }
    }
  }

  public void lintFontFile(File fontFile) throws IOException {
    FileInputStream fis = null;
    try {
      fis = new FileInputStream(fontFile);
      Font[] fontArray = fontFactory.loadFonts(fis);
      for (Font font : fontArray) {
        lintFont(font);
      }
    } finally {
      if (fis != null) {
        fis.close();
      }
    }
  }

Try With Resources try(FileInputStream fis=new FileInputStream(fontFile)) in method public lintFontFile(fontFile File) : void from class com.google.typography.font.sfntly.sample.sflint.SFLint


  public void dumpFont(File fontFile) throws IOException {
    boolean canDumpGlyphs = true;

    System.out.println(fontFile + " ============================");
    try (FileInputStream fis = new FileInputStream(fontFile)) {
      Font[] fontArray = fontFactory.loadFonts(fis);

      for (int fontNumber = 0; fontNumber < fontArray.length; fontNumber++) {
        Font font = fontArray[fontNumber];
        if (fontArray.length > 1) {
          System.out.println();
          System.out.println("======= TTC Entry #" + fontNumber);
          System.out.println();
        }
        if (dumpTableHeadersInFont) {
          for (Map.Entry<Integer, ? extends Table> entry : font.tableMap().entrySet()) {
            System.out.println(entry.getValue().header());
          }
        }

        if (countSpecialGlyphs) {
          countSpecialGlyphs(font);
        }

        if (dumpNameList) {
          System.out.println();
          System.out.println("----- Name Tables");
          NameTable name = font.getTable(Tag.name);
          for (NameTable.NameEntry entry : name) {
            System.out.println(entry);
          }
        }

        if (dumpCmapList) {
          System.out.println();
          System.out.println("------ CMap Tables");
          CMapTable cmapTable = font.getTable(Tag.cmap);
          for (CMap cmap : cmapTable) {
            System.out.println(cmap);
            if (cmapMapping) {
              dumpCMapMapping(cmap);
            }
          }
        }

        if (dumpPost) {
          System.out.println();
          System.out.println("------ Post Table");
          PostScriptTable post = font.getTable(Tag.post);
          int nGlyphs = post.numberOfGlyphs();
          for (int glyphId = 0; glyphId < nGlyphs; glyphId++) {
            System.out.printf("%d: %s%n", glyphId, post.glyphName(glyphId));
          }
        }

        if (dumpEblc) {
          System.out.println();
          System.out.println("------ EBLC Table");
          EblcTable eblcTable = font.getTable(Tag.EBLC);
          System.out.println(eblcTable.toString());
        }

        if (tablesToBinaryDump.size() > 0) {
          for (String tag : tablesToBinaryDump) {
            int tableTag = Tag.intValue(tag);
            Table table = font.getTable(tableTag);
            if (table != null) {
              System.out.println();
              System.out.printf(
                  "------ Dump Data - Table = %s, length = %x%n", tag, table.dataLength());
              ReadableFontData data = table.readFontData();
              for (int i = 0; i < data.length(); i += 16) {
                System.out.printf("%08x: ", i);
                for (int j = i; j < i + 16 && j < data.length(); j++) {
                  System.out.printf("%02x ", data.readUByte(j));
                }
                System.out.println();
              }
              System.out.println();
            }
          }
        }

        LocaTable locaTable = font.getTable(Tag.loca);
        GlyphTable glyphTable = font.getTable(Tag.glyf);
        if (locaTable == null) {
          canDumpGlyphs = false;
          System.out.println("PROBLEM: font has no 'loca' table.");
        }
        if (glyphTable == null) {
          canDumpGlyphs = false;
          System.out.println("PROBLEM: font has no 'glyf' table.");
        }

        if (canDumpGlyphs && glyphSet != null) {
          System.out.println();
          System.out.println("------ Glyphs");
          for (int glyphId = glyphSet.nextSetBit(0);
              glyphId >= 0;
              glyphId = glyphSet.nextSetBit(glyphId + 1)) {
            int offset = locaTable.glyphOffset(glyphId);
            int length = locaTable.glyphLength(glyphId);
            Glyph glyph = glyphTable.glyph(offset, length);
            System.out.println("glyph id = " + glyphId);
            System.out.println(glyph);
          }
        }

        if (canDumpGlyphs && charSet != null) {
          dumpChars(font, locaTable, glyphTable);
        }
      }
    }
  }

  public void dumpFont(File fontFile) throws IOException {
    boolean canDumpGlyphs = true;

    FileInputStream fis = null;
    System.out.println(fontFile + " ============================");
    try {
      fis = new FileInputStream(fontFile);
      Font[] fontArray = fontFactory.loadFonts(fis);

      for (int fontNumber = 0; fontNumber < fontArray.length; fontNumber++) {
        Font font = fontArray[fontNumber];
        if (fontArray.length > 1) {
          System.out.println("\n======= TTC Entry #" + fontNumber + "\n");
        }
        if (this.dumpTableHeadersInFont) {
          for (Map.Entry<Integer, ? extends Table> entry : font.tableMap().entrySet()) {
            System.out.println(entry.getValue().header());
          }
        }

        if (this.countSpecialGlyphs) {
          this.countSpecialGlyphs(font);
        }

        if (this.dumpNameList) {
          System.out.println("\n----- Name Tables");
          NameTable name = (NameTable) font.getTable(Tag.name);
          for (NameEntry entry : name) {
            System.out.println(entry);
          }
        }

        if (this.dumpCmapList) {
          System.out.println("\n------ CMap Tables");
          CMapTable cmapTable = (CMapTable) font.getTable(Tag.cmap);
          for (CMap cmap : cmapTable) {
            System.out.println(cmap);
            if (this.cmapMapping) {
              dumpCMapMapping(cmap);
            }
          }
        }

        if (this.dumpPost) {
          System.out.println("\n------ Post Table");
          PostScriptTable post = font.getTable(Tag.post);
          int nGlyphs = post.numberOfGlyphs();
          for (int glyphId = 0; glyphId < nGlyphs; glyphId++) {
            System.out.printf("%d: %s\n", glyphId, post.glyphName(glyphId));
          }
        }

        if (this.dumpEblc) {
          System.out.println("\n------ EBLC Table");
          EblcTable eblcTable = font.getTable(Tag.EBLC);
          System.out.println(eblcTable.toString());
        }

        if (this.tablesToBinaryDump.size() > 0) {
          for (String tag : this.tablesToBinaryDump) {
            int tableTag = Tag.intValue(tag);
            Table table = font.getTable(tableTag);
            if (table != null) {
              System.out.println("\n------ Dump Data - Table = " + tag + ", length = "
                  + Integer.toHexString(table.dataLength()));
              ReadableFontData data = table.readFontData();
              for (int i = 0; i < data.length(); i += 16) {
                System.out.printf("%08x: ", i);
                for (int j = i; (j < i + 16) && j < data.length(); j++) {
                  System.out.printf("%02x ", data.readUByte(j));
                }
                System.out.println();
              }
              System.out.println();
            }
          }
        }

        LocaTable locaTable = font.getTable(Tag.loca);
        GlyphTable glyphTable = font.getTable(Tag.glyf);
        if (locaTable == null) {
          canDumpGlyphs = false;
          System.out.println("PROBLEM: font has no 'loca' table.");
        }
        if (glyphTable == null) {
          canDumpGlyphs = false;
          System.out.println("PROBLEM: font has no 'glyf' table.");
        }

        if (canDumpGlyphs && this.glyphSet != null) {
          System.out.println("\n------ Glyphs");
          for (int glyphId = this.glyphSet.nextSetBit(0);
          glyphId >= 0; glyphId = this.glyphSet.nextSetBit(glyphId+1)) {
            int offset = locaTable.glyphOffset(glyphId);
            int length = locaTable.glyphLength(glyphId);
            Glyph glyph = glyphTable.glyph(offset, length);
            System.out.println("glyph id = " + glyphId);
            if (glyph != null) {
              System.out.println(glyph);
            }
          }
        }

        if (canDumpGlyphs && this.charSet != null) {
          dumpChars(font, locaTable, glyphTable);
        }
      }
    } finally {
      if (fis != null) {
        fis.close();
      }
    }
  }

Try With Resources try(FileInputStream fis=new FileInputStream(fontFile)) in method public dumpFont(fontFile File) : void from class com.google.typography.font.sfntly.sample.sfntdump.SfntDump


  private static Font[] loadFont(File file) throws IOException {
    FontFactory fontFactory = FontFactory.getInstance();
    fontFactory.fingerprintFont(true);
    try (FileInputStream is = new FileInputStream(file)) {
      return fontFactory.loadFonts(is);
    } catch (FileNotFoundException e) {
      System.err.println("Could not load the font: " + file.getName());
      return null;
    }
  }

  private static Font[] loadFont(File file) throws IOException {
    FontFactory fontFactory = FontFactory.getInstance();
    fontFactory.fingerprintFont(true);
    FileInputStream is = new FileInputStream(file);
    try {
      return fontFactory.loadFonts(is);
    } catch (FileNotFoundException e) {
      System.err.println("Could not load the font: " + file.getName());
      return null;
    } finally {
      is.close();
    }
  }

Try With Resources try(FileInputStream is=new FileInputStream(file)) in method private loadFont(file File) : Font[] from class com.google.typography.font.sfntly.sample.sfview.GsubRulesDump


  public static Font[] loadFont(File file) throws IOException {
    FontFactory fontFactory = FontFactory.getInstance();
    fontFactory.fingerprintFont(true);
    try (FileInputStream is = new FileInputStream(file)) {
      return fontFactory.loadFonts(is);
    }
  }

  public static Font[] loadFont(File file) throws IOException {
    FontFactory fontFactory = FontFactory.getInstance();
    fontFactory.fingerprintFont(true);
    FileInputStream is = null;
    try {
      is = new FileInputStream(file);
      return fontFactory.loadFonts(is);
    } finally {
      if (is != null) {
        is.close();
      }
    }
  }

Try With Resources try(FileInputStream is=new FileInputStream(file)) in method public loadFont(file File) : Font[] from class com.google.typography.font.sfntly.sample.sfview.HtmlViewer


  OtTableTagger(TaggedData tdata) {
    this.td = tdata;
    this.tagMethodRegistry = new HashMap<>();

    registerTagMethods();
  }

  OtTableTagger(TaggedData tdata) {
    this.td = tdata;
    this.tagMethodRegistry = new HashMap<Class<? extends FontDataTable>, TagMethod>();

    registerTagMethods();
  }

Replace Generic With Diamond HashMap<Class<? extends FontDataTable>,TagMethod> with HashMap<> in method package OtTableTagger(tdata TaggedData) from class com.google.typography.font.sfntly.sample.sfview.OtTableTagger


  public static Font[] loadFont(File file) throws IOException {
    FontFactory fontFactory = FontFactory.getInstance();
    fontFactory.fingerprintFont(true);
    try (FileInputStream is = new FileInputStream(file)) {
      return fontFactory.loadFonts(is);
    } catch (FileNotFoundException e) {
      System.err.println("Could not load the font: " + file.getName());
      return null;
    }
  }

  public static Font[] loadFont(File file) throws IOException {
    FontFactory fontFactory = FontFactory.getInstance();
    fontFactory.fingerprintFont(true);
    FileInputStream is = new FileInputStream(file);
    try {
      return fontFactory.loadFonts(is);
    } catch (FileNotFoundException e) {
      System.err.println("Could not load the font: " + file.getName());
      return null;
    } finally {
      is.close();
    }
  }

Try With Resources try(FileInputStream is=new FileInputStream(file)) in method public loadFont(file File) : Font[] from class com.google.typography.font.sfntly.sample.sfview.RuleDump


  private static Font[] loadFont(File file) throws IOException {
    FontFactory fontFactory = FontFactory.getInstance();
    fontFactory.fingerprintFont(true);
    try {
      try (FileInputStream is = new FileInputStream(file)) {
        return fontFactory.loadFonts(is);
      }
    } catch (FileNotFoundException e) {
      System.err.println("Could not load the font: " + file.getName());
      return null;
    }
  }

  private static Font[] loadFont(File file) throws IOException {
    FontFactory fontFactory = FontFactory.getInstance();
    fontFactory.fingerprintFont(true);
    FileInputStream is = null;
    try {
      is = new FileInputStream(file);
      return fontFactory.loadFonts(is);
    } catch (FileNotFoundException e) {
      System.err.println("Could not load the font: " + file.getName());
      return null;
    } finally {
      if (is != null) {
        is.close();
      }
    }
  }

Try With Resources try(FileInputStream is=new FileInputStream(file)) in method private loadFont(file File) : Font[] from class com.google.typography.font.sfntly.sample.sfview.SFView


    private RefWidthFinder() {
      tgt2widthUsage = new TreeMap<>();
    }

    private RefWidthFinder() {
      tgt2widthUsage = new TreeMap<Integer, WidthUsageRecord>();
    }

Replace Generic With Diamond TreeMap<Integer,WidthUsageRecord> with TreeMap<> in method private RefWidthFinder() from class com.google.typography.font.sfntly.sample.sfview.ViewableTaggedData.RefWidthFinder


      public static List<Builder.Segment> deepCopy(List<Builder.Segment> original) {
        List<Builder.Segment> list = new ArrayList<>(original.size());
        for (Builder.Segment segment : original) {
          list.add(new Segment(segment));
        }
        return list;
      }

      public static List<Builder.Segment> deepCopy(List<Builder.Segment> original) {
        List<Builder.Segment> list = new ArrayList<Builder.Segment>(original.size());
        for (Builder.Segment segment : original) {
          list.add(new Segment(segment));
        }
        return list;
      }

Replace Generic With Diamond ArrayList<Builder.Segment> with ArrayList<> in method public deepCopy(original List<Builder.Segment>) : List<Builder.Segment> from class com.google.typography.font.sfntly.table.core.CMapFormat4.Builder.Segment


    private void initialize(ReadableFontData data) {
      this.cmapBuilders = new /*TreeMap*/ HashMap<>();

      int numCMaps = numCMaps(data);
      for (int i = 0; i < numCMaps; i++) {
        CMap.Builder<? extends CMap> cmapBuilder = cmapBuilder(data, i);
        cmapBuilders.put(cmapBuilder.cmapId(), cmapBuilder);
      }
    }

    private void initialize(ReadableFontData data) {
      this.cmapBuilders = new /*TreeMap*/ HashMap<CMapId, CMap.Builder<? extends CMap>>();

      int numCMaps = numCMaps(data);
      for (int i = 0; i < numCMaps; i++) {
        CMap.Builder<? extends CMap> cmapBuilder = cmapBuilder(data, i);
        cmapBuilders.put(cmapBuilder.cmapId(), cmapBuilder);
      }
    }

Replace Generic With Diamond HashMap<CMapId,CMap.Builder<? extends CMap>> with HashMap<> in method private initialize(data ReadableFontData) : void from class com.google.typography.font.sfntly.table.core.CMapTable.Builder


  public static FeatureTag forTagValue(int value) {
    synchronized (FeatureTag.class) {
      if (tagMap == null) {
        Map<Integer, FeatureTag> map = new HashMap<>();
        for (FeatureTag tag : values()) {
          map.put(tag.tag(), tag);
        }
        tagMap = map;
      }
      return tagMap.get(value);
    }
  }

  public static FeatureTag forTagValue(int value) {
    synchronized (FeatureTag.class) {
      if (tagMap == null) {
        Map<Integer, FeatureTag> map = new HashMap<Integer, FeatureTag>();
        for (FeatureTag tag : values()) {
          map.put(tag.tag(), tag);
        }
        tagMap = map;
      }
      return tagMap.get(value);
    }
  }

Replace Generic With Diamond HashMap<Integer,FeatureTag> with HashMap<> in method public forTagValue(value int) : FeatureTag from class com.google.typography.font.sfntly.table.opentype.FeatureTag


    private void initFromData(ReadableFontData data) {
      int count = readLookupCount(data);
      builders = new ArrayList<>(count);
      for (int i = 0; i < count; ++i) {
        ReadableFontData lookupData = readLookupData(data, dataIsCanonical, i);
        LookupTable.Builder lookup = createLookupBuilder(lookupData);
        if (lookup != null) {
          builders.add(lookup);
        }
      }
    }

    private void initFromData(ReadableFontData data) {
      int count = readLookupCount(data);
      builders = new ArrayList<LookupTable.Builder>(count);
      for (int i = 0; i < count; ++i) {
        ReadableFontData lookupData = readLookupData(data, dataIsCanonical, i);
        LookupTable.Builder lookup = createLookupBuilder(lookupData);
        if (lookup != null) {
          builders.add(lookup);
        }
      }
    }

Replace Generic With Diamond ArrayList<LookupTable.Builder> with ArrayList<> in method private initFromData(data ReadableFontData) : void from class com.google.typography.font.sfntly.table.opentype.LookupList.Builder


    @Override
    public void subDataSet() {
      map = new HashMap<>();
    }

    @Override
    public void subDataSet() {
      map = new HashMap<Integer, Integer>();
    }

Replace Generic With Diamond HashMap<Integer,Integer> with HashMap<> in method public subDataSet() : void from class com.google.typography.font.sfntly.table.opentype.component.HeaderTable.Builder


  static List<Rule> prependToInput(int prefix, List<Rule> rules) {
    List<Rule> result = new ArrayList<>();
    for (Rule rule : rules) {
      result.add(prependToInput(prefix, rule));
    }
    return result;
  }

  static List<Rule> prependToInput(int prefix, List<Rule> rules) {
    List<Rule> result = new ArrayList<Rule>();
    for (Rule rule : rules) {
      result.add(prependToInput(prefix, rule));
    }
    return result;
  }

Replace Generic With Diamond ArrayList<Rule> with ArrayList<> in method package prependToInput(prefix int, rules List<Rule>) : List<Rule> from class com.google.typography.font.sfntly.table.opentype.component.Rule


  static Set<Rule> deltaRules(List<Integer> glyphIds, int delta) {
    Set<Rule> result = new LinkedHashSet<>();
    for (int glyphId : glyphIds) {
      RuleSegment input = new RuleSegment(glyphId);
      RuleSegment subst = new RuleSegment(glyphId + delta);
      result.add(new Rule(null, input, null, subst));
    }
    return result;
  }

  static Set<Rule> deltaRules(List<Integer> glyphIds, int delta) {
    Set<Rule> result = new LinkedHashSet<Rule>();
    for (int glyphId : glyphIds) {
      RuleSegment input = new RuleSegment(glyphId);
      RuleSegment subst = new RuleSegment(glyphId + delta);
      result.add(new Rule(null, input, null, subst));
    }
    return result;
  }

Replace Generic With Diamond LinkedHashSet<Rule> with LinkedHashSet<> in method package deltaRules(glyphIds List<Integer>, delta int) : Set<Rule> from class com.google.typography.font.sfntly.table.opentype.component.Rule


  private static Set<Rule> extract(LigatureSubst table) {
    Set<Rule> allRules = new LinkedHashSet<>();
    List<Integer> prefixChars = extract(table.coverage());

    for (int i = 0; i < table.subTableCount(); i++) {
      List<Rule> subRules = extract(table.subTableAt(i));
      subRules = Rule.prependToInput(prefixChars.get(i), subRules);
      allRules.addAll(subRules);
    }
    return allRules;
  }

  private static Set<Rule> extract(LigatureSubst table) {
    Set<Rule> allRules = new LinkedHashSet<Rule>();
    List<Integer> prefixChars = extract(table.coverage());

    for (int i = 0; i < table.subTableCount(); i++) {
      List<Rule> subRules = extract(table.subTableAt(i));
      subRules = Rule.prependToInput(prefixChars.get(i), subRules);
      allRules.addAll(subRules);
    }
    return allRules;
  }

Replace Generic With Diamond LinkedHashSet<Rule> with LinkedHashSet<> in method private extract(table LigatureSubst) : Set<Rule> from class com.google.typography.font.sfntly.table.opentype.component.RuleExtractor


  private static Map<Integer, GlyphGroup> extract(RangeRecordTable table) {
    // Order is important.
    Map<Integer, GlyphGroup> result = new LinkedHashMap<>();
    for (RangeRecord record : table.recordList) {
      if (!result.containsKey(record.property)) {
        result.put(record.property, new GlyphGroup());
      }
      GlyphGroup existingGlyphs = result.get(record.property);
      existingGlyphs.addAll(extract(record));
    }
    return result;
  }

  private static Map<Integer, GlyphGroup> extract(RangeRecordTable table) {
    // Order is important.
    Map<Integer, GlyphGroup> result = new LinkedHashMap<Integer, GlyphGroup>();
    for (RangeRecord record : table.recordList) {
      if (!result.containsKey(record.property)) {
        result.put(record.property, new GlyphGroup());
      }
      GlyphGroup existingGlyphs = result.get(record.property);
      existingGlyphs.addAll(extract(record));
    }
    return result;
  }

Replace Generic With Diamond LinkedHashMap<Integer,GlyphGroup> with LinkedHashMap<> in method private extract(table RangeRecordTable) : Map<Integer,GlyphGroup> from class com.google.typography.font.sfntly.table.opentype.component.RuleExtractor


  private static List<Rule> extract(LigatureSet table) {
    List<Rule> allRules = new ArrayList<>();

    for (int i = 0; i < table.subTableCount(); i++) {
      Rule subRule = extract(table.subTableAt(i));
      allRules.add(subRule);
    }
    return allRules;
  }

  private static List<Rule> extract(LigatureSet table) {
    List<Rule> allRules = new ArrayList<Rule>();

    for (int i = 0; i < table.subTableCount(); i++) {
      Rule subRule = extract(table.subTableAt(i));
      allRules.add(subRule);
    }
    return allRules;
  }

Replace Generic With Diamond ArrayList<Rule> with ArrayList<> in method private extract(table LigatureSet) : List<Rule> from class com.google.typography.font.sfntly.table.opentype.component.RuleExtractor


  private static Set<Rule> extract(MultipleSubst table) {
    Set<Rule> result = new LinkedHashSet<>();

    GlyphList coverage = extract(table.coverage());
    int i = 0;
    for (NumRecordTable glyphIds : table) {
      RuleSegment input = new RuleSegment(coverage.get(i));

      GlyphList glyphList = extract(glyphIds);
      RuleSegment subst = new RuleSegment(glyphList);

      Rule rule = new Rule(null, input, null, subst);
      result.add(rule);
      i++;
    }
    return result;
  }

  private static Set<Rule> extract(MultipleSubst table) {
    Set<Rule> result = new LinkedHashSet<Rule>();

    GlyphList coverage = extract(table.coverage());
    int i = 0;
    for (NumRecordTable glyphIds : table) {
      RuleSegment input = new RuleSegment(coverage.get(i));

      GlyphList glyphList = extract(glyphIds);
      RuleSegment subst = new RuleSegment(glyphList);

      Rule rule = new Rule(null, input, null, subst);
      result.add(rule);
      i++;
    }
    return result;
  }

Replace Generic With Diamond LinkedHashSet<Rule> with LinkedHashSet<> in method private extract(table MultipleSubst) : Set<Rule> from class com.google.typography.font.sfntly.table.opentype.component.RuleExtractor


  private static Set<Rule> extract(AlternateSubst table) {
    Set<Rule> result = new LinkedHashSet<>();

    GlyphList coverage = extract(table.coverage());
    int i = 0;
    for (NumRecordTable glyphIds : table) {
      RuleSegment input = new RuleSegment(coverage.get(i));

      GlyphList glyphList = extract(glyphIds);
      GlyphGroup glyphGroup = new GlyphGroup(glyphList);
      RuleSegment subst = new RuleSegment(glyphGroup);

      Rule rule = new Rule(null, input, null, subst);
      result.add(rule);
      i++;
    }
    return result;
  }

  private static Set<Rule> extract(AlternateSubst table) {
    Set<Rule> result = new LinkedHashSet<Rule>();

    GlyphList coverage = extract(table.coverage());
    int i = 0;
    for (NumRecordTable glyphIds : table) {
      RuleSegment input = new RuleSegment(coverage.get(i));

      GlyphList glyphList = extract(glyphIds);
      GlyphGroup glyphGroup = new GlyphGroup(glyphList);
      RuleSegment subst = new RuleSegment(glyphGroup);

      Rule rule = new Rule(null, input, null, subst);
      result.add(rule);
      i++;
    }
    return result;
  }

Replace Generic With Diamond LinkedHashSet<Rule> with LinkedHashSet<> in method private extract(table AlternateSubst) : Set<Rule> from class com.google.typography.font.sfntly.table.opentype.component.RuleExtractor


  private static Map<Integer, GlyphGroup> extract(InnerArrayFmt1 table) {
    Map<Integer, GlyphGroup> result = new HashMap<>();
    int glyphId = table.getField(InnerArrayFmt1.START_GLYPH_INDEX);
    for (NumRecord record : table) {
      int classId = record.value;
      if (!result.containsKey(classId)) {
        result.put(classId, new GlyphGroup());
      }

      result.get(classId).add(glyphId);
      glyphId++;
    }
    return result;
  }

  private static Map<Integer, GlyphGroup> extract(InnerArrayFmt1 table) {
    Map<Integer, GlyphGroup> result = new HashMap<Integer, GlyphGroup>();
    int glyphId = table.getField(InnerArrayFmt1.START_GLYPH_INDEX);
    for (NumRecord record : table) {
      int classId = record.value;
      if (!result.containsKey(classId)) {
        result.put(classId, new GlyphGroup());
      }

      result.get(classId).add(glyphId);
      glyphId++;
    }
    return result;
  }

Replace Generic With Diamond HashMap<Integer,GlyphGroup> with HashMap<> in method private extract(table InnerArrayFmt1) : Map<Integer,GlyphGroup> from class com.google.typography.font.sfntly.table.opentype.component.RuleExtractor


    private void initFromData(ReadableFontData data, int base) {
      builders = new TreeMap<>();
      if (data == null) {
        return;
      }

      data = data.slice(base);
      // Start of the first subtable in the data, if we're canonical.
      TagOffsetRecordList recordList = new TagOffsetRecordList(data);
      if (recordList.count() == 0) {
        return;
      }

      int subTableLimit = recordList.limit();
      Iterator<TagOffsetRecord> recordIterator = recordList.iterator();
      if (dataIsCanonical) {
        do {
          // Each table starts where the previous one ended.
          int offset = subTableLimit;
          TagOffsetRecord record = recordIterator.next();
          int tag = record.tag;
          // Each table ends at the next start, or at the end of the data.
          subTableLimit = record.offset;
          // TODO(cibu): length computation does not seems to be correct.
          int length = subTableLimit - offset;
          VisibleSubTable.Builder<S> builder = createSubTableBuilder(data, offset, length, tag);
          builders.put(tag, builder);
        } while (recordIterator.hasNext());
      } else {
        do {
          TagOffsetRecord record = recordIterator.next();
          int offset = record.offset;
          int tag = record.tag;
          VisibleSubTable.Builder<S> builder = createSubTableBuilder(data, offset, -1, tag);
          builders.put(tag, builder);
        } while (recordIterator.hasNext());
      }
    }

    private void initFromData(ReadableFontData data, int base) {
      builders = new TreeMap<Integer, VisibleSubTable.Builder<S>>();
      if (data == null) {
        return;
      }

      data = data.slice(base);
      // Start of the first subtable in the data, if we're canonical.
      TagOffsetRecordList recordList = new TagOffsetRecordList(data);
      if (recordList.count() == 0) {
        return;
      }

      int subTableLimit = recordList.limit();
      Iterator<TagOffsetRecord> recordIterator = recordList.iterator();
      if (dataIsCanonical) {
        do {
          // Each table starts where the previous one ended.
          int offset = subTableLimit;
          TagOffsetRecord record = recordIterator.next();
          int tag = record.tag;
          // Each table ends at the next start, or at the end of the data.
          subTableLimit = record.offset;
          // TODO(cibu): length computation does not seems to be correct.
          int length = subTableLimit - offset;
          VisibleSubTable.Builder<S> builder = createSubTableBuilder(data, offset, length, tag);
          builders.put(tag, builder);
        } while (recordIterator.hasNext());
      } else {
        do {
          TagOffsetRecord record = recordIterator.next();
          int offset = record.offset;
          int tag = record.tag;
          VisibleSubTable.Builder<S> builder = createSubTableBuilder(data, offset, -1, tag);
          builders.put(tag, builder);
        } while (recordIterator.hasNext());
      }
    }

Replace Generic With Diamond TreeMap<Integer,VisibleSubTable.Builder<S>> with TreeMap<> in method private initFromData(data ReadableFontData, base int) : void from class com.google.typography.font.sfntly.table.opentype.component.TagOffsetsTable.Builder


  private void addLangScriptMap(String lang, ScriptTag scriptTag) {
    if (!scriptLangMap.containsKey(scriptTag)) {
      scriptLangMap.put(scriptTag, new HashSet<>());
    }
    Set<String> langs = scriptLangMap.get(scriptTag);
    langs.add(lang);
  }

  private void addLangScriptMap(String lang, ScriptTag scriptTag) {
    if (!scriptLangMap.containsKey(scriptTag)) {
      scriptLangMap.put(scriptTag, new HashSet<String>());
    }
    Set<String> langs = scriptLangMap.get(scriptTag);
    langs.add(lang);
  }

Replace Generic With Diamond HashSet<String> with HashSet<> in method private addLangScriptMap(lang String, scriptTag ScriptTag) : void from class com.google.typography.font.sfntly.table.opentype.testing.FontLanguages


  Set<String> get(Font font) {
    Set<String> langs = new HashSet<>();
    GSubTable gsub = font.getTable(Tag.GSUB);
    if (gsub == null) {
      return langs;
    }

    ScriptListTable scriptList = gsub.scriptList();
    for (int i = 0; i < scriptList.count(); i++) {
      ScriptTag script = scriptList.scriptAt(i);
      if (scriptLangMap.containsKey(script)) {
        langs.addAll(scriptLangMap.get(script));
      } else {
        System.err.println("No language exists for the script: " + script);
      }
    }
    return langs;
  }

  Set<String> get(Font font) {
    Set<String> langs = new HashSet<String>();
    GSubTable gsub = font.getTable(Tag.GSUB);
    if (gsub == null) {
      return langs;
    }

    ScriptListTable scriptList = gsub.scriptList();
    for (int i = 0; i < scriptList.count(); i++) {
      ScriptTag script = scriptList.scriptAt(i);
      if (scriptLangMap.containsKey(script)) {
        langs.addAll(scriptLangMap.get(script));
      } else {
        System.err.println("No language exists for the script: " + script);
      }
    }
    return langs;
  }

Replace Generic With Diamond HashSet<String> with HashSet<> in method package get(font Font) : Set<String> from class com.google.typography.font.sfntly.table.opentype.testing.FontLanguages