    public ArrayList createRoster(int rosterSize) {

        ArrayList<Worker> roster = new ArrayList<>();

        for (int i = 0; i < rosterSize; i++) {
            roster.add(randomWorker());

        }

        return roster;
    }

    public ArrayList createRoster(int rosterSize) {

        ArrayList<Worker> roster = new ArrayList<Worker>();

        for (int i = 0; i < rosterSize; i++) {
            roster.add(randomWorker());

        }

        return roster;
    }

Replace Generic With Diamond ArrayList<Worker> with ArrayList<> in method public createRoster(rosterSize int) : ArrayList from class wrestling.model.WorkerFactory


    public ArrayList createRoster(int rosterSize, int rosterLevel) {

        ArrayList<Worker> roster = new ArrayList<>();

        for (int i = 0; i < rosterSize; i++) {
            roster.add(randomWorker(rosterLevel));

        }

        return roster;
    }

    public ArrayList createRoster(int rosterSize, int rosterLevel) {

        ArrayList<Worker> roster = new ArrayList<Worker>();

        for (int i = 0; i < rosterSize; i++) {
            roster.add(randomWorker(rosterLevel));

        }

        return roster;
    }

Replace Generic With Diamond ArrayList<Worker> with ArrayList<> in method public createRoster(rosterSize int, rosterLevel int) : ArrayList from class wrestling.model.WorkerFactory


            @Override
            public void changed(ObservableValue<? extends Promotion> observable, Promotion oldValue, Promotion newValue) {

                currentPromotionLabel.setText(newValue.toString());

                ListView<Worker> rosterListView = new ListView<>();
                ObservableList<Worker> rosterList = FXCollections.observableArrayList();
                for (Worker current : newValue.getRoster()) {
                    rosterList.add(current);
                }
                rosterListView.setItems(rosterList);

                gridPane.add(rosterListView, 3, 1);

                selectedPromotion = newValue;
            }

            @Override
            public void changed(ObservableValue<? extends Promotion> observable, Promotion oldValue, Promotion newValue) {

                currentPromotionLabel.setText(newValue.toString());

                ListView<Worker> rosterListView = new ListView<Worker>();
                ObservableList<Worker> rosterList = FXCollections.observableArrayList();
                for (Worker current : newValue.getRoster()) {
                    rosterList.add(current);
                }
                rosterListView.setItems(rosterList);

                gridPane.add(rosterListView, 3, 1);

                selectedPromotion = newValue;
            }

Replace Generic With Diamond ListView<Worker> with ListView<> in method public changed(observable ObservableValue<? extends Promotion>, oldValue Promotion, newValue Promotion) : void from class wrestling.view.StartGameScreenController.initializeMore.addListener.new ChangeListener<Promotion>


    public void initializeMore() {
        promotionListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Promotion>() {

            @Override
            public void changed(ObservableValue<? extends Promotion> observable, Promotion oldValue, Promotion newValue) {

                currentPromotionLabel.setText(newValue.toString());

                ListView<Worker> rosterListView = new ListView<>();
                ObservableList<Worker> rosterList = FXCollections.observableArrayList();
                for (Worker current : newValue.getRoster()) {
                    rosterList.add(current);
                }
                rosterListView.setItems(rosterList);

                gridPane.add(rosterListView, 3, 1);

                selectedPromotion = newValue;
            }
        });
    }

    public void initializeMore() {
        promotionListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Promotion>() {

            @Override
            public void changed(ObservableValue<? extends Promotion> observable, Promotion oldValue, Promotion newValue) {

                currentPromotionLabel.setText(newValue.toString());

                ListView<Worker> rosterListView = new ListView<Worker>();
                ObservableList<Worker> rosterList = FXCollections.observableArrayList();
                for (Worker current : newValue.getRoster()) {
                    rosterList.add(current);
                }
                rosterListView.setItems(rosterList);

                gridPane.add(rosterListView, 3, 1);

                selectedPromotion = newValue;
            }
        });
    }

Replace Generic With Diamond ListView<Worker> with ListView<> in method public initializeMore() : void from class wrestling.view.StartGameScreenController


    /**
     * sort.
     * Сортирует  по возрасту.
     * @param users - пользователи.
     * @return отсортированный список.
     * */
    public Set<User> sort(List<User> users) {
        Set<User> result = new TreeSet<>(User::compareTo);
        result.addAll(users);
        return result;
    }

    /**
     * sort.
     * Сортирует  по возрасту.
     * @param users - пользователи.
     * @return отсортированный список.
     * */
    public Set<User> sort(List<User> users) {
        Set<User> result = new TreeSet<>(new Comparator<User>() {
            @Override
            public int compare(User o1, User o2) {
                return o1.compareTo(o2);
            }
        });
        result.addAll(users);
        return result;
    }

