    @Override
    public TestThread<ResourcePoolT, ProtocolBuilderNumeric> next() {
      return new TestThread<>() {

        @Override
        public void test() {

          Application<List<BigDecimal>, ProtocolBuilderNumeric> testApplication =
              root -> root.seq(seq -> {

                Pair<Matrix<DRes<SFixed>>, List<DRes<SFixed>>> data = logisticRegressionDataset(
                    seq);

                double[] guess = new double[]{0, 0};

                return new LogisticRegression(data.getFirst(), data.getSecond(), guess,
                    i -> 5.0 / (i + 35.0), 50).buildComputation(seq);
              }).seq((seq, b) -> {

                List<DRes<BigDecimal>> openB =
                    b.stream().map(bi -> FixedNumeric.using(seq).open(bi))
                        .collect(Collectors.toList());

                return () -> openB.stream().map(DRes::out).collect(Collectors.toList());
              });

          List<BigDecimal> output = runApplication(testApplication);
          assertEquals(-4.0778, output.get(0).doubleValue(), 0.2);
          assertEquals(1.5047, output.get(1).doubleValue(), 0.2);
        }
      };
    }

    @Override
    public TestThread<ResourcePoolT, ProtocolBuilderNumeric> next() {
      return new TestThread<ResourcePoolT, ProtocolBuilderNumeric>() {

        @Override
        public void test() throws Exception {

          Application<List<BigDecimal>, ProtocolBuilderNumeric> testApplication =
              root -> root.seq(seq -> {

                Pair<Matrix<DRes<SFixed>>, List<DRes<SFixed>>> data = logisticRegressionDataset(seq);

                double[] guess = new double[]{0, 0};

                return new LogisticRegression(data.getFirst(), data.getSecond(), guess,
                    i -> 5.0 / (i + 35.0), 50).buildComputation(seq);
              }).seq((seq, b) -> {

                List<DRes<BigDecimal>> openB =
                    b.stream().map(bi -> FixedNumeric.using(seq).open(bi)).collect(Collectors.toList());

                return () -> openB.stream().map(DRes::out).collect(Collectors.toList());
              });

          List<BigDecimal> output = runApplication(testApplication);
          assertEquals(-4.0778, output.get(0).doubleValue(), 0.2);
          assertEquals(1.5047, output.get(1).doubleValue(), 0.2);
        }
      };
    }

Replace Generic With Diamond TestThread<ResourcePoolT,ProtocolBuilderNumeric> with TestThread<> in method public next() : TestThread<ResourcePoolT,ProtocolBuilderNumeric> from class dk.alexandra.fresco.stat.LogRegTests.TestLogisticRegression


    @Override
    public TestThread<ResourcePoolT, ProtocolBuilderNumeric> next() {
      return new TestThread<>() {

        @Override
        public void test() {

          Application<List<BigDecimal>, ProtocolBuilderNumeric> testApplication = builder -> builder
              .seq(seq -> {

                List<SurvivalInfoDiscrete> input = survivalAnalysisDataset(seq, true);
                DRes<List<DRes<SReal>>> beta = new CoxGradientDiscrete(input,
                    List.of(seq.realNumeric().known(1))).buildComputation(seq);
                return beta;
              }).seq((seq, beta) -> {
                List<DRes<BigDecimal>> openBeta =
                    beta.stream().map(seq.realNumeric()::open)
                        .collect(Collectors.toList());
                return () ->
                    openBeta.stream().map(DRes::out).collect(Collectors.toList());
              });

          List<BigDecimal> output = runApplication(testApplication);
          assertEquals(-0.25862161094245983, output.get(0).doubleValue(), 0.001);
        }
      };
    }

    @Override
    public TestThread<ResourcePoolT, ProtocolBuilderNumeric> next() {
      return new TestThread<ResourcePoolT, ProtocolBuilderNumeric>() {

        @Override
        public void test() throws Exception {

          Application<List<BigDecimal>, ProtocolBuilderNumeric> testApplication =
              root -> root.seq(seq -> {
                Pair<Matrix<DRes<SReal>>, List<DRes<SReal>>> data = logisticRegressionDataset(seq);

                List<DRes<SReal>> initB = List.of(seq.realNumeric().known(-3.0),
                    seq.realNumeric().known(2.0));

                DRes<List<DRes<SReal>>> b =
                    new LogisticRegressionGD(data.getFirst(), data.getSecond(), 0.1, initB)
                        .buildComputation(seq);
                return b;
              }).seq((seq, b) -> {

                List<DRes<BigDecimal>> openB =
                    b.stream().map(bi -> seq.realNumeric().open(bi)).collect(Collectors.toList());

                return () -> openB.stream().map(DRes::out).collect(Collectors.toList());
              });

          double[] hours = new double[] {0.50, 0.75,1.00,1.25,1.50,1.75,1.75,2.00,2.25,2.50,2.75,3.00,3.25,3.50,4.00,4.25,4.50,4.75,5.00,5.50};
          double[] pass = new double[] {0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1};
          double rate = 0.1;

          List<BigDecimal> output = runApplication(testApplication);

          ToDoubleBiFunction<double[], Double> predict = (b,x) ->  1 / (1 + Math.exp(-b[0] - b[1] * x));

          double[] beta = new double[] {-3, 2};
          double[] score = new double[2];
          for (int i = 0; i < hours.length; i++) {
              score[0] += (predict.applyAsDouble(beta, hours[i]) - pass[i]);
              score[1] += (predict.applyAsDouble(beta, hours[i]) - pass[i]) * hours[i];
          }

          Assert.assertEquals(beta[0] - rate*score[0], output.get(0).doubleValue(), 0.001);
          Assert.assertEquals(beta[1] - rate*score[1], output.get(1).doubleValue(), 0.001);
        }
      };
    }

Replace Generic With Diamond TestThread<ResourcePoolT,ProtocolBuilderNumeric> with TestThread<> in method public next() : TestThread<ResourcePoolT,ProtocolBuilderNumeric> from class dk.alexandra.fresco.stat.SurvivalAnalysisTests.TestCoxGradient


    @Override
    public TestThread<ResourcePoolT, ProtocolBuilderNumeric> next() {
      return new TestThread<ResourcePoolT, ProtocolBuilderNumeric>() {

        @Override
        public void test() throws Exception {

          double[] hours = new double[] {0.50, 0.75,1.00,1.25,1.50,1.75,1.75,2.00,2.25,2.50,2.75,3.00,3.25,3.50,4.00,4.25,4.50,4.75,5.00,5.50};
          double[] pass = new double[] {0,0,0,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1};

          List<List<Double>> data = Arrays.stream(hours).boxed().map(List::of).collect(Collectors.toList());
          List<Double> e = Arrays.stream(pass).boxed().collect(Collectors.toList());

          Application<List<BigDecimal>, ProtocolBuilderNumeric> testApplication =
              root -> root.seq(seq -> {

                Matrix<DRes<SReal>> secretData = new Matrix<>(data.size(), data.get(0).size(),
                    i -> data.get(i).stream().map(BigDecimal::valueOf).map(seq.realNumeric()::known)
                        .collect(Collectors.toCollection(ArrayList::new)));

                List<DRes<SReal>> secretE =
                    e.stream().map(BigDecimal::valueOf).map(seq.realNumeric()::known).collect(Collectors.toList());

                double[] guess = new double[] {-3, 2};

                DRes<List<DRes<SReal>>> b =
                    new LogisticRegression(secretData, secretE, guess, i -> i < 10 ? 0.1 : 0.05, 20)
                        .buildComputation(seq);
                return b;
              }).seq((seq, b) -> {

                List<DRes<BigDecimal>> openB =
                    b.stream().map(bi -> seq.realNumeric().open(bi)).collect(Collectors.toList());

                return () -> openB.stream().map(DRes::out).collect(Collectors.toList());
              });

          List<BigDecimal> output = runApplication(testApplication);
          System.out.println(output);

        }
      };
    }


    @Override
    public TestThread<ResourcePoolT, ProtocolBuilderNumeric> next() {
      return new TestThread<>() {

        @Override
        public void test() {
          Application<List<BigDecimal>, ProtocolBuilderNumeric> testApplication = builder -> builder
              .seq(seq -> {

                List<SurvivalInfoDiscrete> input = survivalAnalysisDataset(seq);
                DRes<List<DRes<SReal>>> beta = new CoxRegression(input, 5, 0.1,
                    new double[]{1}).buildComputation(seq);
                return beta;
              }).seq((seq, beta) -> {
                List<DRes<BigDecimal>> openBeta =
                    beta.stream().map(seq.realNumeric()::open)
                        .collect(Collectors.toList());
                return () ->
                    openBeta.stream().map(DRes::out).collect(Collectors.toList());
              });

          List<BigDecimal> output = runApplication(testApplication);
          assertEquals(0.9610201322467578, output.get(0).doubleValue(), 0.001);
        }
      };
    }

Replace Generic With Diamond TestThread<ResourcePoolT,ProtocolBuilderNumeric> with TestThread<> in method public next() : TestThread<ResourcePoolT,ProtocolBuilderNumeric> from class dk.alexandra.fresco.stat.SurvivalAnalysisTests.TestCoxRegression


    public <T> int insertOne(T instance) {
        String query = QueryFactory.createInsertOneQuery(instance);
        int rowsAffected = 0;
        try (Connection con = ConnectionPool.getConnection(); Statement stmt = con.createStatement();){
            rowsAffected = stmt.executeUpdate(query);
        } catch (Exception e) {
            System.out.println(e);
        }

        System.out.println("Rows affected:" + rowsAffected);
        return rowsAffected;
    }

    public <T> int insertOne(T instance) {
        String query = QueryFactory.createInsertOneQuery(instance);
        int rowsAffected = 0;
        try {
            Connection con = ConnectionPool.getConnection();
            rowsAffected = con.createStatement().executeUpdate(query);
        } catch (Exception e) {
            System.out.println(e);
        }

        System.out.println("Rows affected:" + rowsAffected);
        return rowsAffected;
    }