Replace Anonymous With Lambda ru.job4j.sort.SortUser.sort.result.new TreeSet<>.new Comparator<User> with User::compareTo in method public sort(users List<User>) : Set<User> from class ru.job4j.sort.SortUser


    /**
     * sortNameLenght.
     * Сортирует сначало по имени.
     * @param users - пользователи.
     * @return отсортированный список.
     * */
    public List<User> sortNameLength(List<User> users) {
        users.sort(Comparator.comparing(User::getName));
        return users;
    }

    /**
     * sortNameLenght.
     * Сортирует сначало по имени.
     * @param users - пользователи.
     * @return отсортированный список.
     * */
    public List<User> sortNameLength(List<User> users) {
        users.sort(new Comparator<User>() {
            @Override
            public int compare(User o1, User o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        return users;
    }

Replace Anonymous With Lambda ru.job4j.sort.SortUser.sortNameLength.sort.new Comparator<User> with User::getName in method public sortNameLength(users List<User>) : List<User> from class ru.job4j.sort.SortUser


    /**
     * sortByAllFields.
     * Сортирует сначало по имени , потом по возрасту.
     * @param users - пользователи.
     * @return отсортированный список.
     * */
    public List<User> sortByAllFields(List<User> users) {
        users.sort(Comparator.comparing(User::getName).thenComparingInt(User::getAge));
        return users;
    }

    /**
     * sortByAllFields.
     * Сортирует сначало по имени , потом по возрасту.
     * @param users - пользователи.
     * @return отсортированный список.
     * */
    public List<User> sortByAllFields(List<User> users) {
        users.sort(new Comparator<User>() {
            @Override
            public int compare(User o1, User o2) {
                final int result = o1.getName().compareTo(o2.getName());
                return result != 0 ? result : Integer.compare(o1.getAge(), o2.getAge());
            }
        });
        return users;
    }

Replace Anonymous With Lambda ru.job4j.sort.SortUser.sortByAllFields.sort.new Comparator<User> with User::getAge in method public sortByAllFields(users List<User>) : List<User> from class ru.job4j.sort.SortUser


    /**
     * Contains all options for startup
     */
    private void initializeAPI(String fileName, JavaPlugin plugin) {
        this.plugin = plugin;           // Keep track of an instance of this plugin
        this.fileName = fileName;       // Store the filename of this config file

        contents = new HashMap<>();       // Create a Map that will contain all paths and values

        if (settings.getAutoLoadValues())             // Check if auto loading is enabled
        {
            reloadContents();                           // Load contents into memory
        }

        copyDefConfigIfNeeded();    // Checks if a live config is available, if not: a new default config file is generated
    }

    /**
     * Contains all options for startup
     */
    private void initializeAPI(String fileName, JavaPlugin plugin) {
        this.plugin = plugin;           // Keep track of an instance of this plugin
        this.fileName = fileName;       // Store the filename of this config file

        contents = new HashMap<String, Object>();       // Create a Map that will contain all paths and values

        if (settings.getAutoLoadValues())             // Check if auto loading is enabled
        {
            reloadContents();                           // Load contents into memory
        }

        copyDefConfigIfNeeded();    // Checks if a live config is available, if not: a new default config file is generated
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method private initializeAPI(fileName String, plugin JavaPlugin) : void from class io.github.jochyoua.mychristianswearfilter.dependencies.configapi.ConfigAPI


    /**
     * Load all values from both provided configurations into memory
     * The previous contents will be removed from memory
     *
     * @param liveConfig    should be a YamlConfiguration of the config on the server
     * @param defaultConfig should be a YamlConfiguration of the default config values. If null, no default values will be loaded. If not null, there will be no missing options
     */
    private void loadFromConfigurations(YamlConfiguration liveConfig, YamlConfiguration defaultConfig) {
        // If the default config should not be considered (for missing options): only load from the live values

        if (defaultConfig == null) {
            loadFromConfigurations(liveConfig);
            return;
        }

        // Empty the contents

        contents = new HashMap<>();

        // Load the new contents

        for (String path : defaultConfig.getKeys(true)) {
            if (!defaultConfig.isConfigurationSection(path)) {
                if (liveConfig.contains(path)) {
                    contents.put(path, liveConfig.get(path));
                } else {
                    contents.put(path, defaultConfig.get(path));
                }
            }
        }
    }

    /**
     * Load all values from both provided configurations into memory
     * The previous contents will be removed from memory
     *
     * @param liveConfig    should be a YamlConfiguration of the config on the server
     * @param defaultConfig should be a YamlConfiguration of the default config values. If null, no default values will be loaded. If not null, there will be no missing options
     */
    private void loadFromConfigurations(YamlConfiguration liveConfig, YamlConfiguration defaultConfig) {
        // If the default config should not be considered (for missing options): only load from the live values

        if (defaultConfig == null) {
            loadFromConfigurations(liveConfig);
            return;
        }

        // Empty the contents

        contents = new HashMap<String, Object>();

        // Load the new contents

        for (String path : defaultConfig.getKeys(true)) {
            if (!defaultConfig.isConfigurationSection(path)) {
                if (liveConfig.contains(path)) {
                    contents.put(path, liveConfig.get(path));
                } else {
                    contents.put(path, defaultConfig.get(path));
                }
            }
        }
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method private loadFromConfigurations(liveConfig YamlConfiguration, defaultConfig YamlConfiguration) : void from class io.github.jochyoua.mychristianswearfilter.dependencies.configapi.ConfigAPI


    /**
     * Load all values from the provided configuration into memory
     * Earlier loaded values will be deleted
     *
     * @param liveConfig should be a YamlConfiguration of the config on the server
     */
    private void loadFromConfigurations(YamlConfiguration liveConfig) {

        // Reset contents
        contents = new HashMap<>();

        // Load new contents
        for (String path : liveConfig.getKeys(true)) {
            if (!liveConfig.isConfigurationSection(path)) {
                contents.put(path, liveConfig.get(path));
            }
        }
    }

    /**
     * Load all values from the provided configuration into memory
     * Earlier loaded values will be deleted
     *
     * @param liveConfig should be a YamlConfiguration of the config on the server
     */
    private void loadFromConfigurations(YamlConfiguration liveConfig) {

        // Reset contents
        contents = new HashMap<String, Object>();

        // Load new contents
        for (String path : liveConfig.getKeys(true)) {
            if (!liveConfig.isConfigurationSection(path)) {
                contents.put(path, liveConfig.get(path));
            }
        }
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method private loadFromConfigurations(liveConfig YamlConfiguration) : void from class io.github.jochyoua.mychristianswearfilter.dependencies.configapi.ConfigAPI


    /**
     * Get all options that are present in defaultConfig but NOT in liveConfig
     * By swapping defaultConfig and liveConfig, you can get all redundant options!
     * Both arguments are Nullable! If no value is given, they will be replaced by the contents of each respective file
     * -> liveConfig would be replaced by the contents of the config on the server
     * -> defaultConfig would be replaced by the contents of the default config file
     *
     * @param liveConfig    the YamlConfiguration with possible missing options
     * @param defaultConfig the YamlConfiguration which is assumed to be complete
     * @return a Map<String, Object> containing all missing options and
     */
    public Map<String, Object> getMissingOptions(YamlConfiguration liveConfig, YamlConfiguration defaultConfig) {
        Map<String, Object> missingOptions = new HashMap<>();

        // Get the current config on the server if none was provided

        if (liveConfig == null)
            liveConfig = getLiveConfiguration();

        // Get the current default config if none was provided

        if (defaultConfig == null)
            defaultConfig = getDefaultConfiguration();

        // Get the missing configuration options that are not configuration sections

        for (String path : defaultConfig.getKeys(true)) {
            if (!defaultConfig.isConfigurationSection(path)) {
                if (!liveConfig.contains(path)) {
                    missingOptions.put(path, defaultConfig.get(path));
                }
            }
        }

        return missingOptions;
    }

    /**
     * Get all options that are present in defaultConfig but NOT in liveConfig
     * By swapping defaultConfig and liveConfig, you can get all redundant options!
     * Both arguments are Nullable! If no value is given, they will be replaced by the contents of each respective file
     * -> liveConfig would be replaced by the contents of the config on the server
     * -> defaultConfig would be replaced by the contents of the default config file
     *
     * @param liveConfig    the YamlConfiguration with possible missing options
     * @param defaultConfig the YamlConfiguration which is assumed to be complete
     * @return a Map<String, Object> containing all missing options and
     */
    public Map<String, Object> getMissingOptions(YamlConfiguration liveConfig, YamlConfiguration defaultConfig) {
        Map<String, Object> missingOptions = new HashMap<String, Object>();

        // Get the current config on the server if none was provided

        if (liveConfig == null)
            liveConfig = getLiveConfiguration();

        // Get the current default config if none was provided

        if (defaultConfig == null)
            defaultConfig = getDefaultConfiguration();

        // Get the missing configuration options that are not configuration sections

        for (String path : defaultConfig.getKeys(true)) {
            if (!defaultConfig.isConfigurationSection(path)) {
                if (!liveConfig.contains(path)) {
                    missingOptions.put(path, defaultConfig.get(path));
                }
            }
        }

        return missingOptions;
    }

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public getMissingOptions(liveConfig YamlConfiguration, defaultConfig YamlConfiguration) : Map<String,Object> from class io.github.jochyoua.mychristianswearfilter.dependencies.configapi.ConfigAPI


    /**
     * This constructor will initialize the default values
     * |------------------------|-------|-----
     * | Setting name           | Value | Description
     * | ---------------------- | ------| -----
     * | doDebugLogging         | false | Allows debugging messages to be sent to troubleshoot a config file and the API usage. This is meant as a developer tool and logs a message when an issue occurs
     * | reportMissingOptions   | true  | On each config file reload, report missing options to the console (useful for server owners)
     * | reportRedundantOptions | false | On each config file reload, Report options which are in the live config but not in the default config
     * | reportNewConfig        | true  | On each config file reload, report the action of copying a new config file
     * | useColors              | true  | Choose whether console output should be coloured
     * | autoLoadValues         | true  | Choose to load all config contents upon creating an instance. Setting this to false will be slightly more performant if other settings need to be set first.
     * | loadDefaults           | true  | Load default values (from the default config) where live config values are missing
     * |------------------------| ------| -----
     */
    public Settings() {

        settings = new HashMap<>();

        // Logging settings
        settings.put("dodebuglogging", false);          // Allows debugging messages to be sent to troubleshoot a config file and the API usage. This is meant as a developer tool and logs a message when an issue occurs
        settings.put("reportmissingoptions", true);     // On each config file reload, report missing options to the console (useful for server owners)
        settings.put("reportredundantoptions", false);  // On each config file reload, Report options which are in the live config but not in the default config
        settings.put("reportnewconfig", true);          // On each config file reload, report the action of copying a new config file
        settings.put("usecolors", true);                // Choose whether console output should be coloured

        // Internal working settings
        settings.put("autoloadvalues", true);  // Choose to load all config contents upon creating an instance. Setting this to false will be slightly more performant if other settings need to be set first.
        settings.put("loaddefaults", true);    // Load default values (from the default config) where live config values are missing
    }

    /**
     * This constructor will initialize the default values
     * |------------------------|-------|-----
     * | Setting name           | Value | Description
     * | ---------------------- | ------| -----
     * | doDebugLogging         | false | Allows debugging messages to be sent to troubleshoot a config file and the API usage. This is meant as a developer tool and logs a message when an issue occurs
     * | reportMissingOptions   | true  | On each config file reload, report missing options to the console (useful for server owners)
     * | reportRedundantOptions | false | On each config file reload, Report options which are in the live config but not in the default config
     * | reportNewConfig        | true  | On each config file reload, report the action of copying a new config file
     * | useColors              | true  | Choose whether console output should be coloured
     * | autoLoadValues         | true  | Choose to load all config contents upon creating an instance. Setting this to false will be slightly more performant if other settings need to be set first.
     * | loadDefaults           | true  | Load default values (from the default config) where live config values are missing
     * |------------------------| ------| -----
     */
    public Settings() {

        settings = new HashMap<String, Boolean>();

        // Logging settings
        settings.put("dodebuglogging", false);          // Allows debugging messages to be sent to troubleshoot a config file and the API usage. This is meant as a developer tool and logs a message when an issue occurs
        settings.put("reportmissingoptions", true);     // On each config file reload, report missing options to the console (useful for server owners)
        settings.put("reportredundantoptions", false);  // On each config file reload, Report options which are in the live config but not in the default config
        settings.put("reportnewconfig", true);          // On each config file reload, report the action of copying a new config file
        settings.put("usecolors", true);                // Choose whether console output should be coloured

        // Internal working settings
        settings.put("autoloadvalues", true);  // Choose to load all config contents upon creating an instance. Setting this to false will be slightly more performant if other settings need to be set first.
        settings.put("loaddefaults", true);    // Load default values (from the default config) where live config values are missing
    }

Replace Generic With Diamond HashMap<String,Boolean> with HashMap<> in method public Settings() from class io.github.jochyoua.mychristianswearfilter.dependencies.configapi.Settings


    /**
     * Count rows in a mysql database
     *
     * @param table the table
     * @return the size of the rows
     */
    public int countRows(String table) {
        int i = 0;
        if (plugin.getHikariCP().isEnabled()) {
            try (PreparedStatement ps = connection.prepareStatement("SELECT * FROM " + table);
                 ResultSet rs = ps.executeQuery()) {
                while (rs.next())
                    i++;
                ps.close();
                rs.close();
            } catch (Exception ignored) {
            }
        }
        return i;
    }

    /**
     * Count rows in a mysql database
     *
     * @param table the table
     * @return the size of the rows
     */
    public int countRows(String table) {
        if (!plugin.getHikariCP().isEnabled())
            return 0;
        int i = 0;
        try {
            PreparedStatement ps = connection.prepareStatement("SELECT * FROM " + table);
            ResultSet rs = ps.executeQuery();
            while (rs.next())
                i++;
            ps.close();
        } catch (Exception ignored) {
        }
        return i;
    }

Try With Resources try(PreparedStatement ps=connection.prepareStatement("SELECT * FROM " + table); ResultSet rs=ps.executeQuery()) in method public countRows(table String) : int from class io.github.jochyoua.mychristianswearfilter.shared.Manager


    public static Network fromJSON(final JsonObject json) {
        final Network network = new Network(json.get("input").getAsInt(), json.get("output").getAsInt());
        network.dropout = json.get("dropout").getAsDouble();
        network.nodes = new ArrayList<>();
        network.connections = new ArrayList<>();

        final JsonArray nodes = json.get("nodes").getAsJsonArray();
        final JsonArray connections = json.get("connections").getAsJsonArray();
        nodes.forEach(jsonNode -> network.nodes.add(Node.fromJSON(jsonNode.getAsJsonObject())));
        for (int i = 0; i < connections.size(); i++) {
            final JsonObject connJSON = connections.get(i).getAsJsonObject();
            final List<Connection> connection = network.connect(network.nodes.get(connJSON.get("from").getAsInt()), network.nodes.get(connJSON.get("to").getAsInt()));
            connection.get(0).weight = connJSON.get("weight").getAsDouble();

            if (connJSON.has("gater") && connJSON.get("gater").getAsInt() != -1) {
                network.gate(network.nodes.get(connJSON.get("gater").getAsInt()), connection.get(0));
            }
        }
        return network;
    }

    public static Network fromJSON(final JsonObject json) {
        final Network network = new Network(json.get("input").getAsInt(), json.get("output").getAsInt());
        network.dropout = json.get("dropout").getAsDouble();
        network.nodes = new ArrayList<>();
        network.connections = new ArrayList<>();

        final JsonArray nodes = json.get("nodes").getAsJsonArray();
        final JsonArray connections = json.get("connections").getAsJsonArray();
        for (int i = 0; i < nodes.size(); i++) {
            network.nodes.add(Node.fromJSON(nodes.get(i).getAsJsonObject()));
        }
        for (int i = 0; i < connections.size(); i++) {
            final JsonObject connJSON = connections.get(i).getAsJsonObject();
            final List<Connection> connection = network.connect(network.nodes.get(connJSON.get("from").getAsInt()), network.nodes.get(connJSON.get("to").getAsInt()));
            connection.get(0).weight = connJSON.get("weight").getAsDouble();

            if (connJSON.has("gater") && connJSON.get("gater").getAsInt() != -1) {
                network.gate(network.nodes.get(connJSON.get("gater").getAsInt()), connection.get(0));
            }
        }
        return network;
    }

Replace Loop With Pipeline for(int i=0; i < nodes.size(); i++) with nodes.forEach(jsonNode -> network.nodes.add(Node.fromJSON(jsonNode.getAsJsonObject()))); in method public fromJSON(json JsonObject) : Network from class architecture.Network


  @PostMapping
  public ResponseEntity<ExitStatus> startBatchProcessing(@RequestBody String jobName) throws JobInstanceAlreadyCompleteException, JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException
  {
    Job job = applicationContext.getBean(jobName, Job.class);
    return new ResponseEntity<>(jobLauncher.run(job, new JobParameters()).getExitStatus(), HttpStatus.OK);
  }

  @PostMapping
  public ResponseEntity<ExitStatus> startBatchProcessing(@RequestBody String jobName) throws JobInstanceAlreadyCompleteException, JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException
  {
    Job job = applicationContext.getBean(jobName, Job.class);
    return new ResponseEntity<ExitStatus>(jobLauncher.run(job, new JobParameters()).getExitStatus(), HttpStatus.OK);
  }

Replace Generic With Diamond ResponseEntity<ExitStatus> with ResponseEntity<> in method public startBatchProcessing(jobName String) : ResponseEntity<ExitStatus> from class fr.dsirc.demo.batch.controllers.StartJobController


    @Test
    public void should_use_text_parameter_for_xpath_rule() {
        PmdRulesDefinition definition = new PmdRulesDefinition();
        RulesDefinition.Context context = new RulesDefinition.Context();
        definition.define(context);
        RulesDefinition.Repository repository = context.repository(PmdConstants.REPOSITORY_KEY);

        Rule xpathRule = Iterables.find(repository.rules(), rule -> rule.key().equals("XPathRule"));

        assertThat(xpathRule.param("xpath").type().type()).isEqualTo(PropertyType.TEXT.name());
    }

    @Test
    public void should_use_text_parameter_for_xpath_rule() {
        PmdRulesDefinition definition = new PmdRulesDefinition();
        RulesDefinition.Context context = new RulesDefinition.Context();
        definition.define(context);
        RulesDefinition.Repository repository = context.repository(PmdConstants.REPOSITORY_KEY);

        Rule xpathRule = Iterables.find(repository.rules(), new Predicate<Rule>() {
            @Override
            public boolean apply(Rule rule) {
                return rule.key().equals("XPathRule");
            }
        });

        assertThat(xpathRule.param("xpath").type().type()).isEqualTo(PropertyType.TEXT.name());
    }

Replace Anonymous With Lambda org.sonar.plugins.pmd.PmdRulesDefinitionTest.should_use_text_parameter_for_xpath_rule.xpathRule.find.new Predicate<Rule> with rule -> rule.key().equals("XPathRule") in method public should_use_text_parameter_for_xpath_rule() : void from class org.sonar.plugins.pmd.PmdRulesDefinitionTest


    private static RuleFinder createRuleFinder(final List<RulesDefinition.Rule> rules) {
        RuleFinder ruleFinder = mock(RuleFinder.class);
        final List<Rule> convertedRules = convert(rules);

        when(ruleFinder.find(any(RuleQuery.class))).then((Answer<Rule>) invocation -> {
            RuleQuery query = (RuleQuery) invocation.getArguments()[0];
            for (Rule rule : convertedRules) {
                if (query.getConfigKey().equals(rule.getConfigKey())) {
                    return rule;
                }
            }
            return null;
        });
        return ruleFinder;
    }

    static RuleFinder createRuleFinder(final List<RulesDefinition.Rule> rules) {
        RuleFinder ruleFinder = mock(RuleFinder.class);
        final List<Rule> convertedRules = convert(rules);

        when(ruleFinder.find(any(RuleQuery.class))).then(new Answer<Rule>() {
            @Override
            public Rule answer(InvocationOnMock invocation) {
                RuleQuery query = (RuleQuery) invocation.getArguments()[0];
                for (Rule rule : convertedRules) {
                    if (query.getConfigKey().equals(rule.getConfigKey())) {
                        return rule;
                    }
                }
                return null;
            }
        });
        return ruleFinder;
    }

Replace Anonymous With Lambda org.sonar.plugins.pmd.profile.PmdProfileExporterTest.createRuleFinder.then.new Answer<Rule> with invocation -> {RuleQuery query=(RuleQuery)invocation.getArguments()[0]; in method private createRuleFinder(rules List<RulesDefinition.Rule>) : RuleFinder from class org.sonar.plugins.pmd.profile.PmdProfileExporterTest


    @Test
    public void should_process_input_file() throws Exception {
        doAnswer((Answer<Void>) invocation -> {
            final InputStream inputStreamArg = (InputStream) invocation.getArguments()[0];
            final List<String> inputStreamLines =
                    new BufferedReader(new InputStreamReader(inputStreamArg))
                            .lines()
                            .collect(Collectors.toList());
            assertThat(inputStreamLines).containsExactly("Example source");
            return null;
        }).when(processor).processSourceCode(any(InputStream.class), eq(rulesets), eq(ruleContext));

        new PmdTemplate(configuration, processor).process(inputFile, rulesets, ruleContext);

        verify(ruleContext).setSourceCodeFilename(inputFile.uri().toString());
        verify(processor).processSourceCode(any(InputStream.class), eq(rulesets), eq(ruleContext));
    }

    @Test
    public void should_process_input_file() throws Exception {
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                InputStream inputStreamArg = (InputStream) invocation.getArguments()[0];
                List<String> inputStreamLines = CharStreams.readLines(new InputStreamReader(inputStreamArg));
                assertThat(inputStreamLines).containsExactly("Example source");
                return null;
            }
        }).when(processor).processSourceCode(any(InputStream.class), eq(rulesets), eq(ruleContext));

        new PmdTemplate(configuration, processor).process(inputFile, rulesets, ruleContext);

        verify(ruleContext).setSourceCodeFilename(inputFile.getAbsolutePath());
        verify(processor).processSourceCode(any(InputStream.class), eq(rulesets), eq(ruleContext));
    }

Replace Anonymous With Lambda org.sonar.plugins.pmd.PmdTemplateTest.should_process_input_file.processSourceCode.when.doAnswer.new Answer<Void> with invocation -> {final InputStream inputStreamArg=(InputStream)invocation.getArguments()[0]; in method public should_process_input_file() : void from class org.sonar.plugins.pmd.PmdTemplateTest


    public void process(File file, RuleSets rulesets, RuleContext ruleContext) {
        ruleContext.setSourceCodeFilename(file.getAbsolutePath());

        try (InputStream inputStream = new FileInputStream(file)) {
            processor.processSourceCode(inputStream, rulesets, ruleContext);
        } catch (Throwable e) {
            LOG.error("Fail to execute PMD. Following file is ignored: " + file, e);
        }
    }

    public void process(File file, RuleSets rulesets, RuleContext ruleContext) {
        ruleContext.setSourceCodeFilename(file.getAbsolutePath());
        InputStream inputStream = null;
        try {
            inputStream = new FileInputStream(file);
            processor.processSourceCode(inputStream, rulesets, ruleContext);
        } catch (Throwable e) {
            LOG.error("Fail to execute PMD. Following file is ignored: " + file, e);
        } finally {
            Closeables.closeQuietly(inputStream);
        }
    }

Try With Resources try(InputStream inputStream=new FileInputStream(file)) in method public process(file File, rulesets RuleSets, ruleContext RuleContext) : void from class org.sonar.plugins.pmd.PmdTemplate


    public Report execute() {
        final Profiler profiler = Profiler.create(LOGGER).startInfo("Execute PMD " + PmdVersion.getVersion());
        final ClassLoader initialClassLoader = Thread.currentThread().getContextClassLoader();
        Report result = null;

        try (URLClassLoader classLoader = createClassloader()) {
            Thread.currentThread().setContextClassLoader(getClass().getClassLoader());

            result = executePmd(classLoader);
        } catch (IOException e) {
            LOGGER.error("Failed to close URLClassLoader.", e);
        } finally {
            Thread.currentThread().setContextClassLoader(initialClassLoader);
            profiler.stopInfo();
        }

        return result;
    }

    public Report execute() {
        Profiler profiler = Profiler.create(LOGGER).startInfo("Execute PMD " + PmdVersion.getVersion());

        ClassLoader initialClassLoader = Thread.currentThread().getContextClassLoader();
        URLClassLoader classLoader = createClassloader();
        try {
            Thread.currentThread().setContextClassLoader(getClass().getClassLoader());

            return executePmd(classLoader);
        } finally {
            Closeables.closeQuietly(classLoader);
            Thread.currentThread().setContextClassLoader(initialClassLoader);
            profiler.stopInfo();
        }
    }

Try With Resources try(URLClassLoader classLoader=createClassloader()) in method public execute() : Report from class org.sonar.plugins.pmd.PmdExecutor


    static RuleFinder createRuleFinder() {
        RuleFinder ruleFinder = mock(RuleFinder.class);
        when(ruleFinder.find(any(RuleQuery.class))).then((Answer<Rule>) invocation -> {
            RuleQuery query = (RuleQuery) invocation.getArguments()[0];
            String configKey = query.getConfigKey();
            String key = configKey.substring(configKey.lastIndexOf('/') + 1, configKey.length());
            Rule rule = Rule.create(query.getRepositoryKey(), key, "").setConfigKey(configKey).setSeverity(RulePriority.BLOCKER);
            if (rule.getConfigKey().equals("rulesets/java/coupling.xml/ExcessiveImports")) {
                rule.createParameter("minimum");
            }
            return rule;
        });
        return ruleFinder;
    }

    static RuleFinder createRuleFinder() {
        RuleFinder ruleFinder = mock(RuleFinder.class);
        when(ruleFinder.find(any(RuleQuery.class))).then(new Answer<Rule>() {
            @Override
            public Rule answer(InvocationOnMock invocation) {
                RuleQuery query = (RuleQuery) invocation.getArguments()[0];
                String configKey = query.getConfigKey();
                String key = configKey.substring(configKey.lastIndexOf('/') + 1, configKey.length());
                Rule rule = Rule.create(query.getRepositoryKey(), key, "").setConfigKey(configKey).setSeverity(RulePriority.BLOCKER);
                if (rule.getConfigKey().equals("rulesets/java/coupling.xml/ExcessiveImports")) {
                    rule.createParameter("minimum");
                }
                return rule;
            }
        });
        return ruleFinder;
    }

Replace Anonymous With Lambda org.sonar.plugins.pmd.PmdProfileImporterTest.createRuleFinder.then.new Answer<Rule> with invocation -> {RuleQuery query=(RuleQuery)invocation.getArguments()[0]; in method package createRuleFinder() : RuleFinder from class org.sonar.plugins.pmd.profile.PmdProfileImporterTest


  private PmdRuleset createPmdRuleset(String repositoryKey, List<ActiveRule> activeRules, String profileName) {
    PmdRuleset ruleset = new PmdRuleset(profileName);
    for (ActiveRule activeRule : activeRules) {
      if (activeRule.getRule().getRepositoryKey().equals(repositoryKey)) {
        String configKey = activeRule.getRule().getConfigKey();
        PmdRule rule = new PmdRule(configKey, PmdLevelUtils.toLevel(activeRule.getSeverity()));
        if ((activeRule.getActiveRuleParams() != null) && !activeRule.getActiveRuleParams().isEmpty()) {
          List<PmdProperty> properties = new ArrayList<>();
          for (ActiveRuleParam activeRuleParam : activeRule.getActiveRuleParams()) {
            properties.add(new PmdProperty(activeRuleParam.getRuleParam().getKey(), activeRuleParam.getValue()));
          }
          rule.setProperties(properties);
        }
        ruleset.addRule(rule);
        processXPathRule(activeRule.getRuleKey(), rule);
      }
    }
    return ruleset;
  }

  private PmdRuleset createPmdRuleset(String repositoryKey, List<ActiveRule> activeRules, String profileName) {
    PmdRuleset ruleset = new PmdRuleset(profileName);
    for (ActiveRule activeRule : activeRules) {
      if (activeRule.getRule().getRepositoryKey().equals(repositoryKey)) {
        String configKey = activeRule.getRule().getConfigKey();
        PmdRule rule = new PmdRule(configKey, PmdLevelUtils.toLevel(activeRule.getSeverity()));
        if ((activeRule.getActiveRuleParams() != null) && !activeRule.getActiveRuleParams().isEmpty()) {
          List<PmdProperty> properties = new ArrayList<PmdProperty>();
          for (ActiveRuleParam activeRuleParam : activeRule.getActiveRuleParams()) {
            properties.add(new PmdProperty(activeRuleParam.getRuleParam().getKey(), activeRuleParam.getValue()));
          }
          rule.setProperties(properties);
        }
        ruleset.addRule(rule);
        processXPathRule(activeRule.getRuleKey(), rule);
      }
    }
    return ruleset;
  }

Replace Generic With Diamond ArrayList<PmdProperty> with ArrayList<> in method private createPmdRuleset(repositoryKey String, activeRules List<ActiveRule>, profileName String) : PmdRuleset from class org.sonar.plugins.pmd.PmdProfileExporter


	@Test
	public void testJaxRSPost() throws Exception {
		logger.info("start JaxRS Post test");
		Client client = newClient();
		WebTarget target = client.target(url + "services/calculator/multi");
		double value = 0.0;
		try {
			Entity<double[]> valuesAsArray = entity(new double[] { 4.5, 6.7 }, TEXT_PLAIN);
			target.request().post(valuesAsArray);
			fail();
		} catch (ProcessingException ex) {
			assertEquals("Arrays not supported", "RESTEASY004655: Unable to invoke request", ex.getMessage());
		}
		Entity<List<Double>> valuesAsList = entity(asList(new Double[] { 4.5, 6.7 }), TEXT_PLAIN);
		try (Response response = target.request().post(valuesAsList)) {
			value = response.readEntity(Double.class);
			fail();
		} catch (ProcessingException ex) {
			assertEquals("TEXT_PLAIN not supported",
					"RESTEASY003145: Unable to find a MessageBodyReader of content-type */* and type class java.lang.Double",
					ex.getMessage());
		}

		valuesAsList = entity(asList(new Double[] { 4.5, 6.7 }), APPLICATION_JSON);
		try (Response response = target.request().post(valuesAsList)) {
			value = response.readEntity(Double.class);
		}
		assertEquals("sum implemented: ", 30.150000000000002, value, 0.0);
		assertEquals("The filter registerOperation is called", POST, calledMethod);
	}

	@Test
	public void testJaxRSPost() throws Exception {
		logger.info("start JaxRS Post test");
		Client client = newClient();
		WebTarget target = client.target(url + "services/calculator/multi");
		double value = 0.0;
		Response response = null;
		try {
			Entity<double[]> valuesAsArray = entity(new double[] { 4.5, 6.7 }, TEXT_PLAIN);
			target.request().post(valuesAsArray);
			fail();
		} catch (ProcessingException ex) {
			assertEquals("Arrays not supported", "RESTEASY004655: Unable to invoke request", ex.getMessage());
		}
		try {
			Entity<List<Double>> valuesAsList = entity(asList(new Double[] { 4.5, 6.7 }), TEXT_PLAIN);
			response = target.request().post(valuesAsList);
			value = response.readEntity(Double.class);
			fail();
		} catch (ProcessingException ex) {
			assertEquals("TEXT_PLAIN not supported",
					"RESTEASY003145: Unable to find a MessageBodyReader of content-type */* and type class java.lang.Double",
					ex.getMessage());
		} finally {
			response.close();
		}

		Entity<List<Double>> valuesAsList = entity(asList(new Double[] { 4.5, 6.7 }), APPLICATION_JSON);
		response = target.request().post(valuesAsList);
		value = response.readEntity(Double.class);
		response.close();
		assertEquals("sum implemented: ", 30.150000000000002, value, 0.0);
		assertEquals("The filter registerOperation is called", POST, calledMethod);
	}

Try With Resources try(Response response=target.request().post(valuesAsList)) in method public testJaxRSPost() : void from class it.vige.businesscomponents.services.RestTestCase


	public PathDrawer(LocalizableRobot robot){
		this.robot = robot;

		poses = new LinkedList<>();
	}

	public PathDrawer(LocalizableRobot robot){
		this.robot = robot;

		poses = new LinkedList<Coordinate>();
	}

Replace Generic With Diamond LinkedList<Coordinate> with LinkedList<> in method public PathDrawer(robot LocalizableRobot) from class edu.usf.experiment.display.drawer.PathDrawer


    public AdicionarDisciplina(PlanejadorGradeHoraria planejador) {
        this.planejador = planejador;
        setContentPane(contentPane);
        setModal(true);
        getRootPane().setDefaultButton(buttonOK);

        buttonOK.addActionListener(e -> onOK());

        buttonCancel.addActionListener(e -> onCancel());

        // call onCancel() when cross is clicked
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                onCancel();
            }
        });

        // call onCancel() on ESCAPE
        contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    }

    public AdicionarDisciplina(PlanejadorGradeHoraria planejador) {
        this.planejador = planejador;
        setContentPane(contentPane);
        setModal(true);
        getRootPane().setDefaultButton(buttonOK);

        buttonOK.addActionListener(e -> onOK());

        buttonCancel.addActionListener(e -> onCancel());

        // call onCancel() when cross is clicked
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                onCancel();
            }
        });

        // call onCancel() on ESCAPE
        contentPane.registerKeyboardAction(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onCancel();
            }
        }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    }

Replace Anonymous With Lambda com.hunter104.view.AdicionarDisciplina.AdicionarDisciplina.registerKeyboardAction.new ActionListener with e -> onCancel() in method public AdicionarDisciplina(planejador PlanejadorGradeHoraria) from class com.hunter104.view.AdicionarDisciplina


    private List<String> extractWordsFrom(String filePath) throws IOException
    {
        List<String> words = new ArrayList<>(Collections.emptyList());

        try (BufferedReader fileContent = new BufferedReader(new FileReader(FILE_PATH))) {
            String line = fileContent.readLine();
            while (line != null) {
                words.addAll(Arrays.asList(line.split(REGEX)));
                line = fileContent.readLine();
            }
        } catch (FileNotFoundException ex) {
            logger.error("The file has not been found");
        }
        return words;
    }

    private List<String> extractWordsFrom(String filePath) throws IOException
    {
        List<String> words = new ArrayList<>(Collections.emptyList());

        try {
            FileReader file = new FileReader(FILE_PATH);
            BufferedReader br = new BufferedReader(file);
            String line = br.readLine();

            while (line != null) {
                words.addAll(Arrays.asList(line.split(REGEX)));
                line = br.readLine();
            }
            file.close();
        } catch (FileNotFoundException ex) {
            logger.error("The file has not been found");
        }
        return words;
    }