Try With Resources try(Connection con=ConnectionPool.getConnection(); Statement stmt=con.createStatement()) in method public insertOne(instance T) : int from class MysqlCon


    public <T> void insertMultiple(List<T> itemList) {

        String query = QueryFactory.createInsertMultipleQuery(itemList, clz);
        int rowsAffected = 0;
        try (Connection con = ConnectionPool.getConnection()) {
            Statement stmt = con.createStatement();
            rowsAffected = stmt.executeUpdate(query);
        } catch (Exception e) {
            System.out.println(e);
        }
        System.out.println("Rows affected:" + rowsAffected);

    }

    public <T> void insertMultiple(List<T> itemList) {

        String query = QueryFactory.createInsertMultipleQuery(itemList, clz);
        int rowsAffected = 0;
        try {
            Statement stmt = con.createStatement();
            rowsAffected = stmt.executeUpdate(query);
        } catch (Exception e) {
            System.out.println(e);
        }
        System.out.println("Rows affected:" + rowsAffected);

    }

Try With Resources try(Connection con=ConnectionPool.getConnection()) in method public insertMultiple(itemList List<T>) : void from class MysqlCon


    public MysqlCon(Class<T> clz) {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
        this.clz = clz;
        try (Connection con = ConnectionPool.getConnection()) {
            DatabaseMetaData meta = con.getMetaData();
            if (!meta.getTables(null, null, clz.getSimpleName().toLowerCase(), new String[]{"TABLE"}).next()) {
                initTable();
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    public MysqlCon(Class<T> clz) {
        this.clz = clz;
        try {
            ConfigManager configs = new ConfigManager();
            Class.forName("com.mysql.cj.jdbc.Driver");
            con = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/" + configs.schemaName,
                    configs.username, configs.password);

            DatabaseMetaData meta = con.getMetaData();
            if (!meta.getTables(null, null, clz.getSimpleName().toLowerCase(), new String[]{"TABLE"}).next()) {
                initTable();
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

Try With Resources try(Connection con=ConnectionPool.getConnection()) in method public MysqlCon(clz Class<T>) from class MysqlCon


    public List<T> getByProperty(String propName, String propVal) {

        try (Connection con = ConnectionPool.getConnection()) {
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s WHERE %s = '%s'", clz.getSimpleName().toLowerCase(),propName.toLowerCase(),propVal.toLowerCase()));
            List<T> results = new ArrayList<>();
            while (rs.next()) {
                results.add(createSingleInstance(rs));
            }

            return results;
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }
        catch (Exception e) {
            System.out.println(e);
        }
        return null;
    }

    public List<T> getByProperty(String propName, String propVal) {

        try {
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s WHERE %s = '%s'", clz.getSimpleName().toLowerCase(),propName.toLowerCase(),propVal.toLowerCase()));
            List<T> results = new ArrayList<>();
            while (rs.next()) {
                results.add(createSingleInstance(rs));
            }

            return results;
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }
        catch (Exception e) {
            System.out.println(e);
        }
        return null;
    }

Try With Resources try(Connection con=ConnectionPool.getConnection()) in method public getByProperty(propName String, propVal String) : List<T> from class MysqlCon


    public T findOne(int id) {
        try (Connection con = ConnectionPool.getConnection()) {
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s WHERE id=%d", clz.getSimpleName().toLowerCase(), id));

            Constructor<T> constructor = clz.getConstructor(null);
            T clzInstance = constructor.newInstance();
            if (rs.next()) {
                fieldsAssignment(clzInstance, rs);
            } else {

            }

            return clzInstance;
        } catch (Exception e) {
            System.out.println(e);
        }
        return null;
    }

    public T findOne(int id) {
        try {
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s WHERE id=%d", clz.getSimpleName().toLowerCase(), id));

            Constructor<T> constructor = clz.getConstructor(null);
            T clzInstance = constructor.newInstance();
            if (rs.next()) {
                fieldsAssignment(clzInstance, rs);
            } else {

            }

            return clzInstance;
        } catch (Exception e) {
            System.out.println(e);
        }
        return null;
    }

Try With Resources try(Connection con=ConnectionPool.getConnection()) in method public findOne(id int) : T from class MysqlCon


    public List<T> findAll() {

        try (Connection con = ConnectionPool.getConnection()) {
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s", clz.getSimpleName().toLowerCase()));
            List<T> results = new ArrayList<>();
            while (rs.next()) {
                results.add(createSingleInstance(rs));
            }

            return results;
        } catch (Exception e) {
            System.out.println(e);
        }
        return null;
    }

    public List<T> findAll() {

        try {
            Statement stmt = con.createStatement();
            ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s", clz.getSimpleName().toLowerCase()));
            List<T> results = new ArrayList<>();
            while (rs.next()) {
                results.add(createSingleInstance(rs));
            }

            return results;
        } catch (Exception e) {
            System.out.println(e);
        }
        return null;
    }

Try With Resources try(Connection con=ConnectionPool.getConnection()) in method public findAll() : List<T> from class MysqlCon


    public void updateSingleProperty(int id,String item,String newValue) {
        try (Connection con = ConnectionPool.getConnection()) {
            Statement stmt = con.createStatement();
            stmt.executeUpdate(String.format("UPDATE %s SET %s = %s WHERE id = %d;", clz.getSimpleName().toLowerCase(),item,newValue, id));
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    public void updateSingleProperty(int id,String item,String newValue) {
        try {
            Statement stmt = con.createStatement();
            stmt.executeUpdate(String.format("UPDATE %s SET %s = %s WHERE id = %d;", clz.getSimpleName().toLowerCase(),item,newValue, id));
        } catch (Exception e) {
            System.out.println(e);
        }
    }

Try With Resources try(Connection con=ConnectionPool.getConnection()) in method public updateSingleProperty(id int, item String, newValue String) : void from class MysqlCon


    public void updateRow(int id,T object) {
        try (Connection con = ConnectionPool.getConnection()){
            Statement stmt = con.createStatement();
            StringBuilder query= new StringBuilder(String.format("UPDATE %s SET ", clz.getSimpleName().toLowerCase()));
            Field[] fields = clz.getDeclaredFields();
            for (Field field:
                    fields) {
                query.append(field.getName());
                query.append(" = ");
                query.append(handleValue(field.get(object)));
                query.append(" , ");
            }
            query.delete(query.length()-3, query.length()-1);
            query.append(String.format("WHERE id = %d;",id));
            System.out.println(query);
            stmt.executeUpdate(String.valueOf(query));

        } catch (Exception e) {
            System.out.println(e);
        }
    }

    public void updateRow(int id,T object) {
        try {
            Statement stmt = con.createStatement();
            StringBuilder query= new StringBuilder(String.format("UPDATE %s SET ", clz.getSimpleName().toLowerCase()));
            Field[] fields = clz.getDeclaredFields();
            for (Field field:
                    fields) {
                query.append(field.getName());
                query.append(" = ");
                query.append(handleValue(field.get(object)));
                query.append(" , ");
            }
            query.delete(query.length()-3, query.length()-1);
            query.append(String.format("WHERE id = %d;",id));
            System.out.println(query);
            stmt.executeUpdate(String.valueOf(query));

        } catch (Exception e) {
            System.out.println(e);
        }
    }

Try With Resources try(Connection con=ConnectionPool.getConnection()) in method public updateRow(id int, object T) : void from class MysqlCon


    public void singleItemDeletionByProperty(String property,String value) {
        try (Connection con = ConnectionPool.getConnection()) {
            Statement stmt = con.createStatement();
            stmt.executeUpdate(String.format("DELETE FROM %s WHERE %s=%s;", clz.getSimpleName().toLowerCase(),property, value));
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    public void singleItemDeletionByProperty(String property,String value) {
        try {
            Statement stmt = con.createStatement();
            stmt.executeUpdate(String.format("DELETE FROM %s WHERE %s=%s;", clz.getSimpleName().toLowerCase(),property, value));
        } catch (Exception e) {
            System.out.println(e);
        }
    }

Try With Resources try(Connection con=ConnectionPool.getConnection()) in method public singleItemDeletionByProperty(property String, value String) : void from class MysqlCon


    private void initializeTableColumns() {
        annotationNameColumn.setCellFactory(param -> new TableCell<>() {
            @Override
            public void updateItem(String item, boolean empty) {
                super.updateItem(item, empty);
                setText(item);
                setGraphic(null);
            }
        });

        truePosColumn.setGraphic(getHeaderGraphic(ColumnType.TP));
        truePosColumn.setText(null);

        falsePosColumn.setGraphic(getHeaderGraphic(ColumnType.FP));
        falsePosColumn.setText(null);

        falseNegColumn.setGraphic(getHeaderGraphic(ColumnType.FN));
        falseNegColumn.setText(null);
    }

    private void initializeTableColumns() {
        annotationNameColumn.setCellFactory(param -> new TableCell<AnnotationType, String>() {
            @Override
            public void updateItem(String item, boolean empty) {
                super.updateItem(item, empty);
                setText(item);
                setGraphic(null);
            }
        });

        truePosColumn.setGraphic(getHeaderGraphic(ColumnType.TP));
        truePosColumn.setText(null);

        falsePosColumn.setGraphic(getHeaderGraphic(ColumnType.FP));
        falsePosColumn.setText(null);

        falseNegColumn.setGraphic(getHeaderGraphic(ColumnType.FN));
        falseNegColumn.setText(null);
    }

Replace Generic With Diamond TableCell<AnnotationType,String> with TableCell<> in method private initializeTableColumns() : void from class com.clinacuity.acv.controls.ViewControls


    public static void main(String[] args) {

        try (FinderHelper helper = new FinderHelper(getConfig(), Locale.US)) {

            // Start with accession number
            final String accessionNumber = padNumber(ACCESSION_NUMBER_FORMAT, "42");

            final String modality = "OT";
            Date startDate = null;
            Date endDate = null;

            helper.findStudies(accessionNumber, modality, startDate, endDate, studyInstanceUID -> {
                helper.findSeries(studyInstanceUID, modality, (seriesInstanceUID, availability) -> {
                    //////////////////////////////////////////////////////////////////////////////////////
                    // May run multiple times!
                    System.out.printf("Accession number: %s  modality: %s%n", accessionNumber, modality);
                    System.out.printf("  StudyInstanceUID: %s%n", studyInstanceUID);
                    System.out.printf("  SeriesInstanceUID: %s  availability: %s%n", seriesInstanceUID, availability);
                    //////////////////////////////////////////////////////////////////////////////////////
                });
            });
        }
        catch (Throwable t) {
            System.err.printf("Could not operate: %s%n", t.getMessage());
        }
    }

    public static void main(String[] args) {

        final FinderHelper controller[] = { null };
        try {
            controller[0] = new FinderHelper(getConfig(), Locale.US);

            // Start with accession number
            final String accessionNumber = padNumber(ACCESSION_NUMBER_FORMAT, "42");

            final String modality = "OT";
            Date startDate = null;
            Date endDate = null;

            controller[0].findStudies(accessionNumber, modality, startDate, endDate, studyInstanceUID -> {
                controller[0].findSeries(studyInstanceUID, modality, (seriesInstanceUID, availability) -> {
                    //////////////////////////////////////////////////////////////////////////////////////
                    // May run multiple times!
                    System.out.printf("Accession number: %s  modality: %s%n", accessionNumber, modality);
                    System.out.printf("  StudyInstanceUID: %s%n", studyInstanceUID);
                    System.out.printf("  SeriesInstanceUID: %s  availability: %s%n", seriesInstanceUID, availability);
                    //////////////////////////////////////////////////////////////////////////////////////
                });
            });
        }
        catch (Throwable t) {
            System.err.printf("Could not operate: %s%n", t.getMessage());
        }
        finally {
            if (null != controller[0])
                controller[0].shutdown();
        }
    }

Try With Resources try(FinderHelper helper=new FinderHelper(getConfig(),Locale.US)) in method public main(args String[]) : void from class examples.Application


    @Test
    public void testPing() {
        System.out.println("---");

        final Properties dicomConfig = new Properties();

        // SCU / client-side configuration
        dicomConfig.setProperty("local-scu-application-entity", "MY_SCU");
        dicomConfig.setProperty("local-scu-modality-type", "OT");

        // SCP / client-side configuration. This configuration must match the
        // remote SCP configuration below -- otherwise the SCU will not be able
        // to connect back to the (local) SCP.
        dicomConfig.setProperty("local-scp-application-entity", "MY_SCP");
        dicomConfig.setProperty("local-scp-host", "localhost");
        dicomConfig.setProperty("local-scp-port", "4101");

        dicomConfig.setProperty("storage-directory", "./STORAGE");

        // The local SCP accepts connections from these application entities
        dicomConfig.setProperty("accepted-calling-aets", "MY_SCU,REMOTE_SCP,SOME_PACS");

        // Remote SCP (which is actually same as local SCP :) as seen from the SCU
        dicomConfig.setProperty("remote-application-entity", "MY_SCP");
        dicomConfig.setProperty("remote-host", "localhost");
        dicomConfig.setProperty("remote-port", "4101");

        try (Controller controller = new Controller(dicomConfig)) {
            assertTrue(controller.ping());
            System.out.println("PING!");
        }
        catch (Throwable t) {
            fail(t.getMessage());
        }
    }

    @Test
    public void testPing() {
        System.out.println("---");

        final Properties dicomConfig = new Properties();

        // SCU / client-side configuration
        dicomConfig.setProperty("local-scu-application-entity", "MY_SCU");
        dicomConfig.setProperty("local-scu-modality-type", "OT");

        // SCP / client-side configuration. This configuration must match the
        // remote SCP configuration below -- otherwise the SCU will not be able
        // to connect back to the (local) SCP.
        dicomConfig.setProperty("local-scp-application-entity", "MY_SCP");
        dicomConfig.setProperty("local-scp-host", "localhost");
        dicomConfig.setProperty("local-scp-port", "4101");

        dicomConfig.setProperty("storage-directory", "./STORAGE");

        // The local SCP accepts connections from these application entities
        dicomConfig.setProperty("accepted-calling-aets", "MY_SCU,REMOTE_SCP,SOME_PACS");

        // Remote SCP (which is actually same as local SCP :) as seen from the SCU
        dicomConfig.setProperty("remote-application-entity", "MY_SCP");
        dicomConfig.setProperty("remote-host", "localhost");
        dicomConfig.setProperty("remote-port", "4101");

        Controller controller = null;
        try {
            controller = new Controller(dicomConfig);
            assertTrue(controller.ping());

            System.out.println("PING!");
        }
        catch (Throwable t) {
            fail(t.getMessage());
        }
        finally {
            if (null != controller)
                controller.shutdown();
        }
    }

Try With Resources try(Controller controller=new Controller(dicomConfig)) in method public testPing() : void from class org.gautelis.dicom.PingTest


    public void find(
            final Consumer<Attributes> preparationBlock,
            final Consumer<Attributes> resultHandlerBlock
    ) {
        try {
            // Prepare search keys
            Attributes keys = new Attributes();
            preparationBlock.accept(keys);

            // Search
            try (DicomAssociation association = node.open()) {
                association.query(UID.StudyRootQueryRetrieveInformationModelFind, keys, resultHandlerBlock);
            }
        } catch (ConnectException ce) {
            String info = "Failed to connect to PACS: ";
            Throwable cause = DicomScuNode.getBaseCause(ce);
            info += cause.getMessage();
            log.warn(info);

            throw new RuntimeException(info, ce);

        } catch (Throwable t) {
            String info = "Failed to C-FIND: ";
            Throwable cause = DicomScuNode.getBaseCause(t);
            info += cause.getMessage();
            log.warn(info, t);

            throw new RuntimeException(info, t);
        }
    }

    public void find(
            final Consumer<Attributes> preparationBlock,
            final Consumer<Attributes> resultHandlerBlock
    ) {
        try {
            // Prepare search keys
            Attributes keys = new Attributes();
            preparationBlock.accept(keys);

            try {
                // Search
                node.open();
                node.query(UID.StudyRootQueryRetrieveInformationModelFind, keys, resultHandlerBlock);

            } finally {
                node.close();
            }
        } catch (ConnectException ce) {
            String info = "Failed to connect to PACS: ";
            Throwable cause = DicomScuNode.getBaseCause(ce);
            info += cause.getMessage();
            log.warn(info);

            throw new RuntimeException(info, ce);

        } catch (Throwable t) {
            String info = "Failed to C-FIND: ";
            Throwable cause = DicomScuNode.getBaseCause(t);
            info += cause.getMessage();
            log.warn(info, t);

            throw new RuntimeException(info, t);
        }
    }

Try With Resources try(DicomAssociation association=node.open()) in method public find(preparationBlock Consumer<Attributes>, resultHandlerBlock Consumer<Attributes>) : void from class org.gautelis.dicom.behaviours.FinderBehaviour


    public boolean verify() {
        try {
            try (DicomAssociation association = scuNode.open()) {
                return association.echo();
            }
        } catch (Throwable t) {
            String info = "Failed to verify connection to SCP: " + t.getMessage();
            log.warn(info, t);
        }
        return false;
    }

    public boolean verify() {
        try {
            try {
                scuNode.open();
                return scuNode.echo();

            } finally {
                scuNode.close();
            }
        } catch (Throwable t) {
            String info = "Failed to verify connection to SCP: " + t.getMessage();
            log.warn(info, t);
        }
        return false;
    }

Try With Resources try(DicomAssociation association=scuNode.open()) in method public verify() : boolean from class org.gautelis.dicom.behaviours.VerificationBehaviour


    /**
     * Method to call when the current document changed.
     *
     * @param   aNewCurrentDocument The new current document.
     */
    private void handleCurrentDocumentChanged(File aNewCurrentDocument) {

        if (aNewCurrentDocument != null) {

            try {

                Class<? extends DisplayFileNodeAssembler> tmpFileNodeAssemblerClass =
                        NODE_ASSEMBLER_BY_FILETYPE.get(FileUtil.getFiletype(aNewCurrentDocument));
                Node tmpFileDisplayNode = tmpFileNodeAssemblerClass.getDeclaredConstructor().newInstance()
                        .assemble(aNewCurrentDocument, displayFilePane.getPrefWidth(), displayFilePane.getPrefHeight());

                Platform.runLater(() -> displayFilePane.getChildren().setAll(tmpFileDisplayNode));
            }
            catch (Exception e) {

                throw (new RuntimeException("Could not assemble display file pane: ".concat(e.getMessage())));
            }
        }
        else {

            displayFilePane.getChildren().clear();
        }
    }

    /**
     * Method to call when the current document changed.
     *
     * @param   aNewCurrentDocument The new current document.
     */
    private void handleCurrentDocumentChanged(File aNewCurrentDocument) {

        if (aNewCurrentDocument != null) {

            try {

                Class<? extends DisplayFileNodeAssembler> tmpFileNodeAssemblerClass =
                        NODE_ASSEMBLER_BY_FILETYPE.get(FileUtil.getFiletype(aNewCurrentDocument));
                Node tmpFileDisplayNode = tmpFileNodeAssemblerClass.getDeclaredConstructor().newInstance()
                        .assemble(aNewCurrentDocument, displayFilePane.getPrefWidth(), displayFilePane.getPrefHeight());

                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        displayFilePane.getChildren().setAll(tmpFileDisplayNode);
                    }
                });
            }
            catch (Exception e) {

                throw (new RuntimeException("Could not assemble display file pane: ".concat(e.getMessage())));
            }
        }
        else {

            displayFilePane.getChildren().clear();
        }
    }

Replace Anonymous With Lambda com.sophisticatedapps.archiving.documentarchiver.controller.DisplayFilePaneController.handleCurrentDocumentChanged.runLater.new Runnable with () -> displayFilePane.getChildren().setAll(tmpFileDisplayNode) in method private handleCurrentDocumentChanged(aNewCurrentDocument File) : void from class com.sophisticatedapps.archiving.documentarchiver.controller.DisplayFilePaneController


    public void asyncSend(final Object message) {
        new Thread(() -> send(message)).start();
    }

    public void asyncSend(final Object message) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                send(message);
            }
        }).start();
    }

Replace Anonymous With Lambda it.polimi.ingsw.server.SocketConnection.asyncSend.start.new Thread.new Runnable with () -> send(message) in method public asyncSend(message Object) : void from class it.polimi.ingsw.server.SocketConnection


    public Thread asyncReadFromSocket(ObjectInputStream socketIn) {

        Thread t = new Thread(() -> {

            try {
                while(isActive()) {
                    Object inputObject = socketIn.readObject();

                    if(inputObject instanceof String) {
                        ui.showMessage((String)inputObject);
                        if(inputObject.equals(Messages.gameOver)) {
                            setActive(false);
                        }

                    } else if (inputObject instanceof BoardView) {
                        ui.showBoard((BoardView)inputObject);

                    } else if(inputObject instanceof String[]) {
                        for(String s : (String[])inputObject) {
                            ui.showMessage(s);
                        }
                    } else if(inputObject instanceof ArrayList){  /* currentGodList */
                        ArrayList nameList = (ArrayList) inputObject;
                        if(nameList.size() != 0 && nameList.get(0) instanceof String){
                            for (Object o : nameList){
                                String s = (String) o;
                                ui.showMessage(s);
                            }
                        }
                    } else if(inputObject instanceof Operation){
                        opReceived = true;  /* ricevuto un Operation */
                        Operation operation = (Operation)inputObject;
                        if(operation.getType() == 0){
                            ui.showMessage(Messages.Place + Messages.Operation);
                        }else  if(operation.getType() == 1){
                            ui.showMessage(Messages.Move + Messages.Operation);
                        }else{
                            ui.showMessage(Messages.Build + Messages.Operation);
                        }
                    }else if(inputObject instanceof GameMessage){
                        gmReceived = true;  /* ricevuto un GameMessage */
                        gMessage = (GameMessage)inputObject;
                        ui.showMessage(gMessage.getMessage());
                    }
                    else {
                        throw new IllegalArgumentException();
                    }
                }
            } catch (Exception e) {
                setActive(false);
            }
        });

        t.start();
        return t;
    }

    public Thread asyncReadFromSocket(ObjectInputStream socketIn) {

        Thread t = new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    while(isActive()) {
                        Object inputObject = socketIn.readObject();

                        if(inputObject instanceof String) {
                            ui.showMessage((String)inputObject);
                            if(inputObject.equals(Messages.gameOver)) {
                                setActive(false);
                            }

                        } else if (inputObject instanceof BoardView) {
                            ui.showBoard((BoardView)inputObject);

                        } else if(inputObject instanceof String[]) {
                            for(String s : (String[])inputObject) {
                                ui.showMessage(s);
                            }
                        } else if(inputObject instanceof ArrayList){  /* currentGodList */
                            ArrayList nameList = (ArrayList) inputObject;
                            if(nameList.size() != 0 && nameList.get(0) instanceof String){
                                for (Object o : nameList){
                                    String s = (String) o;
                                    ui.showMessage(s);
                                }
                            }
                        } else if(inputObject instanceof Operation){
                            opReceived = true;  /* ricevuto un Operation */
                            Operation operation = (Operation)inputObject;
                            if(operation.getType() == 0){
                                System.out.print(Messages.Place);
                            }else  if(operation.getType() == 1){
                                System.out.print(Messages.Move);
                            }else{
                                System.out.print(Messages.Build);
                            }
                            System.out.println(Messages.Operation);
                        }else if(inputObject instanceof GameMessage){
                            gmReceived = true;  /* ricevuto un GameMessage */
                            gMessage = (GameMessage)inputObject;
                            System.out.println(gMessage.getMessage());
                        }
                        else {
                            throw new IllegalArgumentException();
                        }
                    }
                } catch (Exception e) {
                    setActive(false);
                }
            }
        });

        t.start();
        return t;
    }