Try With Resources try(BufferedReader fileContent=new BufferedReader(new FileReader(FILE_PATH))) in method private extractWordsFrom(filePath String) : List<String> from class pl.sii.PopularWords


    public static synchronized void playSound(final String url) {

        new Thread(() -> {
            try (AudioInputStream inputStream = AudioSystem.getAudioInputStream(
                    new File("src/main/java/com/game/audio/" + url))){
                Clip clip = AudioSystem.getClip();

                clip.open(inputStream);
                FloatControl gainControl =
                        (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
                gainControl.setValue(-30.0f);
                clip.start();
            } catch (Exception e) {
                System.err.println("Audio no existe: " + e.getMessage());
               // System.out.println(url);
            }
        }).start();
     }

    public static synchronized void playSound(final String url) {
        new Thread(() -> {
            try {
                Clip clip = AudioSystem.getClip();
                AudioInputStream inputStream = AudioSystem.getAudioInputStream(
                        new File("src/main/java/com/game/audio/" + url));
                clip.open(inputStream);
                clip.start();
            } catch (Exception e) {
                System.err.println("Audio no existe: " + e.getMessage());
            }
        }).start();
     }

Try With Resources try(AudioInputStream inputStream=AudioSystem.getAudioInputStream(new File("src/main/java/com/game/audio/" + url))) in method public playSound(url String) : void from class com.game.model.Tools


    public Graph(HashSet<Symbol> vertexList){
        edgeList = new HashMap<>();
        this.vertexList = vertexList;
    }

    public Graph(HashSet<Symbol> vertexList){
        edgeList = new HashMap<Symbol, LinkedList<Symbol>>();
        this.vertexList = vertexList;
    }

Replace Generic With Diamond HashMap<Symbol,LinkedList<Symbol>> with HashMap<> in method public Graph(vertexList HashSet<Symbol>) from class Graph.Graph


  public static Object[] extract(Node node, String xmlName, Class<? extends XmlExtractable> clazz)
  {
    ArrayList<Object> list = new ArrayList<>();
    extractAndTranslateForNode(traverseToTag("XML", node), list, XmlMapTranslator.get(ArrayList.class,
        new XmlMap[]{new XmlMap(xmlName, "add", new XmlMapExtractor(clazz))}));
    return list.toArray();
  }

  public static Object[] extract(Node node, String xmlName, Class<? extends XmlExtractable> clazz)
  {
    ArrayList<Object> list = new ArrayList<Object>();
    extractAndTranslateForNode(traverseToTag("XML", node), list, XmlMapTranslator.get(ArrayList.class,
        new XmlMap[]{new XmlMap(xmlName, "add", new XmlMapExtractor(clazz))}));
    return list.toArray();
  }

Replace Generic With Diamond ArrayList<Object> with ArrayList<> in method public extract(node Node, xmlName String, clazz Class<? extends XmlExtractable>) : Object[] from class com.spun.util.io.xml.XmlExtractorUtil


  public static List<Object> filterEmpty(Object... objects)
  {
    List<Object> list = new ArrayList<>();
    for (Object object : objects)
    {
      if (object != EMPTY_ENTRY)
      {
        list.add(object);
      }
    }
    return list;
  }

  public static List<Object> filterEmpty(Object... objects)
  {
    List<Object> list = new ArrayList<Object>();
    for (Object object : objects)
    {
      if (object != EMPTY_ENTRY)
      {
        list.add(object);
      }
    }
    return list;
  }

Replace Generic With Diamond ArrayList<Object> with ArrayList<> in method public filterEmpty(objects Object...) : List<Object> from class org.approvaltests.combinations.CombinationsHelper


  public static MapBuilder<String, Object> params(String key, Object value)
  {
    return new MapBuilder<>(key, value);
  }

  public static MapBuilder<String, Object> params(String key, Object value)
  {
    return new MapBuilder<String, Object>(key, value);
  }

Replace Generic With Diamond MapBuilder<String,Object> with MapBuilder<> in method public params(key String, value Object) : MapBuilder<String,Object> from class com.spun.util.MapTest


  public static String[][] parse(Reader data)
  {
    try
    {
      List<String[]> records = new ArrayList<>();
      try (BufferedReader reader = new BufferedReader(data)) {
        boolean done = false;
        StringBuffer pastLines = null;
        while (!done) {
          String line = reader.readLine();
          if (line == null) {
            done = true;
          } else {
            if (pastLines != null) {
              pastLines.append("\n");
              pastLines.append(line);
              line = pastLines.toString();
            }
            String[] parseLine = parseLine(line);
            if (parseLine == null) {
              if (pastLines == null) {
                pastLines = new StringBuffer(line);
              }
            } else {
              records.add(parseLine);
              pastLines = null;
            }
          }
        }
      }
      return records.toArray(new String[records.size()][]);
    }
    catch (IOException e)
    {
      throw new RuntimeException(e);
    }
  }

  public static String[][] parse(Reader data)
  {
    try
    {
      List<String[]> records = new ArrayList<String[]>();
      BufferedReader reader = new BufferedReader(data);
      boolean done = false;
      StringBuffer pastLines = null;
      while (!done)
      {
        String line = reader.readLine();
        if (line == null)
        {
          done = true;
        }
        else
        {
          if (pastLines != null)
          {
            pastLines.append("\n");
            pastLines.append(line);
            line = pastLines.toString();
          }
          String[] parseLine = parseLine(line);
          if (parseLine == null)
          {
            if (pastLines == null)
            {
              pastLines = new StringBuffer(line);
            }
          }
          else
          {
            records.add(parseLine);
            pastLines = null;
          }
        }
      }
      return records.toArray(new String[records.size()][]);
    }
    catch (IOException e)
    {
      throw new RuntimeException(e);
    }
  }

Try With Resources try(BufferedReader reader=new BufferedReader(data)) in method public parse(data Reader) : String[][] from class com.spun.util.io.CommaDelimitedFileParser


  public ByteArrayDataSource(InputStream is, String type, String name)
  {
    this.type = type;
    setName(name);
    try
    {
      try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
        int ch;
        while ((ch = is.read()) != -1) {
          // XXX - must be made more efficient by
          // doing buffered reads, rather than one byte reads
          os.write(ch);
        }
        data = os.toByteArray();
      }
    }
    catch (IOException e)
    {
      throw ObjectUtils.throwAsError(e);
    }
  }

  public ByteArrayDataSource(InputStream is, String type, String name)
  {
    this.type = type;
    setName(name);
    try
    {
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      int ch;
      while ((ch = is.read()) != -1)
      {
        // XXX - must be made more efficient by
        // doing buffered reads, rather than one byte reads
        os.write(ch);
      }
      data = os.toByteArray();
    }
    catch (IOException ioex)
    {
    }
  }

Try With Resources try(ByteArrayOutputStream os=new ByteArrayOutputStream()) in method public ByteArrayDataSource(is InputStream, type String, name String) from class com.spun.util.ByteArrayDataSource


  public static void reset()
  {
    TOMCAT_LOGS_PATH = getLogPath();
    writers = new HashMap<>();
  }

  public static void reset()
  {
    TOMCAT_LOGS_PATH = getLogPath();
    writers = new HashMap<String, Appendable>();
  }

Replace Generic With Diamond HashMap<String,Appendable> with HashMap<> in method public reset() : void from class com.spun.util.servlets.ServletLogWriterFactory


  /************************************************************************/
  public static File saveToFile(String prefix, Reader input)
  {
    File file;
    try
    {
      file = File.createTempFile(prefix, null);
      try (BufferedWriter bw = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8)) {

        BufferedReader inputReader = new BufferedReader(input);
        String thisLine;
        while ((thisLine = inputReader.readLine()) != null) {
          bw.write(thisLine);
          bw.newLine();
        }
        inputReader.close();
      }
    }
    catch (IOException e)
    {
      throw new RuntimeException("Unable to store order: " + e.getMessage(), e);
    }
    return file;
  }

  /************************************************************************/
  public static File saveToFile(String prefix, Reader input)
  {
    File file;
    BufferedWriter bw = null;
    try
    {
      file = File.createTempFile(prefix, null);
      bw = new BufferedWriter(new FileWriter(file));
      BufferedReader inputReader = new BufferedReader(input);
      String thisLine;
      while ((thisLine = inputReader.readLine()) != null)
      {
        bw.write(thisLine);
        bw.newLine();
      }
      inputReader.close();
    }
    catch (IOException e)
    {
      throw new RuntimeException("Unable to store order: " + e.getMessage(), e);
    }
    finally
    {
      try
      {
        if (bw != null)
        {
          bw.close();
        }
      }
      catch (IOException e)
      {
      }
    }
    return file;
  }

Try With Resources try(BufferedWriter bw=Files.newBufferedWriter(file.toPath(),StandardCharsets.UTF_8)) in method public saveToFile(prefix String, input Reader) : File from class com.spun.util.io.FileUtils


  /***********************************************************************/
  public static void writeFile(File file, String text)
  {
    try
    {
      Asserts.assertNotNull("Writing to file: " + file, text);
      file.getCanonicalFile().getParentFile().mkdirs();
      try (BufferedWriter out = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8)) {
        out.write(text);
      }
    }
    catch (Throwable t)
    {
      throw ObjectUtils.throwAsError(t);
    }
  }

  /***********************************************************************/
  public static void writeFile(File file, String text)
  {
    try
    {
      Asserts.assertNotNull("Writing to file: " + file, text);
      file.getCanonicalFile().getParentFile().mkdirs();
      BufferedWriter out = new BufferedWriter(new FileWriter(file));
      out.write(text);
      out.close();
    }
    catch (Throwable t)
    {
      throw ObjectUtils.throwAsError(t);
    }
  }

Try With Resources try(BufferedWriter out=Files.newBufferedWriter(file.toPath(),StandardCharsets.UTF_8)) in method public writeFile(file File, text String) : void from class com.spun.util.io.FileUtils


  public static void writeFile(File file, CharSequence data)
  {
    try
    {
      Asserts.assertNotNull("Writing to file: " + file, data);
      file.getCanonicalFile().getParentFile().mkdirs();
      try (DataOutputStream writer = new DataOutputStream(new FileOutputStream(file))) {
        for (int i = 0; i < data.length(); i++) {
          writer.write(data.charAt(i));
        }
      }
    }
    catch (Throwable t)
    {
      throw ObjectUtils.throwAsError(t);
    }
  }

  public static void writeFile(File file, CharSequence data)
  {
    try
    {
      Asserts.assertNotNull("Writing to file: " + file, data);
      file.getCanonicalFile().getParentFile().mkdirs();
      DataOutputStream writer = new DataOutputStream(new FileOutputStream(file));
      for (int i = 0; i < data.length(); i++)
      {
        writer.write(data.charAt(i));
      }
      writer.close();
    }
    catch (Throwable t)
    {
      throw ObjectUtils.throwAsError(t);
    }
  }

Try With Resources try(DataOutputStream writer=new DataOutputStream(new FileOutputStream(file))) in method public writeFile(file File, data CharSequence) : void from class com.spun.util.io.FileUtils


  /***********************************************************************/
  public static Method getGreatestCommonDenominator(Object[] from, String methodName)
      throws SecurityException, NoSuchMethodException
  {
    List<Class<?>> classes = new ArrayList<>();
    ArrayUtils.addArray(classes, getAllCastableClasses(from[0]));
    for (Object o : from)
    {
      for (int i = classes.size() - 1; i >= 0; i--)
      {
        Class<?> clazz = classes.get(i);
        if (!isThisInstanceOfThat(o.getClass(), clazz) || !ClassUtils.hasMethod(clazz, methodName))
        {
          classes.remove(i);
        }
      }
    }
    return classes.size() == 0 ? null : ArrayUtils.getLast(classes).getMethod(methodName, (Class[]) null);
  }

  /***********************************************************************/
  public static Method getGreatestCommonDenominator(Object[] from, String methodName)
      throws SecurityException, NoSuchMethodException
  {
    List<Class> classes = new ArrayList<Class>();
    ArrayUtils.addArray(classes, getAllCastableClasses(from[0]));
    for (Object o : from)
    {
      for (int i = classes.size() - 1; i >= 0; i--)
      {
        Class<?> clazz = classes.get(i);
        if (!isThisInstanceOfThat(o.getClass(), clazz) || !ClassUtils.hasMethod(clazz, methodName))
        {
          classes.remove(i);
        }
      }
    }
    return classes.size() == 0 ? null : ArrayUtils.getLast(classes).getMethod(methodName, (Class[]) null);
  }