Replace Anonymous With Lambda it.polimi.ingsw.client.Client.asyncReadFromSocket.t.new Thread.new Runnable with () -> {trywhile(isActive()){Object inputObject=socketIn.readObject(); in method public asyncReadFromSocket(socketIn ObjectInputStream) : Thread from class it.polimi.ingsw.client.Client


    public Thread asyncWriteToSocket(final PrintWriter socketOut) {

        Thread t = new Thread(() -> {

            try {
                while(isActive()) {
                    String input = ui.getInput();
                    if(opReceived) {
                        try {  /* coordinate Tile */
                            String[] inputs = input.split(",");
                            int row = Integer.parseInt(inputs[0]);
                            int column = Integer.parseInt(inputs[1]);
                            if (row < 5 && column < 5 && row >= 0 && column >= 0) {
                                socketOut.println(input);
                                socketOut.flush();
                                opReceived = false;
                            }else {

                                ui.showMessage(Messages.tryAgain + "\n" + Messages.Operation);
                                //ui.showMessage(Messages.Operation);
                            }
                        } catch (Exception e) {
                            ui.showMessage(Messages.wrongArgument);
                        }

                    }else if (gmReceived) {  /* Risposta al messaggio */

                        input = input.toUpperCase();

                        if (gMessage.getMessage().equals(Messages.Worker)) {
                            try {  /* indice worker o 0 o 1 */
                                int index = Integer.parseInt(input);
                                if (index == 0 || index == 1) {
                                    socketOut.println(input);
                                    socketOut.flush();
                                    gmReceived = false;
                                    gMessage = null;
                                } else {
                                    ui.showMessage(Messages.tryAgain + "\n" + gMessage.getMessage());
                                    //ui.showMessage(gMessage.getMessage());
                                }
                            } catch (IllegalArgumentException e) {
                                ui.showMessage(Messages.wrongArgument);
                            }
                        }else if((gMessage.getMessage().equals(Messages.Atlas)) && (input.equals("BLOCK") || input.equals("DOME"))
                        || (gMessage.getMessage().equals(Messages.Prometheus)) && (input.equals("MOVE")  || input.equals("BUILD"))
                        || !(gMessage.getMessage().equals(Messages.Atlas)) && !(gMessage.getMessage().equals(Messages.Prometheus))
                                && (input.equals("YES") || input.equals("NO"))){  /* problema yes or no */

                                socketOut.println(input);
                                socketOut.flush();
                                gmReceived = false;
                                gMessage = null;
                            }
                            /*
                        }else if(gMessage.getMessage().equals(Messages.Atlas)) {
                            if(input.equals("BLOCK") || input.equals("DOME")){
                                socketOut.println(input);
                                socketOut.flush();
                                gmReceived = false;
                                gMessage = null;
                            }else {
                                System.out.println("Riprova!\n" + gMessage.getMessage());
                            }
                        }else if(gMessage.getMessage().equals(Messages.Prometheus)){
                            if(input.equals("BLOCK") || input.equals("DOME")){
                                socketOut.println(input);
                                socketOut.flush();
                                gmReceived = false;
                                gMessage = null;
                            }else {
                                System.out.println("Riprova!\n" + gMessage.getMessage());
                            }
                        }else if(input.equals("YES") || input.equals("NO")){
                            socketOut.println(input);
                            socketOut.flush();
                            gmReceived = false;
                            gMessage = null;
                        }
                        */
                        else {
                            ui.showMessage(Messages.tryAgain + "\n" + gMessage.getMessage());
                            //ui.showMessage(gMessage.getMessage());
                        }
                    } else {
                        socketOut.println(input);
                        socketOut.flush();
                    }
                }
            } catch(Exception e) {
                setActive(false);
            }
        });

        t.start();
        return t;
    }

    public Thread asyncWriteToSocket(final PrintWriter socketOut) {

        Thread t = new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    while(isActive()) {
                        String input = ui.getInput();
                        if(opReceived) {
                            try {  /* coordinate Tile */
                                String[] inputs = input.split(",");
                                int row = Integer.parseInt(inputs[0]);
                                int column = Integer.parseInt(inputs[1]);
                                if (row < 5 && column < 5 && row >= 0 && column >= 0) {
                                    socketOut.println(input);
                                    socketOut.flush();
                                    opReceived = false;
                                }else {

                                    ui.showMessage(Messages.tryAgain + "\n" + Messages.Operation);
                                    //ui.showMessage(Messages.Operation);
                                }
                            } catch (Exception e) {
                                ui.showMessage(Messages.wrongArgument);
                            }

                        }else if (gmReceived) {  /* Risposta al messaggio */

                            input = input.toUpperCase();

                            if (gMessage.getMessage().equals(Messages.Worker)) {
                                try {  /* indice worker o 0 o 1 */
                                    int index = Integer.parseInt(input);
                                    if (index == 0 || index == 1) {
                                        socketOut.println(input);
                                        socketOut.flush();
                                        gmReceived = false;
                                        gMessage = null;
                                    } else {
                                        ui.showMessage(Messages.tryAgain + "\n" + gMessage.getMessage());
                                        //ui.showMessage(gMessage.getMessage());
                                    }
                                } catch (IllegalArgumentException e) {
                                    ui.showMessage(Messages.wrongArgument);
                                }
                            }else if((gMessage.getMessage().equals(Messages.Atlas)) && (input.equals("BLOCK") || input.equals("DOME"))
                            || (gMessage.getMessage().equals(Messages.Prometheus)) && (input.equals("MOVE")  || input.equals("BUILD"))
                            || !(gMessage.getMessage().equals(Messages.Atlas)) && !(gMessage.getMessage().equals(Messages.Prometheus))
                                    && (input.equals("YES") || input.equals("NO"))){  /* problema yes or no */

                                    socketOut.println(input);
                                    socketOut.flush();
                                    gmReceived = false;
                                    gMessage = null;
                                }
                                /*
                            }else if(gMessage.getMessage().equals(Messages.Atlas)) {
                                if(input.equals("BLOCK") || input.equals("DOME")){
                                    socketOut.println(input);
                                    socketOut.flush();
                                    gmReceived = false;
                                    gMessage = null;
                                }else {
                                    System.out.println("Riprova!\n" + gMessage.getMessage());
                                }
                            }else if(gMessage.getMessage().equals(Messages.Prometheus)){
                                if(input.equals("BLOCK") || input.equals("DOME")){
                                    socketOut.println(input);
                                    socketOut.flush();
                                    gmReceived = false;
                                    gMessage = null;
                                }else {
                                    System.out.println("Riprova!\n" + gMessage.getMessage());
                                }
                            }else if(input.equals("YES") || input.equals("NO")){
                                socketOut.println(input);
                                socketOut.flush();
                                gmReceived = false;
                                gMessage = null;
                            }
                            */
                            else {
                                ui.showMessage(Messages.tryAgain + "\n" + gMessage.getMessage());
                                //ui.showMessage(gMessage.getMessage());
                            }
                        } else {
                            socketOut.println(input);
                            socketOut.flush();
                        }
                    }
                } catch(Exception e) {
                    setActive(false);
                }
            }
        });

        t.start();
        return t;
    }

Replace Anonymous With Lambda it.polimi.ingsw.client.Client.asyncWriteToSocket.t.new Thread.new Runnable with () -> {trywhile(isActive()){String input=ui.getInput(); in method public asyncWriteToSocket(socketOut PrintWriter) : Thread from class it.polimi.ingsw.client.Client


    public void addFunctions(String prefix, Class<?> clazz) {
        List<Class<?>> classes = classesByPrefix.get(prefix);
        if (classes == null) {
            classes = new ArrayList<>();
            classesByPrefix.put(prefix, classes);
        }
        classes.add(clazz);
    }

    public void addFunctions(String prefix, Class<?> clazz) {
        List<Class<?>> classes = classesByPrefix.get(prefix);
        if (classes == null) {
            classes = new ArrayList<Class<?>>();
            classesByPrefix.put(prefix, classes);
        }
        classes.add(clazz);
    }

Replace Generic With Diamond ArrayList<Class<?>> with ArrayList<> in method public addFunctions(prefix String, clazz Class<?>) : void from class org.faceletslite.imp.DefaultConfiguration


    @Override
    public Map<String, Facelet> getCache() {
        return new ConcurrentHashMap<>();
    }

    @Override
    public Map<String, Facelet> getCache() {
        return new ConcurrentHashMap<String, Facelet>();
    }

Replace Generic With Diamond ConcurrentHashMap<String,Facelet> with ConcurrentHashMap<> in method public getCache() : Map<String,Facelet> from class org.faceletslite.imp.DefaultConfiguration


	@Override
	public Method resolveFunction(String prefix, String name) {
		String key = prefix+":"+name;
		Method result = methodByPrefixAndName.get(key);
		if (result==null) {
			List<Class<?>> classes = classesByPrefix.get(prefix);
			if (classes==null) {
				return null;
			}
			List<Method> matches = new ArrayList<>();
			for (Class<?> clazz: classes) {
				for (Method method: clazz.getMethods()) {
					if (method.getName().equals(name)) {
						matches.add(method);
					}
				}
			}
			if (matches.size()>1) {
				throw new RuntimeException("found multiple methods '"+name+"' for prefix "+prefix);
			}
			if (matches.size()==0) {
				return null;
			}
			result = matches.get(0);
			methodByPrefixAndName.put(key, result);
		}
		return result;
	}

	@Override
	public Method resolveFunction(String prefix, String name) {
		String key = prefix+":"+name;
		Method result = methodByPrefixAndName.get(key);
		if (result==null) {
			List<Class<?>> classes = classesByPrefix.get(prefix);
			if (classes==null) {
				return null;
			}
			List<Method> matches = new ArrayList<Method>();
			for (Class<?> clazz: classes) {
				for (Method method: clazz.getMethods()) {
					if (method.getName().equals(name)) {
						matches.add(method);
					}
				}
			}
			if (matches.size()>1) {
				throw new RuntimeException("found multiple methods '"+name+"' for prefix "+prefix);
			}
			if (matches.size()==0) {
				return null;
			}
			result = matches.get(0);
			methodByPrefixAndName.put(key, result);
		}
		return result;
	}

Replace Generic With Diamond ArrayList<Method> with ArrayList<> in method public resolveFunction(prefix String, name String) : Method from class org.faceletslite.imp.FunctionMapperImp


    @Test
    public void testWhenWithUndefinedBoolean() {
        Map<String, Object> context = new HashMap<>();
        checkAgainstExpectedOutput("when2", context);
    }

	@Test
	public void testWhenWithUndefinedBoolean() {
		Map<String, Object> context = new HashMap<String, Object>();
		checkAgainstExpectedOutput("when2", context);
	}

Replace Generic With Diamond HashMap<String,Object> with HashMap<> in method public testWhenWithUndefinedBoolean() : void from class org.faceletslite.test.FaceletTest


	private void jbInit() throws Exception
	{
		jLabel1.setText(res.getString("CONFIG_FILE_LBL"));
		this.setLayout(flowLayout1);
		flowLayout1.setAlignment(FlowLayout.LEFT);
		tfPath.setColumns(30);
		btnBrowse.setText("...");
		btnBrowse.addActionListener((ActionEvent e) ->
    {
      btnBrowse_actionPerformed(e);
    });
		this.add(jLabel1);
		this.add(tfPath);
		this.add(btnBrowse);
	}

	private void jbInit() throws Exception
	{
		jLabel1.setText(res.getString("CONFIG_FILE_LBL"));
		this.setLayout(flowLayout1);
		flowLayout1.setAlignment(FlowLayout.LEFT);
		tfPath.setColumns(30);
		btnBrowse.setText("...");
		btnBrowse.addActionListener(new ActionListener()
		{
      @Override
			public void actionPerformed(ActionEvent e)
			{
				btnBrowse_actionPerformed(e);
			}
		});
		this.add(jLabel1);
		this.add(tfPath);
		this.add(btnBrowse);
	}

Replace Anonymous With Lambda lh.worldclock.ConfigPanel.jbInit.addActionListener.new ActionListener with (e) -> {btnBrowse_actionPerformed(e); in method private jbInit() : void from class lh.worldclock.ConfigPanel


  public EditorView(SingleFrameApplication app)
  {
    super(app);

    initComponents();

    // status bar initialization - message timeout, idle icon and busy animation, etc
    ResourceMap resourceMap = getResourceMap();
    int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
    messageTimer = new Timer(messageTimeout, (ActionEvent e) ->
    {
      statusMessageLabel.setText("");
    });
    messageTimer.setRepeats(false);
    int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
    for (int i = 0; i < busyIcons.length; i++)
    {
      busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
    }
    busyIconTimer = new Timer(busyAnimationRate, (ActionEvent e) ->
    {
      busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
      statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
    });
    idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);

    // connecting action tasks to status bar via TaskMonitor
    TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
    taskMonitor.addPropertyChangeListener((java.beans.PropertyChangeEvent evt) ->
    {
      String propertyName = evt.getPropertyName();
      switch (propertyName)
      {
        case "started":
          if (!busyIconTimer.isRunning())
          {
            statusAnimationLabel.setIcon(busyIcons[0]);
            busyIconIndex = 0;
            busyIconTimer.start();
          }
          progressBar.setVisible(true);
          progressBar.setIndeterminate(true);
          break;
        case "done":
          busyIconTimer.stop();
          statusAnimationLabel.setIcon(idleIcon);
          progressBar.setVisible(false);
          progressBar.setValue(0);
          break;
        case "message":
          String text = (String) (evt.getNewValue());
          statusMessageLabel.setText((text == null) ? "" : text);
          messageTimer.restart();
          break;
        case "progress":
          int value = (Integer) (evt.getNewValue());
          progressBar.setVisible(true);
          progressBar.setIndeterminate(false);
          progressBar.setValue(value);
          break;
      }
    });
  }

  public EditorView(SingleFrameApplication app)
  {
    super(app);

    initComponents();

    // status bar initialization - message timeout, idle icon and busy animation, etc
    ResourceMap resourceMap = getResourceMap();
    int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
    messageTimer = new Timer(messageTimeout, new ActionListener()
    {

      @Override
      public void actionPerformed(ActionEvent e)
      {
        statusMessageLabel.setText("");
      }
    });
    messageTimer.setRepeats(false);
    int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
    for (int i = 0; i < busyIcons.length; i++)
    {
      busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
    }
    busyIconTimer = new Timer(busyAnimationRate, new ActionListener()
    {

      @Override
      public void actionPerformed(ActionEvent e)
      {
        busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
        statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
      }
    });
    idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);

    // connecting action tasks to status bar via TaskMonitor
    TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
    taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener()
    {

      @Override
      public void propertyChange(java.beans.PropertyChangeEvent evt)
      {
        String propertyName = evt.getPropertyName();
        switch (propertyName)
        {
          case "started":
            if (!busyIconTimer.isRunning())
            {
              statusAnimationLabel.setIcon(busyIcons[0]);
              busyIconIndex = 0;
              busyIconTimer.start();
            }
            progressBar.setVisible(true);
            progressBar.setIndeterminate(true);
            break;
          case "done":
            busyIconTimer.stop();
            statusAnimationLabel.setIcon(idleIcon);
            progressBar.setVisible(false);
            progressBar.setValue(0);
            break;
          case "message":
            String text = (String) (evt.getNewValue());
            statusMessageLabel.setText((text == null) ? "" : text);
            messageTimer.restart();
            break;
          case "progress":
            int value = (Integer) (evt.getNewValue());
            progressBar.setVisible(true);
            progressBar.setIndeterminate(false);
            progressBar.setValue(value);
            break;
        }
      }
    });
  }