Replace Generic With Diamond ArrayList<Class> with ArrayList<> in method public getGreatestCommonDenominator(from Object[], methodName String) : Method from class com.spun.util.ObjectUtils


    public static CompletableFuture<BufferedImage> getChunkImage(String id) {
        return get("/pngs/" + id)
                .thenApply(Response::body)
                .thenApply(body -> {
                    try (InputStream stream = body.byteStream()) {
                        System.out.println(stream.available());
                        return ImageIO.read(stream);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                });
    }

    public static CompletableFuture<BufferedImage> getChunkImage(String id) {
        return get("/pngs/" + id)
                .thenApply(Response::body)
                .thenApply(ResponseBody::byteStream)
                .thenApply(stream -> {
                    try {
                        return ImageIO.read(stream);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                });
    }

Try With Resources try(InputStream stream=body.byteStream()) in method public getChunkImage(id String) : CompletableFuture<BufferedImage> from class org.inventivetalent.canvas.CanvasClient


    @Override
    public <T> Future<List<T>> queryAsync(Class<T> _class, DaoQuery _query) {
        return submit(new QueryExecution<>(this, _class, _query));
    }

    @Override
    public <T> Future<List<T>> queryAsync(Class<T> _class, DaoQuery _query) {
        return submit(new QueryExecution<T>(this, _class, _query));
    }

Replace Generic With Diamond QueryExecution<T> with QueryExecution<> in method public queryAsync(_class Class<T>, _query DaoQuery) : Future<List<T>> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public <T> Future<List<T>> queryAsync(Class<T> _class, DaoQuery _query, DaoSort _sort) {
        return submit(new QueryExecution<>(this, _class, _query, _sort));
    }

    @Override
    public <T> Future<List<T>> queryAsync(Class<T> _class, DaoQuery _query, DaoSort _sort) {
        return submit(new QueryExecution<T>(this, _class, _query, _sort));
    }

Replace Generic With Diamond QueryExecution<T> with QueryExecution<> in method public queryAsync(_class Class<T>, _query DaoQuery, _sort DaoSort) : Future<List<T>> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public <T> Future<List<T>> queryAsync(Class<T> _class, DaoQuery _query, Collection<String> _fields) {
        return submit(new QueryExecution<>(this, _class, _query, _fields));
    }

    @Override
    public <T> Future<List<T>> queryAsync(Class<T> _class, DaoQuery _query, Collection<String> _fields) {
        return submit(new QueryExecution<T>(this, _class, _query, _fields));
    }

Replace Generic With Diamond QueryExecution<T> with QueryExecution<> in method public queryAsync(_class Class<T>, _query DaoQuery, _fields Collection<String>) : Future<List<T>> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public <T> Future<List<T>> queryAsync(Class<T> _class, DaoQuery _query, Collection<String> _fields, DaoSort _sort) {
        return submit(new QueryExecution<>(this, _class, _query, _fields, _sort));
    }

    @Override
    public <T> Future<List<T>> queryAsync(Class<T> _class, DaoQuery _query, Collection<String> _fields, DaoSort _sort) {
        return submit(new QueryExecution<T>(this, _class, _query, _fields, _sort));
    }

Replace Generic With Diamond QueryExecution<T> with QueryExecution<> in method public queryAsync(_class Class<T>, _query DaoQuery, _fields Collection<String>, _sort DaoSort) : Future<List<T>> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public <T, V> Future<List<V>> queryWithFinalizer(Class<T> _class, DaoQuery _query, Collection<String> _fields, DaoSort _sort, QueryFinalizer<T, V> _finalizer) {
        return submit(new QueryFinalizerExecution<>(this, _class, _query, _fields, _sort, _finalizer));
    }

    @Override
    public <T, V> Future<List<V>> queryWithFinalizer(Class<T> _class, DaoQuery _query, Collection<String> _fields, DaoSort _sort, QueryFinalizer<T, V> _finalizer) {
        return submit(new QueryFinalizerExecution<T, V>(this, _class, _query, _fields, _sort, _finalizer));
    }

Replace Generic With Diamond QueryFinalizerExecution<T,V> with QueryFinalizerExecution<> in method public queryWithFinalizer(_class Class<T>, _query DaoQuery, _fields Collection<String>, _sort DaoSort, _finalizer QueryFinalizer<T,V>) : Future<List<V>> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public <T> DaoPage<T> queryPage(Class<T> _class, DaoQuery _query, Collection<String> _fields, DaoSort _sort, int _offset, int _count) {
        return new DaoPage<>(query(_class, _query, _fields, _sort, _offset, _count), count(_class, _query));
    }

    @Override
    public <T> DaoPage<T> queryPage(Class<T> _class, DaoQuery _query, Collection<String> _fields, DaoSort _sort, int _offset, int _count) {
        return new DaoPage<T>(query(_class, _query, _fields, _sort, _offset, _count), count(_class, _query));
    }

Replace Generic With Diamond DaoPage<T> with DaoPage<> in method public queryPage(_class Class<T>, _query DaoQuery, _fields Collection<String>, _sort DaoSort, _offset int, _count int) : DaoPage<T> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public DaoPage<DaoEntity> queryForEntitiesPage(String _tableName, DaoQuery _query, Collection<String> _fields, DaoSort _sort, int _offset, int _count) {
        return new DaoPage<>(queryForEntities(_tableName, _query, _fields, _sort, _offset, _count), count(_tableName, _query));
    }

    @Override
    public DaoPage<DaoEntity> queryForEntitiesPage(String _tableName, DaoQuery _query, Collection<String> _fields, DaoSort _sort, int _offset, int _count) {
        return new DaoPage<DaoEntity>(queryForEntities(_tableName, _query, _fields, _sort, _offset, _count), count(_tableName, _query));
    }

Replace Generic With Diamond DaoPage<DaoEntity> with DaoPage<> in method public queryForEntitiesPage(_tableName String, _query DaoQuery, _fields Collection<String>, _sort DaoSort, _offset int, _count int) : DaoPage<DaoEntity> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public <T> Future<T> queryOneAsync(Class<T> _class, DaoQuery _query) {
        return submit(new QueryOneExecution<>(this, _class, _query));
    }

    @Override
    public <T> Future<T> queryOneAsync(Class<T> _class, DaoQuery _query) {
        return submit(new QueryOneExecution<T>(this, _class, _query));
    }

Replace Generic With Diamond QueryOneExecution<T> with QueryOneExecution<> in method public queryOneAsync(_class Class<T>, _query DaoQuery) : Future<T> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public <T> Future<T> queryOneAsync(Class<T> _class, DaoQuery _query, DaoSort _sort) {
        return submit(new QueryOneExecution<>(this, _class, _query, _sort));
    }

    @Override
    public <T> Future<T> queryOneAsync(Class<T> _class, DaoQuery _query, DaoSort _sort) {
        return submit(new QueryOneExecution<T>(this, _class, _query, _sort));
    }

Replace Generic With Diamond QueryOneExecution<T> with QueryOneExecution<> in method public queryOneAsync(_class Class<T>, _query DaoQuery, _sort DaoSort) : Future<T> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public <T> Future<T> queryOneAsync(Class<T> _class, DaoQuery _query, Collection<String> _fields) {
        return submit(new QueryOneExecution<>(this, _class, _query, _fields));
    }

    @Override
    public <T> Future<T> queryOneAsync(Class<T> _class, DaoQuery _query, Collection<String> _fields) {
        return submit(new QueryOneExecution<T>(this, _class, _query, _fields));
    }

Replace Generic With Diamond QueryOneExecution<T> with QueryOneExecution<> in method public queryOneAsync(_class Class<T>, _query DaoQuery, _fields Collection<String>) : Future<T> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public <T> Future<T> queryOneAsync(Class<T> _class, DaoQuery _query, Collection<String> _fields, DaoSort _sort) {
        return submit(new QueryOneExecution<>(this, _class, _query, _fields, _sort));
    }

    @Override
    public <T> Future<T> queryOneAsync(Class<T> _class, DaoQuery _query, Collection<String> _fields, DaoSort _sort) {
        return submit(new QueryOneExecution<T>(this, _class, _query, _fields, _sort));
    }

Replace Generic With Diamond QueryOneExecution<T> with QueryOneExecution<> in method public queryOneAsync(_class Class<T>, _query DaoQuery, _fields Collection<String>, _sort DaoSort) : Future<T> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public <T> DaoPage<T> queryImportantPage(Class<T> _class, DaoQuery _query, DaoSort _sort, int _offset, int _count) {
        return new DaoPage<>(queryImportant(_class, _query, _sort, _offset, _count), count(_class, _query));
    }

    @Override
    public <T> DaoPage<T> queryImportantPage(Class<T> _class, DaoQuery _query, DaoSort _sort, int _offset, int _count) {
        return new DaoPage<T>(queryImportant(_class, _query, _sort, _offset, _count), count(_class, _query));
    }

Replace Generic With Diamond DaoPage<T> with DaoPage<> in method public queryImportantPage(_class Class<T>, _query DaoQuery, _sort DaoSort, _offset int, _count int) : DaoPage<T> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public List<String> queryForField(Class<?> _class, DaoQuery _query, final String _field, DaoSort _sort) {
        return CollectionUtils.transform(queryForEntities(DaoSerializer.getTableName(_class, getType()), _query, List.of(_field), _sort), _daoEntity -> DaoSerializer.getString(_daoEntity, _field));
    }

    @Override
    public List<String> queryForField(Class<?> _class, DaoQuery _query, final String _field, DaoSort _sort) {
        return CollectionUtils.transform(queryForEntities(DaoSerializer.getTableName(_class, getType()), _query, Arrays.asList(_field), _sort), new ITransformer<DaoEntity, String>() {
            @Override
            public String transform(DaoEntity _daoEntity) {
                return DaoSerializer.getString(_daoEntity, _field);
            }
        });
    }

Replace Anonymous With Lambda com.lanternsoftware.util.dao.AbstractDaoProxy.queryForField.transform.new ITransformer<DaoEntity,String> with _daoEntity -> DaoSerializer.getString(_daoEntity,_field) in method public queryForField(_class Class<?>, _query DaoQuery, _field String, _sort DaoSort) : List<String> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public List<String> queryForField(String _tableName, DaoQuery _query, final String _field) {
        return CollectionUtils.transform(queryForEntities(_tableName, _query, List.of(_field)), _daoEntity -> DaoSerializer.getString(_daoEntity, _field));
    }

    @Override
    public List<String> queryForField(String _tableName, DaoQuery _query, final String _field) {
        return CollectionUtils.transform(queryForEntities(_tableName, _query, Arrays.asList(_field)), new ITransformer<DaoEntity, String>() {
            @Override
            public String transform(DaoEntity _daoEntity) {
                return DaoSerializer.getString(_daoEntity, _field);
            }
        });
    }

Replace Anonymous With Lambda com.lanternsoftware.util.dao.AbstractDaoProxy.queryForField.transform.new ITransformer<DaoEntity,String> with _daoEntity -> DaoSerializer.getString(_daoEntity,_field) in method public queryForField(_tableName String, _query DaoQuery, _field String) : List<String> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Override
    public <T> Map<String, T> save(Collection<T> _objects) {
        Map<String, T> ids = new HashMap<>();
        for (T o : _objects) {
            String id = save(o);
            if (NullUtils.isNotEmpty(id))
                ids.put(id, o);
        }
        return ids;
    }

    @Override
    public <T> Map<String, T> save(Collection<T> _objects) {
        Map<String, T> ids = new HashMap<String, T>();
        for (T o : _objects) {
            String id = save(o);
            if (NullUtils.isNotEmpty(id))
                ids.put(id, o);
        }
        return ids;
    }

Replace Generic With Diamond HashMap<String,T> with HashMap<> in method public save(_objects Collection<T>) : Map<String,T> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    protected <T> List<T> toObjects(List<DaoEntity> _entities, final Class<T> _class) {
        return CollectionUtils.transform(_entities, _daoEntity -> DaoSerializer.fromDaoEntity(_daoEntity, _class, getType()));
    }

    protected <T> List<T> toObjects(List<DaoEntity> _entities, final Class<T> _class) {
        return CollectionUtils.transform(_entities, new ITransformer<DaoEntity, T>() {
            @Override
            public T transform(DaoEntity _daoEntity) {
                return DaoSerializer.fromDaoEntity(_daoEntity, _class, getType());
            }
        });
    }

Replace Anonymous With Lambda com.lanternsoftware.util.dao.AbstractDaoProxy.toObjects.transform.new ITransformer<DaoEntity,T> with _daoEntity -> DaoSerializer.fromDaoEntity(_daoEntity,_class,getType()) in method protected toObjects(_entities List<DaoEntity>, _class Class<T>) : List<T> from class com.lanternsoftware.util.dao.AbstractDaoProxy


    @Test
    public void test009() {
        Heap heap = new Heap();
        ArrayList<Integer> input = new ArrayList<>(Arrays.asList(-1, -2, -3, -4));
        ArrayList<Integer> output = heap.heap_sort(input);
        printTest(output);
        isSorted(output);
    }

    @Test
    public void test009() {
        Heap heap = new Heap();
        ArrayList<Integer> input = new ArrayList<Integer>(Arrays.asList(-1, -2, -3, -4));
        ArrayList<Integer> output = heap.heap_sort(input);
        printTest(output);
        isSorted(output);
    }

Replace Generic With Diamond ArrayList<Integer> with ArrayList<> in method public test009() : void from class sort.HeapSortTest


    public Phrase(String groupText){
        parts = new ArrayList<>(List.of(groupText.split("/")));
        if (parts.get(0).toUpperCase().equals(parts.get(0))){
            phraseType = PhraseType.TAG;
        } else {
            phraseType = PhraseType.WORD;
        }
    }

    public Phrase(String groupText){
        parts = new ArrayList<String>(List.of(groupText.split("/")));
        if (parts.get(0).toUpperCase().equals(parts.get(0))){
            phraseType = PhraseType.TAG;
        } else {
            phraseType = PhraseType.WORD;
        }
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public Phrase(groupText String) from class org.example.Phrase


    public ArrayList<AnnotatedPhrase> findGroups(AnnotatedSentence sentence){
        ArrayList<AnnotatedPhrase> phraseList = new ArrayList<>();
        int groupIndex = 0, wordIndex = 0;
        boolean inPpMatch = false;
        AnnotatedPhrase ppPhrase = null;
        while (groupIndex < groups.size() && wordIndex < sentence.wordCount()){
            Phrase phrase = groups.get(groupIndex);
            AnnotatedWord word = (AnnotatedWord) sentence.getWord(wordIndex);
            if (Word.isPunctuation(word.getName())){
                inPpMatch = false;
                wordIndex++;
            } else {
                if (phrase.wordMatch(word) || phrase.tagMatch(word)){
                    AnnotatedPhrase annotatedPhrase = new AnnotatedPhrase(wordIndex, "" + (groupIndex + 1));
                    annotatedPhrase.addWord(word);
                    phraseList.add(annotatedPhrase);
                    groupIndex++;
                    wordIndex++;
                    inPpMatch = false;
                } else {
                    if (!inPpMatch && phrase.ppmatch(word)){
                        ppPhrase = new AnnotatedPhrase(wordIndex, "" + (groupIndex + 1));
                        ppPhrase.addWord(word);
                        phraseList.add(ppPhrase);
                        wordIndex++;
                        inPpMatch = true;
                    } else {
                        if (inPpMatch){
                            ppPhrase.addWord(word);
                            wordIndex++;
                        } else {
                            if (phrase.isComplexPhrase()){
                                groupIndex++;
                            } else {
                                wordIndex++;
                            }
                        }
                    }
                }
            }
        }
        if (Word.isPunctuation(sentence.getWord(sentence.wordCount() - 1).getName())){
            AnnotatedPhrase annotatedPhrase = new AnnotatedPhrase(sentence.wordCount() - 1, "" + (groups.size() + 1));
            annotatedPhrase.addWord(sentence.getWord(sentence.wordCount() - 1));
            phraseList.add(annotatedPhrase);
        }
        if (phraseList.size() != groups.size() + 1){
            AnnotatedPhrase firstPhrase = phraseList.get(0);
            int firstTag = Integer.parseInt(firstPhrase.getTag());
            if (firstTag == 2){
                AnnotatedPhrase newPhrase = new AnnotatedPhrase(1, "1");
                for (int j = 0; j < firstPhrase.getWordIndex(); j++){
                    newPhrase.addWord(sentence.getWord(j));
                }
                phraseList.add(0, newPhrase);
            }
            for (int i = 0; i < phraseList.size() - 1; i++){
                AnnotatedPhrase phrase = phraseList.get(i);
                int tag = Integer.parseInt(phrase.getTag());
                AnnotatedPhrase phraseNext = phraseList.get(i + 1);
                int tagNext = Integer.parseInt(phraseNext.getTag());
                if (tag + 2 == tagNext){
                    AnnotatedPhrase newPhrase = new AnnotatedPhrase(phrase.getWordIndex() + 1, "" + (tag + 1));
                    for (int j = phrase.getWordIndex() + 1; j < phraseNext.getWordIndex(); j++){
                        newPhrase.addWord(sentence.getWord(j));
                    }
                    phraseList.add(i + 1, newPhrase);
                }
            }
        }
        return phraseList;
    }

    public ArrayList<AnnotatedPhrase> findGroups(AnnotatedSentence sentence){
        ArrayList<AnnotatedPhrase> phraseList = new ArrayList<AnnotatedPhrase>();
        int groupIndex = 0, wordIndex = 0;
        boolean inPpMatch = false;
        AnnotatedPhrase ppPhrase = null;
        while (groupIndex < groups.size() && wordIndex < sentence.wordCount()){
            Phrase phrase = groups.get(groupIndex);
            AnnotatedWord word = (AnnotatedWord) sentence.getWord(wordIndex);
            if (Word.isPunctuation(word.getName())){
                inPpMatch = false;
                wordIndex++;
            } else {
                if (phrase.wordMatch(word) || phrase.tagMatch(word)){
                    AnnotatedPhrase annotatedPhrase = new AnnotatedPhrase(wordIndex, "" + (groupIndex + 1));
                    annotatedPhrase.addWord(word);
                    phraseList.add(annotatedPhrase);
                    groupIndex++;
                    wordIndex++;
                    inPpMatch = false;
                } else {
                    if (!inPpMatch && phrase.ppmatch(word)){
                        ppPhrase = new AnnotatedPhrase(wordIndex, "" + (groupIndex + 1));
                        ppPhrase.addWord(word);
                        phraseList.add(ppPhrase);
                        wordIndex++;
                        inPpMatch = true;
                    } else {
                        if (inPpMatch){
                            ppPhrase.addWord(word);
                            wordIndex++;
                        } else {
                            if (phrase.isComplexPhrase()){
                                groupIndex++;
                            } else {
                                wordIndex++;
                            }
                        }
                    }
                }
            }
        }
        if (Word.isPunctuation(sentence.getWord(sentence.wordCount() - 1).getName())){
            AnnotatedPhrase annotatedPhrase = new AnnotatedPhrase(sentence.wordCount() - 1, "" + (groups.size() + 1));
            annotatedPhrase.addWord(sentence.getWord(sentence.wordCount() - 1));
            phraseList.add(annotatedPhrase);
        }
        if (phraseList.size() != groups.size() + 1){
            AnnotatedPhrase firstPhrase = phraseList.get(0);
            int firstTag = Integer.parseInt(firstPhrase.getTag());
            if (firstTag == 2){
                AnnotatedPhrase newPhrase = new AnnotatedPhrase(1, "1");
                for (int j = 0; j < firstPhrase.getWordIndex(); j++){
                    newPhrase.addWord(sentence.getWord(j));
                }
                phraseList.add(0, newPhrase);
            }
            for (int i = 0; i < phraseList.size() - 1; i++){
                AnnotatedPhrase phrase = phraseList.get(i);
                int tag = Integer.parseInt(phrase.getTag());
                AnnotatedPhrase phraseNext = phraseList.get(i + 1);
                int tagNext = Integer.parseInt(phraseNext.getTag());
                if (tag + 2 == tagNext){
                    AnnotatedPhrase newPhrase = new AnnotatedPhrase(phrase.getWordIndex() + 1, "" + (tag + 1));
                    for (int j = phrase.getWordIndex() + 1; j < phraseNext.getWordIndex(); j++){
                        newPhrase.addWord(sentence.getWord(j));
                    }
                    phraseList.add(i + 1, newPhrase);
                }
            }
        }
        return phraseList;
    }

Replace Generic With Diamond ArrayList<AnnotatedPhrase> with ArrayList<> in method public findGroups(sentence AnnotatedSentence) : ArrayList<AnnotatedPhrase> from class org.example.SentenceOfPhrases


    public static List<Livro> pesquisarLivros(String titulo, String autor, String editora, String isbn, int idLivroCategoria, int idLivroStatus) {
        public static List<Livro> pesquisarLivros (String titulo, String autor, String editora, String isbn,
        int idLivroCategoria, int idLivroStatus){
            List<Livro> livrosEncontrados = new ArrayList<>();

            try (Connection connection = DriverManager.getConnection(URL)) {
                String sql = "SELECT * FROM livro WHERE titulo LIKE ? AND autor LIKE ? AND editora LIKE ? AND isbn LIKE ? AND id_livro_categoria = ? AND id_livro_status = ?";
                try (PreparedStatement statement = connection.prepareStatement(sql)) {
                    statement.setString(1, "%" + titulo + "%");
                    statement.setString(2, "%" + autor + "%");
                    statement.setString(3, "%" + editora + "%");
                    statement.setString(4, "%" + isbn + "%");
                    statement.setInt(5, idLivroCategoria);
                    statement.setInt(6, idLivroStatus);

                    try (ResultSet resultSet = statement.executeQuery()) {
                        while (resultSet.next()) {
                            Livro livro = new Livro(
                                    resultSet.getInt("id_livro"),
                                    resultSet.getString("titulo"),
                                    resultSet.getString("autor"),
                                    resultSet.getString("editora"),
                                    resultSet.getString("sinopse"),
                                    resultSet.getInt("paginas"),
                                    resultSet.getString("isbn"),
                                    resultSet.getDate("data_publicacao"),
                                    resultSet.getDate("data_cadastro"),
                                    resultSet.getInt("id_livro_categoria"),
                                    resultSet.getInt("id_livro_status")
                            );

                            livrosEncontrados.add(livro);
                        }
                    }
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }

            return livrosEncontrados;
        }
    }

    public static List<Livro> pesquisarLivros(String titulo, String autor, String editora, String isbn, int idLivroCategoria, int idLivroStatus) {
        List<Livro> livrosEncontrados = new ArrayList<>();

        try {
            Connection connection = DriverManager.getConnection(URL);
            String sql = "SELECT * FROM livro WHERE titulo LIKE ? AND autor LIKE ? AND editora LIKE ? AND isbn LIKE ? AND id_livro_categoria = ? AND id_livro_status = ?";
            PreparedStatement statement = connection.prepareStatement(sql);
            statement.setString(1, "%" + titulo + "%");
            statement.setString(2, "%" + autor + "%");
            statement.setString(3, "%" + editora + "%");
            statement.setString(4, "%" + isbn + "%");
            statement.setInt(5, idLivroCategoria);
            statement.setInt(6, idLivroStatus);

            ResultSet resultSet = statement.executeQuery();

//            while (resultSet.next()) {
//                Livro livro = new Livro();
//                livro.setIdLivro(resultSet.getInt("id_livro"));
//                livro.setTitulo(resultSet.getString("titulo"));
//                livro.setAutor(resultSet.getString("autor"));
//                livro.setEditora(resultSet.getString("editora"));
//                livro.setSinopse(resultSet.getString("sinopse"));
//                livro.setPaginas(resultSet.getInt("paginas"));
//                livro.setIdLivroCategoria(resultSet.getInt("id_livro_categoria"));
//                livro.setIsbn(resultSet.getString("isbn"));
//                livro.setPrazoEmprestimo(resultSet.getInt("prazo_emprestimo"));
//                livro.setDataPublicacao(resultSet.getDate("data_publicacao"));
//                livro.setDataCadastro(resultSet.getDate("data_cadastro"));
//                livro.setIdLivroStatus(resultSet.getInt("id_livro_status"));
//
//                livrosEncontrados.add(livro);
//            }

            connection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return livrosEncontrados;
    }

Try With Resources try(PreparedStatement statement=connection.prepareStatement(sql)) in method public pesquisarLivros(titulo String, autor String, editora String, isbn String, idLivroCategoria int, idLivroStatus int) : List<Livro> from class models.Database.DatabaseManager


    private void addToIncoming(FullTransition ft) {
        if (!incoming.containsKey(ft.getTargetState())) {
            incoming.put(ft.getTargetState(), new HashSet<>());
        }
        incoming.get(ft.getTargetState()).add(ft);
    }

    private void addToIncoming(FullTransition ft) {
        if (!incoming.containsKey(ft.getTargetState())) {
            incoming.put(ft.getTargetState(), new HashSet<FullTransition>());
        }
        incoming.get(ft.getTargetState()).add(ft);
    }

Replace Generic With Diamond HashSet<FullTransition> with HashSet<> in method private addToIncoming(ft FullTransition) : void from class org.snt.autorex.AutomatonTrans


    private void addToOutgoing(FullTransition ft) {
        if (!outgoing.containsKey(ft.getSourceState())) {
            outgoing.put(ft.getSourceState(), new HashSet<>());
        }
        outgoing.get(ft.getSourceState()).add(ft);
    }

    private void addToOutgoing(FullTransition ft) {
        if (!outgoing.containsKey(ft.getSourceState())) {
            outgoing.put(ft.getSourceState(), new HashSet<FullTransition>());
        }
        outgoing.get(ft.getSourceState()).add(ft);
    }

Replace Generic With Diamond HashSet<FullTransition> with HashSet<> in method private addToOutgoing(ft FullTransition) : void from class org.snt.autorex.AutomatonTrans


	public static void main(String[] args) {
		Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
		System.setProperty("java.awt.headless", "true");
		System.setProperty("apple.awt.UIElement", "true");

		cleanClipBoard();
		new Thread(() -> {
			while (true) {

				try {
					Thread.sleep(2_000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}

				final ClipboardOwner clipboardOwner = new ClipboardOwner() {
					@Override
					public void lostOwnership(Clipboard clipboard, Transferable contents) {
						try {
							System.out.println((String) clipboard.getData(DataFlavor.stringFlavor));
						} catch (UnsupportedFlavorException e) {
						} catch (IOException e) {
						}
					}
				};
				final Transferable contents = systemClipboard.getContents(clipboardOwner);
				try {
					if (contents.isDataFlavorSupported(DataFlavor.imageFlavor)) {
						Image image = (Image) contents.getTransferData(DataFlavor.imageFlavor);
						final BufferedImage bufferedImage = toBufferedImage(image);

						String fileName = "savingAnImage";
						String ext = "png";
						File file = new File(fileName + "." + ext);
						try {
							ImageIO.write(bufferedImage, ext, file);  // ignore returned boolean
							uploadFile("https://klikr.org/upload.php", file);
						} catch(IOException e) {
							System.out.println("Write error for " + file.getPath() +
									": " + e.getMessage());
						} finally {
							Files.delete(file.toPath());
						}
						cleanClipBoard();
					}
				} catch (UnsupportedFlavorException | IOException e) {
					e.printStackTrace();
				}

			}
		}).start();

		JFrame frame = new JFrame("Klikr");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		try (InputStream is = Main.class.getClassLoader().getResourceAsStream("doc.png");) {
			Objects.requireNonNull(is);
			Image image = ImageIO.read(is);
			if (Taskbar.getTaskbar().isSupported(Taskbar.Feature.ICON_IMAGE)) {
				Taskbar.getTaskbar().setIconImage(image);
			}
		} catch (IOException ex) {
			throw new RuntimeException(ex);
		}

		frame.setSize(new Dimension(0, 0));
		frame.setVisible(false);

	}

	public static void main(String[] args) {
		Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
		System.setProperty("java.awt.headless", "true");
		System.setProperty("apple.awt.UIElement", "true");

		cleanClipBoard();
		new Thread(new Runnable() {
			@Override
			public void run() {
				while (true) {

					try {
						Thread.sleep(2_000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}

					final ClipboardOwner clipboardOwner = new ClipboardOwner() {
						@Override
						public void lostOwnership(Clipboard clipboard, Transferable contents) {
							try {
								System.out.println((String) clipboard.getData(DataFlavor.stringFlavor));
							} catch (UnsupportedFlavorException e) {
							} catch (IOException e) {
							}
						}
					};
					final Transferable contents = systemClipboard.getContents(clipboardOwner);
					try {
//							for (DataFlavor transferDataFlavor : contents.getTransferDataFlavors()) {
//								System.out.println(transferDataFlavor.toString());
//							}
						if (contents.isDataFlavorSupported(DataFlavor.imageFlavor)) {
//							final Object transferData = contents.getTransferData(DataFlavor.imageFlavor);
							Image image = (Image) contents.getTransferData(DataFlavor.imageFlavor);
							final BufferedImage bufferedImage = toBufferedImage(image);

							String fileName = "savingAnImage";
							String ext = "png";
							File file = new File(fileName + "." + ext);
							try {
								ImageIO.write(bufferedImage, ext, file);  // ignore returned boolean
								uploadFile("https://klikr.org/upload.php", file);
							} catch(IOException e) {
								System.out.println("Write error for " + file.getPath() +
										": " + e.getMessage());
							}
							cleanClipBoard();
						}
//
					} catch (UnsupportedFlavorException e) {
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
					}

				}
			}
		}).start();

		JFrame frame = new JFrame("Klikr");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		try (InputStream is = Main.class.getClassLoader().getResourceAsStream("doc.png");) {
			Objects.requireNonNull(is);
			Image image = ImageIO.read(is);
//			frame.setIconImage(image);
			if (Taskbar.getTaskbar().isSupported(Taskbar.Feature.ICON_IMAGE)) {
				Taskbar.getTaskbar().setIconImage(image);
			}
		} catch (IOException ex) {
			throw new RuntimeException(ex);
		}

		frame.setSize(new Dimension(0, 0));
		frame.setVisible(false);

	}

Replace Anonymous With Lambda io.github.volyx.Main.main.start.new Thread.new Runnable with () -> {while(true){tryThread.sleep(2_000); in method public main(args String[]) : void from class io.github.volyx.Main


	private static JFrame createFrame() {
		JFrame frame = new JFrame("RocksDB UI");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		try (InputStream is = Main.class.getClassLoader().getResourceAsStream("doc.png");) {
			Objects.requireNonNull(is);
			Image image = ImageIO.read(is);
//			frame.setIconImage(image);
			Taskbar.getTaskbar().setIconImage(image);
		} catch (IOException ex) {
			throw new RuntimeException(ex);
		}

		frame.setSize(new Dimension(600, 450));

//		Application.getApplication().setDockIconImage(new ImageIcon(getClass().getResource("/logo.png")).getImage());
//		Application.getApplication().setDockIconImage(
//				new ImageIcon("app.png").getImage());
		return frame;
	}

	private static JFrame createFrame() {
		JFrame frame = new JFrame("Rockssb UI");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		try {
			final URL url = Main.class.getClassLoader().getResource("doc.png");
			Objects.requireNonNull(url);
			File pathToFile = new File(url.getPath());
			Image image = ImageIO.read(pathToFile);
//			frame.setIconImage(image);
			Taskbar.getTaskbar().setIconImage(image);
		} catch (IOException ex) {
			ex.printStackTrace();
		}

		frame.setSize(new Dimension(600, 450));

//		Application.getApplication().setDockIconImage(new ImageIcon(getClass().getResource("/logo.png")).getImage());
//		Application.getApplication().setDockIconImage(
//				new ImageIcon("app.png").getImage());
		return frame;
	}

Try With Resources try(InputStream is=Main.class.getClassLoader().getResourceAsStream("doc.png")) in method private createFrame() : JFrame from class io.github.volyx.Main


    public void warnWindow(String warnMSG, int width, int height) {
        final JFrame warn = new JFrame();
        JLabel label = new JLabel(warnMSG);
        JButton ok = new JButton("Ok");
        Panel p1 = new Panel();
        Panel p2 = new Panel();
        p1.add(label);
        p2.add(ok);
        warn.setSize(width, height);
        warn.setLocation(500, 250);
        warn.add(p1, BorderLayout.NORTH);
        warn.add(p2, BorderLayout.SOUTH);
        warn.setVisible(true);
        ok.addActionListener(e -> warn.dispose());
    }

    public void warnWindow(String warnMSG, int width, int height) {
        final JFrame warn = new JFrame();
        JLabel label = new JLabel(warnMSG);
        JButton ok = new JButton("Ok");
        Panel p1 = new Panel();
        Panel p2 = new Panel();
        p1.add(label);
        p2.add(ok);
        warn.setSize(width, height);
        warn.setLocation(500, 250);
        warn.add(p1, BorderLayout.NORTH);
        warn.add(p2, BorderLayout.SOUTH);
        warn.setVisible(true);
        ok.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                warn.dispose();
            }
        });
    }

Replace Anonymous With Lambda ca.laurentian.concluder.Concluder.warnWindow.addActionListener.new ActionListener with e -> warn.dispose() in method public warnWindow(warnMSG String, width int, height int) : void from class ca.laurentian.concluder.Concluder