Replace Anonymous With Lambda lh.worldclock.editor.EditorView.EditorView.addPropertyChangeListener.new java.beans.PropertyChangeListener with (e) -> {statusMessageLabel.setText(""); in method public EditorView(app SingleFrameApplication) from class lh.worldclock.editor.EditorView


    private void btnFindActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnFindActionPerformed
    {//GEN-HEADEREND:event_btnFindActionPerformed
      // TODO add your handling code here:
      setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      SwingUtilities.invokeLater(() ->
      {
        model.update(GeonamesWSWrapper.getGeonames(tfCity.getText(), (Integer) spMax.getValue()));
        setCursor(Cursor.getDefaultCursor());
      });

    }//GEN-LAST:event_btnFindActionPerformed

    private void btnFindActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnFindActionPerformed
    {//GEN-HEADEREND:event_btnFindActionPerformed
      // TODO add your handling code here:
      setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      SwingUtilities.invokeLater(new Runnable()
      {

        @Override
        public void run()
        {
          model.update(GeonamesWSWrapper.getGeonames(tfCity.getText(), (Integer) spMax.getValue()));
          setCursor(Cursor.getDefaultCursor());
        }
      });

    }//GEN-LAST:event_btnFindActionPerformed

Replace Anonymous With Lambda lh.worldclock.editor.FindCityPanelGeoname.btnFindActionPerformed.invokeLater.new Runnable with () -> {model.update(GeonamesWSWrapper.getGeonames(tfCity.getText(),(Integer)spMax.getValue())); in method private btnFindActionPerformed(evt ActionEvent) : void from class lh.worldclock.editor.FindCityPanelGeoname


    private void tfCityActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_tfCityActionPerformed
    {//GEN-HEADEREND:event_tfCityActionPerformed
      // TODO add your handling code here:
      SwingUtilities.invokeLater(() ->
      {
        btnFind.doClick();
      });

    }//GEN-LAST:event_tfCityActionPerformed

    private void tfCityActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_tfCityActionPerformed
    {//GEN-HEADEREND:event_tfCityActionPerformed
      // TODO add your handling code here:
      SwingUtilities.invokeLater(new Runnable()
      {

        @Override
        public void run()
        {
          btnFind.doClick();
        }
      });

    }//GEN-LAST:event_tfCityActionPerformed

Replace Anonymous With Lambda lh.worldclock.editor.FindCityPanelGeoname.tfCityActionPerformed.invokeLater.new Runnable with () -> {btnFind.doClick(); in method private tfCityActionPerformed(evt ActionEvent) : void from class lh.worldclock.editor.FindCityPanelGeoname


  /**
   * Initialise the screen saver. In particular load the cities and planes as well as creates the off screen images (also create the log file in ~/.saverbeans/)
   */
  @Override
  public void init()
  {
    // prevent multiple calls
    if (isLoading)
    {
      return;
    }
    isLoading = true;
    isLoaded = false;
    loading = res.getString("LOADING_BASE");

    isFullScreen = getContext().isFullScreen();
    LOGGER.log(Level.INFO, "isFullScreen: {0}", isFullScreen);
    if (!isFullScreen)
    {
      loading = res.getString("LOADING_BASE_SHORT");
      usingTemplate = res.getString("USING_TEMPLATE_SHORT");
      loadingTemplate = res.getString("LOADING_TEMPLATE_SHORT");
      frameTemplate = res.getString("FRAME_TEMPLATE_SHORT");
    }

    try
    {
      FileHandler fh = new FileHandler("%h/.worldclocksaver/worldclocksaver.log");
      LOGGER.addHandler(fh);
    }
    catch (IOException | SecurityException ex)
    {
      LOGGER.log(Level.FINE, ex.getMessage(), ex);
    }

    final ScreensaverSettings settings = getContext().getSettings();
    component = getContext().getComponent();

    // hack to make sure a mouse move ends the screen saver
    component.addMouseMotionListener(new MouseMotionAdapter()
    {
      @Override
      public void mouseMoved(MouseEvent e)
      {
        try
        {
          Robot r = new Robot();
          r.keyPress(KeyEvent.VK_DOWN);
        }
        catch (AWTException ex)
        {
          LOGGER.log(Level.FINE, ex.getMessage(), ex);
        }
      }

    });

    // run the main initialisation sequence in it own thread to make the screen saver look 'responsive'
    Runnable imagesCreatorRunnable = () ->
    {
      LOGGER.info("loading...");
      // init setting only when there is a valid screen
      while (width <= 0 || height <= 0)
      {
        width = component.getWidth();
        height = component.getHeight();

        try
        {
          Thread.sleep(25);
        }
        catch (InterruptedException ex)
        {
        }
      }

      // load the config file
      loadConfig(settings.getProperty("planespath"));

      // initialise the speed, sleep time used to delay the showing of the next frame (decrease CPU usage)
      String sspeed = settings.getProperty("speed");
      LOGGER.log(Level.INFO, "base speed = {0}", sspeed);
      if (sspeed != null && !sspeed.equals(""))
      {
        try
        {
          sleep = Integer.parseInt(sspeed);
        }
        catch (NumberFormatException ex)
        {
          LOGGER.log(Level.FINE, ex.getMessage(), ex);
        }
      }
      LOGGER.log(Level.INFO, "sleep = {0}ms", sleep);

      // random or sequencial planes
      if (null != settings.getProperty("random"))
      {
        isRandom = true;
      }
      LOGGER.log(Level.INFO, "isRandom: {0}", isRandom);

      // shows current plane and loading plane names
      if (null != settings.getProperty("info"))
      {
        isShowingPlaneInfo = true;
      }
      LOGGER.log(Level.INFO, "isShowingPlaneInfo: {0}", isShowingPlaneInfo);

      // shows debug info, time between 2 frames
      if (null != settings.getProperty("debug"))
      {
        isDebug = true;
      }
      LOGGER.log(Level.INFO, "isDebug: {0}", isDebug);

      // check for special 'effects'
      special = Special.NOTHING;
      if (null != settings.getProperty("xmas"))
      {
        special = Special.XMAS;
      }
      else if (null != settings.getProperty("stpaddy"))
      {
        special = Special.STPADDY;
      }
      else if (null != settings.getProperty("debugshadow"))
      {
        special = Special.DEBUG;
      }
      LOGGER.log(Level.INFO, "special: {0}", special.toString());

      // set the elements location on the board
      board.updateSizeValues(width, height);

      // board
      offScreenBoard = getContext().getComponent().createImage(width, height);
      offScreenBoardGraphics = offScreenBoard.getGraphics();
      board.updateTimeValues();
      board.paintComponent(offScreenBoardGraphics);
      // main
      offScreenStatic = getContext().getComponent().createImage(width, height);
      offScreenStaticGraphics = offScreenStatic.getGraphics();
      // painter
      offScreenPainter = getContext().getComponent().createImage(width, height);
      offScreenPainterGraphics = (Graphics2D)offScreenPainter.getGraphics();

      renderOffscreenStatic(offScreenStaticGraphics);
      offScreenPainterGraphics.drawImage(offScreenStatic, 0, 0, null);

      LOGGER.info("static board loaded");
      isLoaded = true;
      isLoading = false;

      Thread asynchRendererThread = new Thread(asynchRenderer);
      asynchRendererThread.start();
    };
    Thread staticBoardLoader = new Thread(imagesCreatorRunnable);
    staticBoardLoader.start();
  }

  /**
   * Initialise the screen saver. In particular load the cities and planes as well as creates the off screen images (also create the log file in ~/.saverbeans/)
   */
  @Override
  public void init()
  {
    // prevent multiple calls
    if (isLoading)
    {
      return;
    }
    isLoading = true;
    isLoaded = false;
    loading = res.getString("LOADING_BASE");

    isFullScreen = getContext().isFullScreen();
    LOGGER.log(Level.INFO, "isFullScreen: {0}", isFullScreen);
    if (!isFullScreen)
    {
      loading = res.getString("LOADING_BASE_SHORT");
      usingTemplate = res.getString("USING_TEMPLATE_SHORT");
      loadingTemplate = res.getString("LOADING_TEMPLATE_SHORT");
      frameTemplate = res.getString("FRAME_TEMPLATE_SHORT");
    }

    try
    {
      FileHandler fh = new FileHandler("%h/.worldclocksaver/worldclocksaver.log");
      LOGGER.addHandler(fh);
    }
    catch (IOException | SecurityException ex)
    {
      LOGGER.log(Level.FINE, ex.getMessage(), ex);
    }

    final ScreensaverSettings settings = getContext().getSettings();
    component = getContext().getComponent();

    // hack to make sure a mouse move ends the screen saver
    component.addMouseMotionListener(new MouseMotionAdapter()
    {
      @Override
      public void mouseMoved(MouseEvent e)
      {
        try
        {
          Robot r = new Robot();
          r.keyPress(KeyEvent.VK_DOWN);
        }
        catch (AWTException ex)
        {
          LOGGER.log(Level.FINE, ex.getMessage(), ex);
        }
      }

    });

    // run the main initialisation sequence in it own thread to make the screen saver look 'responsive'
    Runnable imagesCreatorRunnable = new Runnable()
    {
      @Override
      public void run()
      {
        LOGGER.info("loading...");
        // init setting only when there is a valid screen
        while (width <= 0 || height <= 0)
        {
          width = component.getWidth();
          height = component.getHeight();

          try
          {
            Thread.sleep(25);
          }
          catch (InterruptedException ex)
          {
          }
        }

        // load the config file
        loadConfig(settings.getProperty("planespath"));

        // initialise the speed, sleep time used to delay the showing of the next frame (decrease CPU usage)
        String sspeed = settings.getProperty("speed");
        LOGGER.log(Level.INFO, "base speed = {0}", sspeed);
        if (sspeed != null && !sspeed.equals(""))
        {
          try
          {
            sleep = Integer.parseInt(sspeed);
          }
          catch (NumberFormatException ex)
          {
            LOGGER.log(Level.FINE, ex.getMessage(), ex);
          }
        }
        LOGGER.log(Level.INFO, "sleep = {0}ms", sleep);

        // random or sequencial planes
        if (null != settings.getProperty("random"))
        {
          isRandom = true;
        }
        LOGGER.log(Level.INFO, "isRandom: {0}", isRandom);

        // shows current plane and loading plane names
        if (null != settings.getProperty("info"))
        {
          isShowingPlaneInfo = true;
        }
        LOGGER.log(Level.INFO, "isShowingPlaneInfo: {0}", isShowingPlaneInfo);

        // shows debug info, time between 2 frames
        if (null != settings.getProperty("debug"))
        {
          isDebug = true;
        }
        LOGGER.log(Level.INFO, "isDebug: {0}", isDebug);

        // check for special 'effects'
        special = Special.NOTHING;
        if (null != settings.getProperty("xmas"))
        {
          special = Special.XMAS;
        }
        else if (null != settings.getProperty("stpaddy"))
        {
          special = Special.STPADDY;
        }
        else if (null != settings.getProperty("debugshadow"))
        {
          special = Special.DEBUG;
        }
        LOGGER.log(Level.INFO, "special: {0}", special.toString());

        // set the elements location on the board
        board.updateSizeValues(width, height);

        // board
        offScreenBoard = getContext().getComponent().createImage(width, height);
        offScreenBoardGraphics = offScreenBoard.getGraphics();
        board.updateTimeValues();
        board.paintComponent(offScreenBoardGraphics);
        // main
        offScreenStatic = getContext().getComponent().createImage(width, height);
        offScreenStaticGraphics = offScreenStatic.getGraphics();
        // painter
        offScreenPainter = getContext().getComponent().createImage(width, height);
        offScreenPainterGraphics = (Graphics2D)offScreenPainter.getGraphics();

        renderOffscreenStatic(offScreenStaticGraphics);
        offScreenPainterGraphics.drawImage(offScreenStatic, 0, 0, null);

        LOGGER.info("static board loaded");
        isLoaded = true;
        isLoading = false;

        Thread asynchRendererThread = new Thread(asynchRenderer);
        asynchRendererThread.start();

      }
    };
    Thread staticBoardLoader = new Thread(imagesCreatorRunnable);
    staticBoardLoader.start();
  }

Replace Anonymous With Lambda lh.worldclock.saver.WorldClockSaver.init.imagesCreatorRunnable.new Runnable with () -> {LOGGER.info("loading..."); in method public init() : void from class lh.worldclock.saver.WorldClockSaver


  /**
   * Moves the current plane, get the next plane once the current plane has moved off screen, loading the next one if needed
   */
  private void move()
  {
    Avion nextPlane = avion; // next plane to be shown, unless it need to be changed (first time or moved offscreen) it is set to the current plane
    if (nextPlane == null) // planes null, get a plane
    {
      nextPlane = getNextPlane();
    }
    else
    {
      if (!nextPlane.isShown(width, height)) // if the plane is no longer shown then get the next one
      {
        nextPlane = getNextPlane();
      }
    }

    // if the next plane is null, no point moving it
    if (nextPlane != null)
    {
      // check if the image of the next plane is loaded,
      // if not checks if it can load it,
      // if it can then load it in a separate thread to avoid (seriously) delaying the current frame display
      if (!nextPlane.isLoaded())
      {
        if (loadingPlane == null)
        {
          loadingPlane = nextPlane;
          new Thread(() ->
          {
            LOGGER.log(Level.INFO, "loading {0}", loadingPlane.getName());
            loadingPlane.loadImage(width, height);
            LOGGER.log(Level.INFO, "loaded {0}", loadingPlane.getName());
            loadingPlane = null;
            ++nbLoaded;
          }).start();
        }
      }

      // if no plane is loaded no need to move
      if (nbLoaded > 0)
      {
        // check if the next plane is loaded, if it isn't then tries to get a loaded one (checks for null as getNextPlane can return a null plane)
        while (nextPlane == null || !nextPlane.isLoaded())
        {
          nextPlane = getNextPlane();
          if (nextPlane != null)
          {
            if (nextPlane.isLoaded())
            {
              LOGGER.log(Level.INFO, "using avion = {0}", nextPlane.getName());
            }
            else
            {
              LOGGER.log(Level.INFO, "avion not loaded = {0}", nextPlane.getName());
            }
          }
        }

        // a plane is loaded, set it as the current plane
        avion = nextPlane;
        // if the current plane is not shown then initialise it position so that it is (shown)
        if (!avion.isShown(width, height))
        {
          LOGGER.log(Level.INFO, "init pos avion = {0}", avion.getName());
          avion.initPos(width, height);
        }
        // last but not least: moves the plane
        avion.move();
      } // EO nb planes > 0
    } // EO plane's null
  }

  /**
   * Moves the current plane, get the next plane once the current plane has moved off screen, loading the next one if needed
   */
  private void move()
  {
    Avion nextPlane = avion; // next plane to be shown, unless it need to be changed (first time or moved offscreen) it is set to the current plane
    if (nextPlane == null) // planes null, get a plane
    {
      nextPlane = getNextPlane();
    }
    else
    {
      if (!nextPlane.isShown(width, height)) // if the plane is no longer shown then get the next one
      {
        nextPlane = getNextPlane();
      }
    }

    // if the next plane is null, no point moving it
    if (nextPlane != null)
    {
      // check if the image of the next plane is loaded,
      // if not checks if it can load it,
      // if it can then load it in a separate thread to avoid (seriously) delaying the current frame display
      if (!nextPlane.isLoaded())
      {
        if (loadingPlane == null)
        {
          loadingPlane = nextPlane;
          new Thread(new Runnable()
          {
            @Override
            public void run()
            {
              LOGGER.log(Level.INFO, "loading {0}", loadingPlane.getName());
              loadingPlane.loadImage(width, height);
              LOGGER.log(Level.INFO, "loaded {0}", loadingPlane.getName());
              loadingPlane = null;
              ++nbLoaded;
            }
          }).start();
        }
      }

      // if no plane is loaded no need to move
      if (nbLoaded > 0)
      {
        // check if the next plane is loaded, if it isn't then tries to get a loaded one (checks for null as getNextPlane can return a null plane)
        while (nextPlane == null || !nextPlane.isLoaded())
        {
          nextPlane = getNextPlane();
          if (nextPlane != null)
          {
            if (nextPlane.isLoaded())
            {
              LOGGER.log(Level.INFO, "using avion = {0}", nextPlane.getName());
            }
            else
            {
              LOGGER.log(Level.INFO, "avion not loaded = {0}", nextPlane.getName());
            }
          }
        }

        // a plane is loaded, set it as the current plane
        avion = nextPlane;
        // if the current plane is not shown then initialise it position so that it is (shown)
        if (!avion.isShown(width, height))
        {
          LOGGER.log(Level.INFO, "init pos avion = {0}", avion.getName());
          avion.initPos(width, height);
        }
        // last but not least: moves the plane
        avion.move();
      } // EO nb planes > 0
    } // EO plane's null
  }

Replace Anonymous With Lambda lh.worldclock.saver.WorldClockSaver.move.start.new Thread.new Runnable with () -> {LOGGER.log(Level.INFO,"loading {0}",loadingPlane.getName()); in method private move() : void from class lh.worldclock.saver.WorldClockSaver


	public void load() throws IOException
	{
		String homedir = System.getProperty("user.home");
		Path dir = Paths.get(homedir, dirname);
		Path propfile = dir.resolve(filename);
		Properties props = new Properties();
		try (InputStream is = Files.newInputStream(propfile))
		{
			props.load(is);
		}
		catch (FileNotFoundException ex)
		{
			// No reason to abort program loading for this.
			System.out.println("Property file was not found: " + ex.getMessage());
		}
		configpath = props.getProperty("configpath", null);
	}

	public void load() throws IOException
	{
		String homedir = System.getProperty("user.home");
		File dir = new File(homedir, dirname);
		File propfile = new File(dir, filename);
		Properties props = new Properties();
		FileInputStream fis = null;
		try
		{
			fis = new FileInputStream(propfile);
			props.load(fis);
		}
		catch (FileNotFoundException ex)
		{
			// No reason to abort program loading for this.
			System.out.println("Property file was not found: " + ex.getMessage());
		}
		finally
		{
			if (fis != null)
			{
				try
				{
					fis.close();
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
		}
		configpath = props.getProperty("configpath", null);
	}

Try With Resources try(InputStream is=Files.newInputStream(propfile)) in method public load() : void from class lh.worldclock.PropsManager


  private List<Geoname> doGetGeonames(String location, int max)
  {
    StringBuilder sb = new StringBuilder();
    sb.append(URL_BASE);
    try
    {
      sb.append(URLEncoder.encode(location, "UTF-8"));
    }
    catch (UnsupportedEncodingException ex)
    {
      Logger.getLogger(GeonamesWSWrapper.class.getName()).log(Level.FINE, null, ex);
      // try without encoding
      sb.append(location);
    }
    sb.append(URL_STYLE);
    sb.append(URL_MAX_ROWS);
    sb.append(Integer.toString(max));
    try(InputStream is = new URL(sb.toString()).openStream())
    {
      load(is);
    }
    catch (JAXBException | IOException ex)
    {
      Logger.getLogger(GeonamesWSWrapper.class.getName()).log(Level.FINE, null, ex);
    }
    return getGeonames();
  }

  private List<Geoname> doGetGeonames(String location, int max)
  {
    StringBuilder sb = new StringBuilder();
    sb.append(URL_BASE);
    try
    {
      sb.append(URLEncoder.encode(location, "UTF8"));
    }
    catch (UnsupportedEncodingException ex)
    {
      Logger.getLogger(GeonamesWSWrapper.class.getName()).log(Level.FINE, null, ex);
      // try without encoding
      sb.append(location);
    }
    sb.append(URL_STYLE);
    sb.append(URL_MAX_ROWS);
    sb.append(Integer.toString(max));
    try
    {
      load(new URL(sb.toString()).openStream());
    }
    catch (JAXBException | IOException ex)
    {
      Logger.getLogger(GeonamesWSWrapper.class.getName()).log(Level.FINE, null, ex);
    }
    return getGeonames();
  }

Try With Resources try(InputStream is=new URL(sb.toString()).openStream()) in method private doGetGeonames(location String, max int) : List<Geoname> from class lh.worldclock.geonames4lhwc.GeonamesWSWrapper


  private List<Geoname> doGetGeonames(String location, int max)
  {
    StringBuilder sb = new StringBuilder();
    sb.append(URL_BASE);
    try
    {
      sb.append(URLEncoder.encode(location, "UTF8"));
    }
    catch (UnsupportedEncodingException ex)
    {
      Logger.getLogger(GeonamesWSWrapper.class.getName()).log(Level.FINE, null, ex);
      // try without encoding
      sb.append(location);
    }
    sb.append(URL_STYLE);
    sb.append(URL_MAX_ROWS);
    sb.append(Integer.toString(max));
    try
    {
      load(new URL(sb.toString()).openStream());
    }
    catch (JAXBException | IOException ex)
    {
      Logger.getLogger(GeonamesWSWrapper.class.getName()).log(Level.FINE, null, ex);
    }
    return getGeonames();
  }

  private List<Geoname> doGetGeonames(String location, int max)
  {
    StringBuilder sb = new StringBuilder();
    sb.append(URL_BASE);
    try
    {
      sb.append(URLEncoder.encode(location, "UTF8"));
    }
    catch (UnsupportedEncodingException ex)
    {
      Logger.getLogger(GeonamesWSWrapper.class.getName()).log(Level.FINE, null, ex);
      // try without encoding
      sb.append(location);
    }
    sb.append(URL_STYLE);
    sb.append(URL_MAX_ROWS);
    sb.append(Integer.toString(max));
    try
    {
      load(new URL(sb.toString()).openStream());
    }
    catch (JAXBException ex)
    {
      Logger.getLogger(GeonamesWSWrapper.class.getName()).log(Level.FINE, null, ex);
    }
    catch (IOException ex)
    {
      Logger.getLogger(GeonamesWSWrapper.class.getName()).log(Level.FINE, null, ex);
    }
    return getGeonames();
  }

Merge Catch [catch(JAXBException ex), catch(IOException ex)] to catch(JAXBException|IOException ex) in method private doGetGeonames(location String, max int) : List<Geoname> from class lh.worldclock.geonames4lhwc.GeonamesWSWrapper


                @Override
                public void run() {
                    try ( BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
                        String line;
                        while ((line = reader.readLine()) != null) {
                            output.append(line).append("\n");
                        }
                    } catch (IOException e) {
                        Logger.getLogger(Clippy.class.getName()).log(Level.SEVERE, null, e);
                        placeOnClipboard("Your command ", cmdString, " caused exception ", e.getMessage());
                    }
                }

                @Override
                public void run() {
                    BufferedReader reader = null;
                    try {
                        reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                        String line;
                        while ((line = reader.readLine()) != null) {
                            output.append(line).append("\n");
                        }
                    } catch (IOException e) {
                        Logger.getLogger(Clippy.class.getName()).log(Level.SEVERE, null, e);
                    } finally {
                        if (reader != null) {
                            try {
                                reader.close();
                            } catch (IOException e) {
                                Logger.getLogger(Clippy.class.getName()).log(Level.SEVERE, null, e);
                            }
                        }
                    }
                }

Try With Resources try(BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream()))) in method public run() : void from class nl.wers.clippy.Clippy.handleCommand.outputThread.new Thread.new Runnable


    private  boolean isValidURL(String url) {
        try {
            new URL(url).toURI();
            return true;
        } catch (MalformedURLException | URISyntaxException e) {
            logger.error(" Invalid url!");
            return false;
        }
    }

    private static boolean isValidURL(String url) {
        try {
            new URL(url).toURI();
            return true;
        } catch (MalformedURLException e) {
            logger.error(" Invalid url!");
            return false;
        } catch (URISyntaxException e) {
            logger.error(" Invalid url!");
            return false;
        }
    }

Merge Catch [catch(MalformedURLException e), catch(URISyntaxException e)] to catch(MalformedURLException|URISyntaxException e) in method private isValidURL(url String) : boolean from class docSharing.controller.DocumentController


        private static List<Series> toSeries(DataCursor cursor) throws IOException {
            try (Stream<Series> stream = cursor.asCloseableStream()) {
                return stream.collect(Collectors.toList());
            } catch (UncheckedIOException ex) {
                throw ex.getCause();
            }
        }

        private static List<Series> toSeries(DataCursor cursor) throws IOException {
            try {
                return cursor.toStream().collect(Collectors.toList());
            } finally {
                cursor.close();
            }
        }

Try With Resources try(Stream<Series> stream=cursor.asCloseableStream()) in method private toSeries(cursor DataCursor) : List<Series> from class internal.sdmxdl.provider.ri.web.drivers.StatCanDriver.Converter


    private static DataSet toDataSet(DataCursor cursor) throws IOException {
        try (Stream<Series> stream = cursor.asCloseableStream()) {
            return stream.collect(DataSet.toDataSet(DataflowRef.parse("abc"), DataQuery.ALL));
        } catch (UncheckedIOException ex) {
            throw ex.getCause();
        }
    }

    private static DataSet toDataSet(DataCursor cursor) throws IOException {
        try {
            return cursor.toStream().collect(DataSet.toDataSet(DataflowRef.parse("abc"), DataQuery.ALL));
        } finally {
            cursor.close();
        }
    }

Try With Resources try(Stream<Series> stream=cursor.asCloseableStream()) in method private toDataSet(cursor DataCursor) : DataSet from class internal.sdmxdl.provider.ri.web.Sdmx21RestParsersTest


    @Nonnull
    @SuppressWarnings("null")
    private static DateParser onStrictDatePattern(@Nonnull String datePattern) {
        DateFormat dateFormat = new SimpleDateFormat(datePattern, Locale.ROOT);
        dateFormat.setLenient(false);
        return o -> {
            try {
                String inputAsString = o.toString();
                Date result = dateFormat.parse(inputAsString);
                return result != null && inputAsString.equals(dateFormat.format(result)) ? result : null;
            } catch (ParseException ex) {
                return null;
            }
        };
    }

    @Nonnull
    private static DateParser onStrictDatePattern(@Nonnull String datePattern) {
        final DateFormat dateFormat = new SimpleDateFormat(datePattern, Locale.ROOT);
        dateFormat.setLenient(false);
        return new DateParser() {
            @Override
            public Date parse(CharSequence input) {
                try {
                    String inputAsString = input.toString();
                    Date result = dateFormat.parse(inputAsString);
                    return result != null && inputAsString.equals(dateFormat.format(result)) ? result : null;
                } catch (ParseException ex) {
                    return null;
                }
            }
        };
    }

Replace Anonymous With Lambda be.nbb.sdmx.facade.util.ObsParser.onStrictDatePattern.new DateParser with o -> {tryString inputAsString=o.toString(); in method private onStrictDatePattern(datePattern String) : DateParser from class be.nbb.sdmx.facade.util.ObsParser


    private static ClientSupplier supplierOf(Class<? extends RestSdmxClient> clazz) {
        return (URL endpoint, Map<?, ?> info) -> {
            try {
                GenericSDMXClient result = clazz.newInstance();
                result.setEndpoint(endpoint);
                return result;
            } catch (InstantiationException | IllegalAccessException ex) {
                throw new RuntimeException(ex);
            }
        };
    }

    private static ClientSupplier supplierOf(final Class<? extends RestSdmxClient> clazz) {
        return new ClientSupplier() {
            @Override
            public GenericSDMXClient getClient(URL endpoint, Map<?, ?> info) throws MalformedURLException {
                try {
                    GenericSDMXClient result = clazz.newInstance();
                    result.setEndpoint(endpoint);
                    return result;
                } catch (InstantiationException | IllegalAccessException ex) {
                    throw new RuntimeException(ex);
                }
            }
        };
    }

Replace Anonymous With Lambda be.nbb.sdmx.facade.connectors.SdmxDriverSupport.supplierOf.new ClientSupplier with (endpoint, info) -> {tryGenericSDMXClient result=clazz.newInstance(); in method private supplierOf(clazz Class<? extends RestSdmxClient>) : ClientSupplier from class be.nbb.sdmx.facade.connectors.SdmxDriverSupport