    public synchronized Boolean getQuestToggled(Quest quest) {
        try (Connection connection = getConnection();
        PreparedStatement preparedStatement = connection.prepareStatement("SELECT toggled FROM quests WHERE id = ?;")) {

            preparedStatement.setString(1, quest.getID());
            ResultSet results = preparedStatement.executeQuery();
            Boolean result = false;

            if (results.next()) {
                result = results.getBoolean("toggled");
            }

            return result; // no result found
        } catch (SQLException e) {
            System.err.println("Could not get the quest toggle status " + quest.toString() + ". " + e.getMessage());
            return null;
        }
    }

    public static Boolean getQuestToggled(Quest quest) {
        try {
            // Add player to players table
            String addQuestSQL = "SELECT toggled FROM quests WHERE id = ?;";

            PreparedStatement preparedStatement = getConnection().prepareStatement(addQuestSQL);

            preparedStatement.setString(1, quest.getID()); // parameterIndex starts at 1

            ResultSet results = preparedStatement.executeQuery();
            Boolean state = results.getBoolean("toggled");

            getConnection().close();

            return state;

        } catch (SQLException e) {
            System.err.println("Could not get the quest to toggle " + quest.toString() + ". " + e.getMessage());
            return null;
        }
    }

Try With Resources try(Connection connection=getConnection(); PreparedStatement preparedStatement=connection.prepareStatement("SELECT toggled FROM quests WHERE id = ?;")) in method public getQuestToggled(quest Quest) : Boolean from class playerquests.utility.singleton.Database


    public synchronized void setQuestToggled(Quest quest, Boolean state) {
        try (Connection connection = getConnection();
        PreparedStatement preparedStatement = connection.prepareStatement("UPDATE quests SET toggled = ? WHERE id = ?;")) {

            preparedStatement.setBoolean(1, state);
            preparedStatement.setString(2, quest.getID());
            preparedStatement.execute();

        } catch (SQLException e) {
            System.err.println("Could not toggle the quest " + quest.toString() + ". " + e.getMessage());
        }
    }

    public static void setQuestToggled(Quest quest, Boolean state) {
        try {
            // Add player to players table
            String addQuestSQL = "UPDATE quests SET toggled = ? WHERE id = ?;";

            PreparedStatement preparedStatement = getConnection().prepareStatement(addQuestSQL);

            preparedStatement.setBoolean(1, state); // parameterIndex starts at 1
            preparedStatement.setString(2, quest.getID());
            preparedStatement.execute();

            getConnection().close();

            if (state) {
                QuestRegistry.getInstance().submit(quest);
            } else {
                QuestRegistry.getInstance().remove(quest, true);
            }

        } catch (SQLException e) {
            System.err.println("Could not toggle the quest " + quest.toString() + ". " + e.getMessage());
        }
    }

Try With Resources try(Connection connection=getConnection(); PreparedStatement preparedStatement=connection.prepareStatement("UPDATE quests SET toggled = ? WHERE id = ?;")) in method public setQuestToggled(quest Quest, state Boolean) : void from class playerquests.utility.singleton.Database


    public synchronized void removeQuest(String id) {
        if (id == null) {
            return;
        }

        try (Connection connection = getConnection()) {
            PreparedStatement preparedStatement;

            String removeQuestSQL = "DELETE FROM quests WHERE id = ?;";
            preparedStatement = getConnection().prepareStatement(removeQuestSQL);
            preparedStatement.setString(1, id);
            preparedStatement.execute();

            String removeDiaryQuestSQL = "DELETE FROM diary_quests WHERE quest = ?;";
            preparedStatement = getConnection().prepareStatement(removeDiaryQuestSQL);
            preparedStatement.setString(1, id);
            preparedStatement.execute();

        } catch (SQLException e) {
            System.err.println("Could not remove the quest " + id + ". " + e.getMessage());
        }
    }

    /**
     * Removes a quest reference from the database.
     * @param id the ID to refer to the quest by
     */
    public static void removeQuest(String id) {
        if (id == null) {
            return;
        }

        try {
            PreparedStatement preparedStatement;

            // Remove quest from quests table
            String removeQuestSQL = "DELETE FROM quests WHERE id = ?;";
            preparedStatement = getConnection().prepareStatement(removeQuestSQL);
            preparedStatement.setString(1, id);
            preparedStatement.execute();

            // Remove quest reference from quest diaries
            String removeDiaryQuestSQL = "DELETE FROM diary_quests WHERE quest = ?;";
            preparedStatement = getConnection().prepareStatement(removeDiaryQuestSQL);
            preparedStatement.setString(1, id);
            preparedStatement.execute();

            getConnection().close();

        } catch (SQLException e) {
            System.err.println("Could not remove the quest " + id + ". " + e.getMessage());
        }
    }

Try With Resources try(Connection connection=getConnection()) in method public removeQuest(id String) : void from class playerquests.utility.singleton.Database


    public synchronized void setDiaryQuest(QuestDiary diary, Quest quest, ConnectionsData connections) {
        String questID = quest.getID(); // get the quest ID
        Player player = diary.getPlayer(); // get the player this diary represents

        try (Connection connection = getConnection();
        PreparedStatement preparedStatement = connection.prepareStatement("INSERT OR REPLACE INTO diary_quests (id, stage, action, quest, diary) VALUES (?, ?, ?, ?, ?)")) {

            preparedStatement.setString(1, player.getUniqueId().toString() + "_" + questID);

            // default to initial values
            preparedStatement.setString(2, quest.getEntry().getStage());
            preparedStatement.setString(3, quest.getEntry().getAction());

            // get the current quest stage or action
            StagePath currentConnection = connections.getCurr();

            // replace with current values (if possible)
            if (currentConnection != null) {
                preparedStatement.setString(2, currentConnection.getStage());
                preparedStatement.setString(3, currentConnection.getAction());
            }

            // set remaining values
            preparedStatement.setString(4, questID);
            preparedStatement.setString(5, diary.getDiaryID());

            preparedStatement.execute();

        } catch (SQLException e) {
            System.err.println("Could not set or update quest progress for the " + questID + " quest: " + e.getMessage());
            return;
        }
    }

    public void setQuestProgress(String questID, ConnectionsData connections) {
        Player player = this.getPlayer(this.dbPlayerID);
        Quest quest = QuestRegistry.getInstance().getAllQuests().get(questID);
        Map<String, QuestAction> actions = quest.getActions();

        if (player == null) {
            System.err.println("No player found for this QuestDiary, cannot try to set Quest progress.");
            return;
        }

        try {

            String setQuestProgressSQL = "INSERT OR REPLACE INTO diary_quests (id, stage, action, quest, diary) VALUES (?, ?, ?, ?, ?)";

            PreparedStatement preparedStatement = Database.getConnection().prepareStatement(setQuestProgressSQL);

            preparedStatement.setString(1, player.getUniqueId().toString() + "_" + questID);

            // default to initial values
            preparedStatement.setString(2, quest.getEntry());
            preparedStatement.setString(3, quest.getStages().get(quest.getEntry()).getEntryPoint().getID());

            // get the current quest stage or action
            String currentConnection = connections.getCurr();

            if (currentConnection != null) {
            // stage-based current
                if (currentConnection.contains("stage")) {
                    preparedStatement.setString(2, currentConnection);
                    preparedStatement.setString(3, quest.getStages().get(currentConnection).getEntryPoint().getID()); // get the ID of the entry action
                }

                // action-based current
                if (currentConnection.contains("action") && actions.containsKey(currentConnection)) {
                    String stageID = actions.get(currentConnection).getStage().getID();

                    preparedStatement.setString(2, stageID);
                    preparedStatement.setString(3, currentConnection);
                }
            }

            // set remaining values
            preparedStatement.setString(4, questID);
            preparedStatement.setInt(5, this.dbDiaryID);

            preparedStatement.execute();

            Database.getConnection().close();

        } catch (SQLException e) {
            System.err.println("Could not set or update quest progress for the " + questID + " quest: " + e.getMessage());
            return;
        }
    }

Try With Resources try(Connection connection=getConnection(); PreparedStatement preparedStatement=connection.prepareStatement("INSERT OR REPLACE INTO diary_quests (id, stage, action, quest, diary) VALUES (?, ?, ?, ?, ?)")) in method public setDiaryQuest(diary QuestDiary, quest Quest, connections ConnectionsData) : void from class playerquests.utility.singleton.Database


    public synchronized ResultSet getDiary(Integer dbPlayerID) {
        try (Connection connection = getConnection();
        PreparedStatement preparedStatement = connection.prepareStatement("SELECT id FROM diaries WHERE player = ?")) {

            preparedStatement.setInt(1, dbPlayerID);

            ResultSet results = preparedStatement.executeQuery();

            return results;
        } catch (SQLException e) {
            System.err.println("Could not find a diary for db player ID: " + dbPlayerID + ": " + e.getMessage());
            return null;
        }
    }

    public Integer getDiaryID(Integer dbPlayerID) {
        if (dbDiaryID != null) {
            return dbDiaryID;
        }

        try {
            String getDiarySQL = "SELECT id FROM diaries WHERE player = ?";

            PreparedStatement preparedStatement = Database.getConnection().prepareStatement(getDiarySQL);

            preparedStatement.setInt(1, dbPlayerID);

            ResultSet results = preparedStatement.executeQuery();
            Integer id = results.getInt("id");

            Database.getConnection().close();

            // if not found (it will return 0)
            if (id.equals(0)) {
                return null;
            }

            return id;
        } catch (SQLException e) {
            System.err.println("Could not get diary ID, from player with the database ID: " + dbPlayerID + ": " + e.getMessage());
            return null;
        }
    }

Try With Resources try(Connection connection=getConnection(); PreparedStatement preparedStatement=connection.prepareStatement("SELECT id FROM diaries WHERE player = ?")) in method public getDiary(dbPlayerID Integer) : ResultSet from class playerquests.utility.singleton.Database


    /**
	 * Constructor that is invoked when page is invoked without a session.
	 */
    public CodeSnippetsPage() {
        val form = new SourceCodeSnippetForm("snippetsForm");
        add(form);

        IModel<List<SourceCodeSnippet>> snippets = (IModel<List<SourceCodeSnippet>>) () -> snippetService.retrieveAllItems();

        val listContainer = new WebMarkupContainer("snippetsContainer");
        listContainer.setOutputMarkupId(true);
        listContainer.add(new PropertyListView<>("snippets", snippets) {
            @Override
            protected void populateItem(ListItem<SourceCodeSnippet> listItem) {
                listItem.add(new Label("dateTime"));

                val removeLink = new AjaxSubmitLink("removeSnippet", form) {
                    @Override
                    public void onSubmit(AjaxRequestTarget target) {
                        snippetService.removeItem(listItem.getModelObject().getId());
                        target.add(listContainer);
                    }
                };
                removeLink.setDefaultFormProcessing(false);
                listItem.add(removeLink);

                listItem.add(new Label("title"));
                listItem.add(new MultiLineLabel("sourceCode"));
            }
        });

        add(listContainer).setVersioned(false);
    }

    /**
	 * Constructor that is invoked when page is invoked without a session.
	 */
    public CodeSnippetsPage() {
        val form = new SourceCodeSnippetForm("snippetsForm");
        add(form);

        IModel<List<SourceCodeSnippet>> snippets = (IModel<List<SourceCodeSnippet>>) () -> snippetService.retrieveAllItems();

        val listContainer = new WebMarkupContainer("snippetsContainer");
        listContainer.setOutputMarkupId(true);
        listContainer.add(new PropertyListView<SourceCodeSnippet>("snippets", snippets) {
            @Override
            protected void populateItem(ListItem<SourceCodeSnippet> listItem) {
                listItem.add(new Label("dateTime"));

                val removeLink = new AjaxSubmitLink("removeSnippet", form) {
                    @Override
                    public void onSubmit(AjaxRequestTarget target) {
                        snippetService.removeItem(listItem.getModelObject().getId());
                        target.add(listContainer);
                    }
                };
                removeLink.setDefaultFormProcessing(false);
                listItem.add(removeLink);

                listItem.add(new Label("title"));
                listItem.add(new MultiLineLabel("sourceCode"));
            }
        });

        add(listContainer).setVersioned(false);
    }

Replace Generic With Diamond PropertyListView<SourceCodeSnippet> with PropertyListView<> in method public CodeSnippetsPage() from class com.backedrum.component.CodeSnippetsPage


    /**
     * Constructor that is invoked when page is invoked without a session.
     */
    public HowTosPage() {
        val form = new HowToForm("howtosForm");

        add(form);

        IModel<List<HowTo>> howToList = (IModel<List<HowTo>>) () -> howtoService.retrieveAllItems();

        val listContainer = new WebMarkupContainer("howtosContainer");
        listContainer.setOutputMarkupId(true);
        listContainer.add(new PropertyListView<>("howtos", howToList) {
            @Override
            protected void populateItem(ListItem<HowTo> listItem) {
                listItem.add(new Label("dateTime"));

                val removeLink = new AjaxSubmitLink("removeHowTo", form) {
                    @Override
                    public void onSubmit(AjaxRequestTarget target) {
                        howtoService.removeItem(listItem.getModelObject().getId());
                        target.add(listContainer);
                    }
                };
                removeLink.setDefaultFormProcessing(false);
                listItem.add(removeLink);

                listItem.add(new Label("title"));

                val howToText = new AjaxEditableMultiLineLabel<>("text", new PropertyModel<>(listItem.getModelObject(), "text")) {
                    @Override
                    protected void onSubmit(AjaxRequestTarget target) {
                        val howTo = listItem.getModelObject();
                        howTo.setText(getEditor().getValue());
                        howtoService.saveItem(howTo);

                        super.onSubmit(target);
                        target.add(listContainer);
                    }
                };

                listItem.add(howToText);
            }
        });

        add(listContainer).setVersioned(false);
    }

    /**
     * Constructor that is invoked when page is invoked without a session.
     */
    public HowTosPage() {
        val form = new HowToForm("howtosForm");

        add(form);

        IModel<List<HowTo>> howToList = (IModel<List<HowTo>>) () -> howtoService.retrieveAllItems();

        val listContainer = new WebMarkupContainer("howtosContainer");
        listContainer.setOutputMarkupId(true);
        listContainer.add(new PropertyListView<HowTo>("howtos", howToList) {
            @Override
            protected void populateItem(ListItem<HowTo> listItem) {
                listItem.add(new Label("dateTime"));

                val removeLink = new AjaxSubmitLink("removeHowTo", form) {
                    @Override
                    public void onSubmit(AjaxRequestTarget target) {
                        howtoService.removeItem(listItem.getModelObject().getId());
                        target.add(listContainer);
                    }
                };
                removeLink.setDefaultFormProcessing(false);
                listItem.add(removeLink);

                listItem.add(new Label("title"));
                listItem.add(new MultiLineLabel("text"));
            }
        });

        add(listContainer).setVersioned(false);
    }

Replace Generic With Diamond PropertyListView<HowTo> with PropertyListView<> in method public HowTosPage() from class com.backedrum.component.HowTosPage


    /**
     * Constructor that is invoked when page is invoked without a session.
     */
    public ScreenshotsPage() {
        val form = new ScreenshotForm("screenshotsForm");
        add(form);

        IModel<List<Screenshot>> screenshots = (IModel<List<Screenshot>>) () -> screenshotService.retrieveAllItems();

        val listContainer = new WebMarkupContainer("screenshotsContainer");
        listContainer.setOutputMarkupId(true);
        listContainer.add(new PropertyListView<>("screenshots", screenshots) {
            @Override
            protected void populateItem(ListItem<Screenshot> listItem) {
                listItem.add(new Label("dateTime"));

                val removeLink = new AjaxSubmitLink("removeScreenshot", form) {
                    @Override
                    public void onSubmit(AjaxRequestTarget target) {
                        screenshotService.removeItem(listItem.getModelObject().getId());
                        target.add(listContainer);
                    }
                };
                removeLink.setDefaultFormProcessing(false);
                listItem.add(removeLink);

                listItem.add(new Label("title"));

                listItem.add(new PropertyListView<>("images", listItem.getModelObject().getImages()) {
                    @Override
                    protected void populateItem(ListItem<Image> image) {
                        image.add(new NonCachingImage("screenshotImage", new DynamicImageResource() {
                            @Override
                            protected byte[] getImageData(Attributes attributes) {
                                return image.getModelObject().getImage();
                            }
                        }));
                    }
                });

            }
        });

        add(listContainer).setVersioned(false);
    }

    /**
     * Constructor that is invoked when page is invoked without a session.
     */
    public ScreenshotsPage() {
        val form = new ScreenshotForm("screenshotsForm");
        add(form);

        IModel<List<Screenshot>> screenshots = (IModel<List<Screenshot>>) () -> screenshotService.retrieveAllItems();

        val listContainer = new WebMarkupContainer("screenshotsContainer");
        listContainer.setOutputMarkupId(true);
        listContainer.add(new PropertyListView<Screenshot>("screenshots", screenshots) {
            @Override
            protected void populateItem(ListItem<Screenshot> listItem) {
                listItem.add(new Label("dateTime"));

                val removeLink = new AjaxSubmitLink("removeScreenshot", form) {
                    @Override
                    public void onSubmit(AjaxRequestTarget target) {
                        screenshotService.removeItem(listItem.getModelObject().getId());
                        target.add(listContainer);
                    }
                };
                removeLink.setDefaultFormProcessing(false);
                listItem.add(removeLink);

                listItem.add(new Label("title"));
                listItem.add(new NonCachingImage("screenshotImage", new DynamicImageResource() {
                    @Override
                    protected byte[] getImageData(Attributes attributes) {
                        return listItem.getModelObject().getImage();
                    }
                }));
            }
        });

        add(listContainer).setVersioned(false);
    }

Replace Generic With Diamond PropertyListView<Screenshot> with PropertyListView<> in method public ScreenshotsPage() from class com.backedrum.component.ScreenshotsPage


    public static void main(String[] args) {
        EventQueue.invokeLater(() -> {
            try {
                VentanaPreguntasFrecuentes window = new VentanaPreguntasFrecuentes();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
    }

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    VentanaPreguntasFrecuentes window = new VentanaPreguntasFrecuentes();
                    window.frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

Replace Anonymous With Lambda org.proyectosalida.Pruebas.VentanaPreguntasFrecuentes.main.invokeLater.new Runnable with () -> {tryVentanaPreguntasFrecuentes window=new VentanaPreguntasFrecuentes(); in method public main(args String[]) : void from class VentanaPreguntasFrecuentes


    public void onAnalysisReset(final JsAnalysisResetHandler handler) {
        diagram.addAnalysisResetHandler(event -> Scheduler.get().scheduleDeferred(handler::analysisReset));
    }

    public void onAnalysisReset(final JsAnalysisResetHandler handler) {
        diagram.addAnalysisResetHandler(new AnalysisResetHandler() {
            @Override
            public void onAnalysisReset(AnalysisResetEvent event) {
                handler.analysisReset();
            }
        });
    }

Replace Anonymous With Lambda org.reactome.web.client.Diagram.onAnalysisReset.addAnalysisResetHandler.new AnalysisResetHandler with event -> Scheduler.get().scheduleDeferred(handler::analysisReset) in method public onAnalysisReset(handler JsAnalysisResetHandler) : void from class org.reactome.web.client.Diagram


    public void onCanvasNotSupported(final JsCanvasNotSupported handler) {
        diagram.addCanvasNotSupportedEventHandler(event -> Scheduler.get().scheduleDeferred(handler::canvasNotSupported));
    }

    public void onCanvasNotSupported(final JsCanvasNotSupported handler) {
        diagram.addCanvasNotSupportedEventHandler(new CanvasNotSupportedHandler() {
            @Override
            public void onCanvasNotSupported(CanvasNotSupportedEvent event) {
                handler.canvasNotSupported();
            }
        });
    }

Replace Anonymous With Lambda org.reactome.web.client.Diagram.onCanvasNotSupported.addCanvasNotSupportedEventHandler.new CanvasNotSupportedHandler with event -> Scheduler.get().scheduleDeferred(handler::canvasNotSupported) in method public onCanvasNotSupported(handler JsCanvasNotSupported) : void from class org.reactome.web.client.Diagram


    public void onFlagsReset(final JsFlagsResetHandler handler) {
        diagram.addDiagramObjectsFlagResetHandler(event -> Scheduler.get().scheduleDeferred(handler::flagsReset));
    }

    public void onFlagsReset(final JsFlagsResetHandler handler) {
        diagram.addDiagramObjectsFlagResetHandler(new DiagramObjectsFlagResetHandler() {
            @Override
            public void onDiagramObjectsFlagReset(DiagramObjectsFlagResetEvent event) {
                handler.flagsReset();
            }
        });
    }

Replace Anonymous With Lambda org.reactome.web.client.Diagram.onFlagsReset.addDiagramObjectsFlagResetHandler.new DiagramObjectsFlagResetHandler with event -> Scheduler.get().scheduleDeferred(handler::flagsReset) in method public onFlagsReset(handler JsFlagsResetHandler) : void from class org.reactome.web.client.Diagram


    public List<RR> get(final RRCode type, final String name, final int domainId) {
        logger.traceEntry(new ObjectMessage(type));
        logger.traceEntry(new ObjectMessage(name));
        logger.traceEntry(new ObjectMessage(domainId));

        try (Connection conn = DriverManager.getConnection(dbURL, dbUser, dbPass);
             Statement stmt = conn.createStatement();
             ResultSet rs = stmt.executeQuery(
             "SELECT * FROM records where domain_id = " + domainId +
                     " AND name = \"" + name + "\"" +
                     " AND type = \"" + type.name() + "\"")) {

            List<RR> ret = new ArrayList<>();

            while (rs.next()) {
                addRR(type, name, rs);
            }

            return ret;
        } catch (SQLException sqle) {
            logger.catching(sqle);
        }

        return Collections.emptyList();
    }

    public List<RR> get(final RRCode type, final String name, final int domainId) {
        logger.traceEntry(new ObjectMessage(type));
        logger.traceEntry(new ObjectMessage(name));
        logger.traceEntry(new ObjectMessage(domainId));

        try {
            String stype = type.name();
            logger.trace(stype);
            List<RR> ret = new ArrayList<>();
            ResultSet rs = stmt.executeQuery(
                    "SELECT * FROM records where domain_id = " + domainId +
                            " AND name = \"" + name + "\"" +
                            " AND type = \"" + stype + "\"");

            while (rs.next()) {
                addRR(type, name, rs);
            }

            return ret;
        } catch (SQLException sqle) {
            logger.catching(sqle);
        }

        return Collections.emptyList();
    }

Try With Resources try(Connection conn=DriverManager.getConnection(dbURL,dbUser,dbPass); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("SELECT * FROM records where domain_id = " + domainId + " AND name = \"" + name + "\"" + " AND type = \"" + type.name() + "\"")) in method public get(type RRCode, name String, domainId int) : List<RR> from class edu.msudenver.cs.jdnss.DBConnection


    public Vector<RR> get(final RRCode type, final String name, final int domainId) {
        logger.traceEntry(new ObjectMessage(type));
        logger.traceEntry(new ObjectMessage(name));
        logger.traceEntry(new ObjectMessage(domainId));

        try {
            String stype = type.name();
            logger.trace(stype);
            Vector<RR> ret = new Vector<>();
            ResultSet rs = stmt.executeQuery(
                    "SELECT * FROM records where domain_id = " + domainId +
                            " AND name = \"" + name + "\"" +
                            " AND type = \"" + stype + "\"");

            while (rs.next()) {
                String dbname = rs.getString("name");
                String dbcontent = rs.getString("content");
                int dbttl = rs.getInt("ttl");
                int dbprio = rs.getInt("prio");

                switch (type) {
                    case SOA: {
                        String s[] = dbcontent.split("\\s+");
                        ret.add(new SOARR(dbname, s[0], s[1],
                                Integer.parseInt(s[2]), Integer.parseInt(s[3]),
                                Integer.parseInt(s[4]), Integer.parseInt(s[5]),
                                Integer.parseInt(s[6]), dbttl));
                        break;
                    }
                    case NS: {
                        ret.add(new NSRR(dbname, dbttl, dbcontent));
                        break;
                    }
                    case A: {
                        ret.add(new ARR(dbname, dbttl, dbcontent));
                        break;
                    }
                    case AAAA: {
                        ret.add(new AAAARR(dbname, dbttl, dbcontent));
                        break;
                    }
                    case MX: {
                        ret.add(new MXRR(dbname, dbttl, dbcontent, dbprio));
                        break;
                    }
                    case TXT: {
                        ret.add(new TXTRR(dbname, dbttl, dbcontent));
                        break;
                    }
                    case CNAME: {
                        ret.add(new CNAMERR(dbname, dbttl, dbcontent));
                        break;
                    }
                    case PTR: {
                        ret.add(new PTRRR(dbname, dbttl, dbcontent));
                        break;
                    }
                    case HINFO: {
                        final String s[] = dbcontent.split("\\s+");
                        ret.add(new HINFORR(dbname, dbttl, s[0], s[1]));
                        break;
                    }
                    default: {
                        logger.warn("requested type " + type +
                                " for " + name + " not found");
                        Assertion.fail();
                    }
                }
            }

            Assertion.aver(ret.size() != 0);
            return ret;
        } catch (SQLException sqle) {
            logger.catching(sqle);
            Assertion.fail();
        }

        Assertion.aver(false);
        return null;    // have to have this or javac complains
    }

    public Vector<RR> get(final RRCode type, final String name, final int domainId) {
        logger.traceEntry(new ObjectMessage(type));
        logger.traceEntry(new ObjectMessage(name));
        logger.traceEntry(new ObjectMessage(domainId));

        try {
            String stype = type.name();
            logger.trace(stype);
            Vector<RR> ret = new Vector<RR>();
            ResultSet rs = stmt.executeQuery(
                    "SELECT * FROM records where domain_id = " + domainId +
                            " AND name = \"" + name + "\"" +
                            " AND type = \"" + stype + "\"");

            while (rs.next()) {
                String dbname = rs.getString("name");
                String dbcontent = rs.getString("content");
                int dbttl = rs.getInt("ttl");
                int dbprio = rs.getInt("prio");

                switch (type) {
                    case SOA: {
                        String s[] = dbcontent.split("\\s+");
                        ret.add(new SOARR(dbname, s[0], s[1],
                                Integer.parseInt(s[2]), Integer.parseInt(s[3]),
                                Integer.parseInt(s[4]), Integer.parseInt(s[5]),
                                Integer.parseInt(s[6]), dbttl));
                        break;
                    }
                    case NS: {
                        ret.add(new NSRR(dbname, dbttl, dbcontent));
                        break;
                    }
                    case A: {
                        ret.add(new ARR(dbname, dbttl, dbcontent));
                        break;
                    }
                    case AAAA: {
                        ret.add(new AAAARR(dbname, dbttl, dbcontent));
                        break;
                    }
                    case MX: {
                        ret.add(new MXRR(dbname, dbttl, dbcontent, dbprio));
                        break;
                    }
                    case TXT: {
                        ret.add(new TXTRR(dbname, dbttl, dbcontent));
                        break;
                    }
                    case CNAME: {
                        ret.add(new CNAMERR(dbname, dbttl, dbcontent));
                        break;
                    }
                    case PTR: {
                        ret.add(new PTRRR(dbname, dbttl, dbcontent));
                        break;
                    }
                    case HINFO: {
                        final String s[] = dbcontent.split("\\s+");
                        ret.add(new HINFORR(dbname, dbttl, s[0], s[1]));
                        break;
                    }
                    default: {
                        logger.warn("requested type " + type +
                                " for " + name + " not found");
                        Assertion.fail();
                    }
                }
            }

            Assertion.aver(ret.size() != 0);
            return ret;
        } catch (SQLException sqle) {
            logger.catching(sqle);
            Assertion.fail();
        }

        Assertion.aver(false);
        return null;    // have to have this or javac complains
    }

Replace Generic With Diamond Vector<RR> with Vector<> in method public get(type RRCode, name String, domainId int) : Vector<RR> from class edu.msudenver.cs.jdnss.DBConnection


    public UDP() throws SocketException, UnknownHostException
    {
        try
        {
            String ipaddress = JDNSS.getJargs().IPaddress;
            int port = JDNSS.getJargs().port;
            if (ipaddress != null)
            {
                dsocket = new DatagramSocket(port,
                    InetAddress.getByName(ipaddress));
            }
            else
            {
                dsocket = new DatagramSocket(port);
            }
        }
        catch (UnknownHostException | SocketException uhe)
        {
            logger.catching(uhe);
            throw uhe;
        }
    }

    public UDP() throws SocketException, UnknownHostException
    {
        try
        {
            String ipaddress = JDNSS.getJargs().IPaddress;
            int port = JDNSS.getJargs().port;
            if (ipaddress != null)
            {
                dsocket = new DatagramSocket(port,
                    InetAddress.getByName(ipaddress));
            }
            else
            {
                dsocket = new DatagramSocket(port);
            }
        }
        catch (UnknownHostException uhe)
        {
            logger.catching(uhe);
            throw uhe;
        }
        catch (SocketException se)
        {
            logger.catching(se);
            throw se;
        }
    }

Merge Catch [catch(UnknownHostException uhe), catch(SocketException se)] to catch(UnknownHostException|SocketException uhe) in method public UDP() from class edu.msudenver.cs.jdnss.UDP


    /**
     * This method is used by both UDP and MC
     */
    public void run()
    {
        logger.traceEntry();

        /*
        "Multicast DNS Messages carried by UDP may be up to the IP MTU of the
        physical interface, less the space required for the IP header(20
        bytes for IPv4; 40 bytes for IPv6) and the UDP header(8 bytes)."

        Ergo, we should probably calculate those values here instead of
        just going with 1500.
        */

        int size = this instanceof MC ? 1500 : 512;

        byte[] buffer = new byte[size];
        DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
        int threadPoolSize = JDNSS.getJargs().threads;
        ExecutorService pool = Executors.newFixedThreadPool(threadPoolSize);

        while (true)
        {
            try
            {
                dsocket.receive(packet);
            }
            catch (IOException ioe)
            {
                logger.catching(ioe);
                continue;
            }

            Future f = pool.submit(
                new UDPThread(
                    Utils.trimByteArray(packet.getData(), packet.getLength()),
                    dsocket, packet.getPort(), packet.getAddress()
                )
            );

            // if we're only supposed to answer once, and we're the first,
            // bring everything down with us.
            if (JDNSS.getJargs().once)
            {
                try
                {
                    f.get();
                }
                catch (InterruptedException | ExecutionException ie)
                {
                    logger.catching(ie);
                }

                System.exit(0);
            }
        }
    }

    /**
     * This method is used by both UDP and MC
     */
    public void run()
    {
        logger.traceEntry();

        /*
        "Multicast DNS Messages carried by UDP may be up to the IP MTU of the
        physical interface, less the space required for the IP header(20
        bytes for IPv4; 40 bytes for IPv6) and the UDP header(8 bytes)."

        Ergo, we should probably calculate those values here instead of
        just going with 1500.
        */

        int size = this instanceof MC ? 1500 : 512;

        byte[] buffer = new byte[size];
        DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
        int threadPoolSize = JDNSS.getJargs().threads;
        ExecutorService pool = Executors.newFixedThreadPool(threadPoolSize);

        while (true)
        {
            try
            {
                dsocket.receive(packet);
            }
            catch (IOException ioe)
            {
                logger.catching(ioe);
                continue;
            }

            Future f = pool.submit(
                new UDPThread(
                    Utils.trimByteArray(packet.getData(), packet.getLength()),
                    dsocket, packet.getPort(), packet.getAddress()
                )
            );

            // if we're only supposed to answer once, and we're the first,
            // bring everything down with us.
            if (JDNSS.getJargs().once)
            {
                try
                {
                    f.get();
                }
                catch (InterruptedException ie)
                {
                    logger.catching(ie);
                }
                catch (ExecutionException ee)
                {
                    logger.catching(ee);
                }

                System.exit(0);
            }
        }
    }

Merge Catch [catch(InterruptedException ie), catch(ExecutionException ee)] to catch(InterruptedException|ExecutionException ie) in method public run() : void from class edu.msudenver.cs.jdnss.UDP


    final synchronized void performAddRemoveOperations(AddRemoveOperation[] operations) {
        Argument.assertElementNotNull(operations, "operations");

        boolean containsAdd = false;
        for (AddRemoveOperation operation : operations) {
            if (operation.getOperation() == Operation.ADD) {
                containsAdd = true;
                break;
            }
        }
        if (containsAdd && immediateChildren == null) {
            immediateChildren = new HashSet<TreeComponent>();
        }
        List<Runnable> runnables = new ArrayList<>();
        for (AddRemoveOperation operation : operations) {
            TreeComponent child = operation.getTreeComponent();
            if (operation.getOperation() == Operation.ADD) {
                if (!immediateChildren.add(child)) {
                    throw new IllegalStateException(
                            child.getFullyQualifiedName() + " is already a child of this Branch");
                }
                // Create the CHILD -> PARENT relationship.
                if (child.immediateParent == null) {
                    child.immediateParent = this;
                } else {
                    throw new IllegalStateException(child.getFullyQualifiedName() + " already has a parent!");
                }
                runnables.add(new TransactionMgr.AddComponentRunnable(this, child));
            } else if (operation.getOperation() == Operation.REMOVE) {
                if (immediateChildren == null || !immediateChildren.remove(child)) {
                    throw new IllegalStateException(child.getFullyQualifiedName() + " is not a child of this Branch!");
                }
                // Remove the CHILD -> PARENT relationship.
                if (child.immediateParent == this) {
                    child.immediateParent = null;
                } else {
                    throw new IllegalStateException(
                            child.getFullyQualifiedName() + " has " + child.immediateParent + " Parent!");
                }
                runnables.add(new RemoveComponentRunnable(this, child));
            }
        }

        if (immediateChildren != null && immediateChildren.isEmpty()) {
            immediateChildren = null;
        }

        // Perform deferred add on child & descendants if this node has a Root.
        if (immediateRoot != null) {
            synchronized (immediateRoot) {
                TransactionMgr transactionMgr = immediateRoot.getTransactionManager();

                transactionMgr.lockTransactionQueue();
                try {
                    for (Runnable runnable : runnables) {
                        if (runnable instanceof AddComponentRunnable) {
                            AddComponentRunnable acr = (AddComponentRunnable) runnable;

                            acr.setTransactionMgr(transactionMgr);
                            transactionMgr.addComponent(
                                    acr, TransactionMgr.isTraceLogging() ? new Throwable("AddComponent") : null);

                            ArrayList<Object> allDeferredAddRemoveSets = new ArrayList<Object>();

                            addChildAndDescendents(this, acr.child, allDeferredAddRemoveSets);
                            TransactionMgrUtil.postAddRemoveSetsToQueue(
                                    allDeferredAddRemoveSets.toArray(), transactionMgr);
                        } else if (runnable instanceof RemoveComponentRunnable) {
                            RemoveComponentRunnable rcr = (RemoveComponentRunnable) runnable;

                            rcr.setTransactionMgr(transactionMgr);
                            transactionMgr.removeComponent(
                                    rcr, TransactionMgr.isTraceLogging() ? new Throwable("RemoveComponent") : null);
                            removeChildAndDescendents(this, rcr.child);
                        }
                    }
                } finally {
                    transactionMgr.unlockTransactionQueue();
                }
            }
        } else {
            for (Runnable runnable : runnables) {
                synchronized (deferredAddRemoveSets) {
                    deferredAddRemoveSets.add(runnable);
                }
                if (runnable instanceof AddComponentRunnable) {
                    AddComponentRunnable acr = (AddComponentRunnable) runnable;

                    if (acr.child instanceof Initiator) {
                        Initiator initiator = (Initiator) acr.child;

                        Initiator.TransactionContainer[] sourceNState = initiator.getDeferredStateChangesAndClear();
                        if (sourceNState != null) {
                            for (int i = 0; i < sourceNState.length; i++) {
                                addStateChange(sourceNState[i]);
                            }
                        }
                    }
                }
            }
        }
    }

    final synchronized void performAddRemoveOperations(AddRemoveOperation[] operations) {
        Argument.assertElementNotNull(operations, "operations");

        boolean containsAdd = false;
        for (AddRemoveOperation operation : operations) {
            if (operation.getOperation() == Operation.ADD) {
                containsAdd = true;
                break;
            }
        }
        if (containsAdd && immediateChildren == null) {
            immediateChildren = new HashSet<TreeComponent>();
        }
        List<Runnable> runnables = new LinkedList<Runnable>();
        for (AddRemoveOperation operation : operations) {
            TreeComponent child = operation.getTreeComponent();
            if (operation.getOperation() == Operation.ADD) {
                if (!immediateChildren.add(child)) {
                    throw new IllegalStateException(
                            child.getFullyQualifiedName() + " is already a child of this Branch");
                }
                // Create the CHILD -> PARENT relationship.
                if (child.immediateParent == null) {
                    child.immediateParent = this;
                } else {
                    throw new IllegalStateException(child.getFullyQualifiedName() + " already has a parent!");
                }
                runnables.add(new TransactionMgr.AddComponentRunnable(this, child));
            } else if (operation.getOperation() == Operation.REMOVE) {
                if (immediateChildren == null || !immediateChildren.remove(child)) {
                    throw new IllegalStateException(child.getFullyQualifiedName() + " is not a child of this Branch!");
                }
                // Remove the CHILD -> PARENT relationship.
                if (child.immediateParent == this) {
                    child.immediateParent = null;
                } else {
                    throw new IllegalStateException(
                            child.getFullyQualifiedName() + " has " + child.immediateParent + " Parent!");
                }
                runnables.add(new RemoveComponentRunnable(this, child));
            }
        }

        if (immediateChildren != null && immediateChildren.isEmpty()) {
            immediateChildren = null;
        }

        // Perform deferred add on child & descendants if this node has a Root.
        if (immediateRoot != null) {
            synchronized (immediateRoot) {
                TransactionMgr transactionMgr = immediateRoot.getTransactionManager();

                transactionMgr.lockTransactionQueue();
                try {
                    for (Runnable runnable : runnables) {
                        if (runnable instanceof AddComponentRunnable) {
                            AddComponentRunnable acr = (AddComponentRunnable) runnable;

                            acr.setTransactionMgr(transactionMgr);
                            transactionMgr.addComponent(
                                    acr, TransactionMgr.isTraceLogging() ? new Throwable("AddComponent") : null);

                            ArrayList<Object> allDeferredAddRemoveSets = new ArrayList<Object>();

                            addChildAndDescendents(this, acr.child, allDeferredAddRemoveSets);
                            TransactionMgrUtil.postAddRemoveSetsToQueue(
                                    allDeferredAddRemoveSets.toArray(), transactionMgr);
                        } else if (runnable instanceof RemoveComponentRunnable) {
                            RemoveComponentRunnable rcr = (RemoveComponentRunnable) runnable;

                            rcr.setTransactionMgr(transactionMgr);
                            transactionMgr.removeComponent(
                                    rcr, TransactionMgr.isTraceLogging() ? new Throwable("RemoveComponent") : null);
                            removeChildAndDescendents(this, rcr.child);
                        }
                    }
                } finally {
                    transactionMgr.unlockTransactionQueue();
                }
            }
        } else {
            for (Runnable runnable : runnables) {
                synchronized (deferredAddRemoveSets) {
                    deferredAddRemoveSets.add(runnable);
                }
                if (runnable instanceof AddComponentRunnable) {
                    AddComponentRunnable acr = (AddComponentRunnable) runnable;

                    if (acr.child instanceof Initiator) {
                        Initiator initiator = (Initiator) acr.child;

                        Initiator.TransactionContainer[] sourceNState = initiator.getDeferredStateChangesAndClear();
                        if (sourceNState != null) {
                            for (int i = 0; i < sourceNState.length; i++) {
                                addStateChange(sourceNState[i]);
                            }
                        }
                    }
                }
            }
        }
    }

Replace Generic With Diamond LinkedList<Runnable> with ArrayList<> in method package performAddRemoveOperations(operations AddRemoveOperation[]) : void from class tfw.tsm.BranchComponent


    private static ObjectECD[] toArray(ObjectIlaECD listECD, ObjectECD selectedItemECD, IntegerECD selectedIndexECD) {
        Argument.assertNotNull(listECD, "listECD");
        if (selectedItemECD == null && selectedIndexECD == null) {
            throw new IllegalStateException("(selectedItemECD == null) && (selectedIndexECD == null) not allowed");
        }
        ArrayList<ObjectECD> list = new ArrayList<>();
        list.add(listECD);
        if (selectedItemECD != null) {
            list.add(selectedItemECD);
        }
        if (selectedIndexECD != null) {
            list.add(selectedIndexECD);
        }
        return list.toArray(new ObjectECD[list.size()]);
    }

    private static ObjectECD[] toArray(ObjectIlaECD listECD, ObjectECD selectedItemECD, IntegerECD selectedIndexECD) {
        Argument.assertNotNull(listECD, "listECD");
        if (selectedItemECD == null && selectedIndexECD == null) {
            throw new IllegalStateException("(selectedItemECD == null) && (selectedIndexECD == null) not allowed");
        }
        ArrayList<ObjectECD> list = new ArrayList<ObjectECD>();
        list.add(listECD);
        if (selectedItemECD != null) {
            list.add(selectedItemECD);
        }
        if (selectedIndexECD != null) {
            list.add(selectedIndexECD);
        }
        return list.toArray(new ObjectECD[list.size()]);
    }

Replace Generic With Diamond ArrayList<ObjectECD> with ArrayList<> in method private toArray(listECD ObjectIlaECD, selectedItemECD ObjectECD, selectedIndexECD IntegerECD) : ObjectECD[] from class tfw.swing.combobox.SelectionAndListCommit


    public JComboBoxBB(
            Branch branch,
            ObjectIlaECD listECD,
            ObjectECD selectedItemECD,
            IntegerECD selectedIndexECD,
            BooleanECD enabledECD,
            Initiator[] initiators) {

        this.branch = branch;

        SelectionInitiator selectionInitiator =
                new SelectionInitiator("JComboBoxBB", selectedItemECD, selectedIndexECD, this);

        addActionListener(selectionInitiator);
        branch.add(selectionInitiator);

        List<Initiator> list = new ArrayList<>(Arrays.asList(initiators));
        list.add(selectionInitiator);
        initiators = list.toArray(new Initiator[list.size()]);
        SelectionAndListCommit selectionAndListCommit = new SelectionAndListCommit(
                "JComboBoxBB",
                listECD,
                selectedItemECD,
                selectedIndexECD,
                initiators,
                new ActionListener[] {selectionInitiator},
                this);

        if (enabledECD != null) {
            branch.add(new EnabledCommit("JComboBoxBB", enabledECD, this, null));
        }
        branch.add(selectionAndListCommit);
    }

    public JComboBoxBB(
            Branch branch,
            ObjectIlaECD listECD,
            ObjectECD selectedItemECD,
            IntegerECD selectedIndexECD,
            BooleanECD enabledECD,
            Initiator[] initiators) {

        this.branch = branch;

        SelectionInitiator selectionInitiator =
                new SelectionInitiator("JComboBoxBB", selectedItemECD, selectedIndexECD, this);

        addActionListener(selectionInitiator);
        branch.add(selectionInitiator);

        List<Initiator> list = new ArrayList<Initiator>(Arrays.asList(initiators));
        list.add(selectionInitiator);
        initiators = list.toArray(new Initiator[list.size()]);
        SelectionAndListCommit selectionAndListCommit = new SelectionAndListCommit(
                "JComboBoxBB",
                listECD,
                selectedItemECD,
                selectedIndexECD,
                initiators,
                new ActionListener[] {selectionInitiator},
                this);

        if (enabledECD != null) {
            branch.add(new EnabledCommit("JComboBoxBB", enabledECD, this, null));
        }
        branch.add(selectionAndListCommit);
    }

Replace Generic With Diamond ArrayList<Initiator> with ArrayList<> in method public JComboBoxBB(branch Branch, listECD ObjectIlaECD, selectedItemECD ObjectECD, selectedIndexECD IntegerECD, enabledECD BooleanECD, initiators Initiator[]) from class tfw.swing.JComboBoxBB


    public SourceProxy[] getSourceProxies() {
        Collection<Source> collection = new ArrayList<>(synchronizer.sources);
        Iterator<Source> iterator = collection.iterator();
        SourceProxy[] sp = new SourceProxy[collection.size()];

        for (int i = 0; iterator.hasNext(); i++) {
            Object o = iterator.next();
            sp[i] = new SourceProxy((Source) o);
        }
        return (sp);
    }

    public SourceProxy[] getSourceProxies() {
        Collection<Source> collection = new ArrayList<Source>(synchronizer.sources);
        Iterator<Source> iterator = collection.iterator();
        SourceProxy[] sp = new SourceProxy[collection.size()];

        for (int i = 0; iterator.hasNext(); i++) {
            Object o = iterator.next();
            sp[i] = new SourceProxy((Source) o);
        }
        return (sp);
    }

Replace Generic With Diamond ArrayList<Source> with ArrayList<> in method public getSourceProxies() : SourceProxy[] from class tfw.tsm.SynchronizerProxy


  public void start() {
    frame.tfRuc.getDocument().addDocumentListener(dl);
    frame.tfUsername.getDocument().addDocumentListener(dl);
    frame.tfPassword.getDocument().addDocumentListener(dl);

    frame.btnLogIn.addActionListener(
        (ActionEvent arg0) -> {
          try {
            User user = User.getInstance();
            user.setRuc(frame.tfRuc.getText());
            user.setUsername(frame.tfUsername.getText());
            user.setPassword(String.valueOf(frame.tfPassword.getPassword()));

            if (frame.cbRemember.isSelected()) {
              prefs.put(TAG_RUC, frame.tfRuc.getText());
              prefs.put(TAG_USERNAME, frame.tfUsername.getText());
            } else {
              prefs.clear();
            }

            frame.dispose();

            SwingUtilities.invokeLater(
                () -> {
                  BillFrame billFrame = new BillFrame();
                  new BillController(billFrame).start();
                });
          } catch (BackingStoreException ex) {
            Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex);
          }
        });
  }

  public void start() {
    frame.tfRuc.getDocument().addDocumentListener(dl);
    frame.tfUsername.getDocument().addDocumentListener(dl);
    frame.tfPassword.getDocument().addDocumentListener(dl);

    frame.btnLogIn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            try {
              User user = User.getInstance();
              user.setRuc(frame.tfRuc.getText());
              user.setUsername(frame.tfUsername.getText());
              user.setPassword(String.valueOf(frame.tfPassword.getPassword()));

              if (frame.cbRemember.isSelected()) {
                prefs.put(TAG_RUC, frame.tfRuc.getText());
                prefs.put(TAG_USERNAME, frame.tfUsername.getText());
              } else {
                prefs.clear();
              }

              frame.dispose();

              SwingUtilities.invokeLater(
                  () -> {
                    BillFrame billFrame = new BillFrame();
                    new BillController(billFrame).start();
                  });
            } catch (BackingStoreException ex) {
              Logger.getLogger(UserController.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        });
  }

Replace Anonymous With Lambda com.anthonyponte.jbillconsultservice.controller.UserController.start.addActionListener.new ActionListener with (arg0) -> {tryUser user=User.getInstance(); in method public start() : void from class com.anthonyponte.jbillconsultservice.controller.UserController


    public void testHateosResourceMapping()  {
        final HateosResourceMapping<BigInteger, TestResource, TestResource, TestHateosResource, TestHateosResourceHandlerContext> mapping = HateosResourceMapping.with(HateosResourceName.with("resource1"),
                (s, x) -> {
                    return HateosResourceSelection.one(
                            BigInteger.valueOf(
                                    Integer.parseInt(
                                            s.substring(2),
                                            16
                                    )
                            )
                    ); // assumes hex digit in url
                },
                TestResource.class,
                TestResource.class,
                TestHateosResource.class,
                TestHateosResourceHandlerContext.class
        ).setHateosResourceHandler(
                LinkRelation.CONTENTS,
                HttpMethod.POST,
                new FakeHateosResourceHandler<>() {
                    @Override
                    public Optional<TestResource> handleOne(final BigInteger id,
                                                            final Optional<TestResource> resource,
                                                            final Map<HttpRequestAttribute<?>, Object> parameters,
                                                            final TestHateosResourceHandlerContext context) {
                        return Optional.of(
                                TestResource.with(
                                        TestHateosResource.with(
                                                BigInteger.valueOf(31)
                                        )
                                )
                        );
                    }
                }
        );

        final Router<HttpRequestAttribute<?>, HttpHandler> router = HateosResourceMapping.router(
                AbsoluteUrl.parseAbsolute("http://www.example.com/api"),
                Sets.of(mapping),
                Indentation.SPACES2,
                LineEnding.NL,
                new TestHateosResourceHandlerContext()
        );

        final HttpRequest request = new FakeHttpRequest() {

            @Override
            public HttpTransport transport() {
                return HttpTransport.UNSECURED;
            }

            @Override
            public HttpProtocolVersion protocolVersion() {
                return HttpProtocolVersion.VERSION_1_0;
            }

            @Override
            public HttpMethod method() {
                return HttpMethod.POST;
            }

            @Override
            public RelativeUrl url() {
                return Url.parseRelative("/api/resource1/0x123/contents");
            }

            @Override
            public Map<HttpHeaderName<?>, List<?>> headers() {
                return Maps.of(
                        HttpHeaderName.CONTENT_TYPE, Lists.of(TestHateosResourceHandlerContext.CONTENT_TYPE),
                        HttpHeaderName.ACCEPT, Lists.of(TestHateosResourceHandlerContext.CONTENT_TYPE.accept()),
                        HttpHeaderName.ACCEPT_CHARSET, Lists.of(AcceptCharset.parse("utf-8"))
                );
            }

            public String bodyText() {
                return "";
            }

            @Override
            public Map<HttpRequestParameterName, List<String>> parameters() {
                return Maps.empty();
            }

            @Override
            public List<String> parameterValues(final HttpRequestParameterName parameterName) {
                throw new UnsupportedOperationException();
            }

            @Override
            public String toString() {
                return this.method() + " " + this.url() + " " + parameters();
            }
        };
        final HttpHandler httpHandler = router.route(request.routerParameters())
                .orElseThrow(() -> new Error("Unable to route"));

        final HttpResponse response = HttpResponses.recording();
        httpHandler.handle(request, response);
        checkEquals(
                "{\n" +
                        "  \"type\": \"test-HateosResource\",\n" +
                        "  \"value\": {\n" +
                        "    \"id\": \"31\"\n" +
                        "  }\n" +
                        "}",
                response.entities()
                        .get(0)
                        .bodyText()
        );
    }

    public void testHateosResourceMapping()  {
        final HateosResourceMapping<BigInteger, TestResource, TestResource, TestHateosResource, TestHateosResourceHandlerContext> mapping = HateosResourceMapping.with(HateosResourceName.with("resource1"),
                (s) -> {
                    return HateosResourceSelection.one(
                            BigInteger.valueOf(
                                    Integer.parseInt(
                                            s.substring(2),
                                            16
                                    )
                            )
                    ); // assumes hex digit in url
                },
                TestResource.class,
                TestResource.class,
                TestHateosResource.class,
                TestHateosResourceHandlerContext.class
        ).setHateosResourceHandler(
                LinkRelation.CONTENTS,
                HttpMethod.POST,
                new FakeHateosResourceHandler<>() {
                    @Override
                    public Optional<TestResource> handleOne(final BigInteger id,
                                                            final Optional<TestResource> resource,
                                                            final Map<HttpRequestAttribute<?>, Object> parameters,
                                                            final TestHateosResourceHandlerContext context) {
                        return Optional.of(
                                TestResource.with(
                                        TestHateosResource.with(
                                                BigInteger.valueOf(31)
                                        )
                                )
                        );
                    }
                }
        );

        final Router<HttpRequestAttribute<?>, HttpHandler> router = HateosResourceMapping.router(
                AbsoluteUrl.parseAbsolute("http://www.example.com/api"),
                Sets.of(mapping),
                Indentation.SPACES2,
                LineEnding.NL,
                new TestHateosResourceHandlerContext()
        );

        final HttpRequest request = new FakeHttpRequest() {

            @Override
            public HttpTransport transport() {
                return HttpTransport.UNSECURED;
            }

            @Override
            public HttpProtocolVersion protocolVersion() {
                return HttpProtocolVersion.VERSION_1_0;
            }

            @Override
            public HttpMethod method() {
                return HttpMethod.POST;
            }

            @Override
            public RelativeUrl url() {
                return Url.parseRelative("/api/resource1/0x123/contents");
            }

            @Override
            public Map<HttpHeaderName<?>, List<?>> headers() {
                return Maps.of(
                        HttpHeaderName.CONTENT_TYPE, Lists.of(TestHateosResourceHandlerContext.CONTENT_TYPE),
                        HttpHeaderName.ACCEPT, Lists.of(TestHateosResourceHandlerContext.CONTENT_TYPE.accept()),
                        HttpHeaderName.ACCEPT_CHARSET, Lists.of(AcceptCharset.parse("utf-8"))
                );
            }

            public String bodyText() {
                return "";
            }

            @Override
            public Map<HttpRequestParameterName, List<String>> parameters() {
                return Maps.empty();
            }

            @Override
            public List<String> parameterValues(final HttpRequestParameterName parameterName) {
                throw new UnsupportedOperationException();
            }

            @Override
            public String toString() {
                return this.method() + " " + this.url() + " " + parameters();
            }
        };
        final HttpHandler httpHandler = router.route(request.routerParameters())
                .orElseThrow(() -> new Error("Unable to route"));

        final HttpResponse response = HttpResponses.recording();
        httpHandler.handle(request, response);
        checkEquals(
                "{\n" +
                        "  \"type\": \"test-HateosResource\",\n" +
                        "  \"value\": {\n" +
                        "    \"id\": \"31\"\n" +
                        "  }\n" +
                        "}",
                response.entities()
                        .get(0)
                        .bodyText()
        );
    }

Replace Anonymous With Lambda test.TestGwtTest.testHateosResourceMapping.mapping.setHateosResourceHandler.new FakeHateosResourceHandler<> with (s, x) -> {return HateosResourceSelection.one(BigInteger.valueOf(Integer.parseInt(s.substring(2),16))); in method public testHateosResourceMapping() : void from class test.TestGwtTest


    @Test
    public void testHateosResourceMapping()  {
        final HateosResourceMapping<BigInteger, TestResource, TestResource, TestHateosResource, TestHateosResourceHandlerContext> mapping = HateosResourceMapping.with(HateosResourceName.with("resource1"),
                (s, x) -> {
                    return HateosResourceSelection.one(
                            BigInteger.valueOf(
                                    Integer.parseInt(
                                            s.substring(2),
                                            16
                                    )
                            )
                    ); // assumes hex digit in url
                },
                TestResource.class,
                TestResource.class,
                TestHateosResource.class,
                TestHateosResourceHandlerContext.class
        ).setHateosResourceHandler(
                LinkRelation.CONTENTS,
                HttpMethod.POST,
                new FakeHateosResourceHandler<>() {
                    @Override
                    public Optional<TestResource> handleOne(final BigInteger id,
                                                            final Optional<TestResource> resource,
                                                            final Map<HttpRequestAttribute<?>, Object> parameters,
                                                            final TestHateosResourceHandlerContext context) {
                        return Optional.of(
                                TestResource.with(
                                        TestHateosResource.with(
                                                BigInteger.valueOf(31)
                                        )
                                )
                        );
                    }
                }
        );

        final Router<HttpRequestAttribute<?>, HttpHandler> router = HateosResourceMapping.router(
                AbsoluteUrl.parseAbsolute("http://www.example.com/api"),
                Sets.of(mapping),
                Indentation.SPACES2,
                LineEnding.NL,
                new TestHateosResourceHandlerContext()
        );

        final HttpRequest request = new FakeHttpRequest() {

            @Override
            public HttpTransport transport() {
                return HttpTransport.UNSECURED;
            }

            @Override
            public HttpProtocolVersion protocolVersion() {
                return HttpProtocolVersion.VERSION_1_0;
            }

            @Override
            public HttpMethod method() {
                return HttpMethod.POST;
            }

            @Override
            public RelativeUrl url() {
                return Url.parseRelative("/api/resource1/0x123/contents");
            }

            @Override
            public Map<HttpHeaderName<?>, List<?>> headers() {
                return Maps.of(
                        HttpHeaderName.CONTENT_TYPE, Lists.of(TestHateosResourceHandlerContext.CONTENT_TYPE),
                        HttpHeaderName.ACCEPT, Lists.of(TestHateosResourceHandlerContext.CONTENT_TYPE.accept()),
                        HttpHeaderName.ACCEPT_CHARSET, Lists.of(AcceptCharset.parse("utf-8"))
                );
            }

            public String bodyText() {
                return "";
            }

            @Override
            public Map<HttpRequestParameterName, List<String>> parameters() {
                return Maps.empty();
            }

            @Override
            public List<String> parameterValues(final HttpRequestParameterName parameterName) {
                throw new UnsupportedOperationException();
            }

            @Override
            public String toString() {
                return this.method() + " " + this.url() + " " + parameters();
            }
        };
        final HttpHandler httpHandler = router.route(request.routerParameters())
                .orElseThrow(() -> new Error("Unable to route"));

        final HttpResponse response = HttpResponses.recording();
        httpHandler.handle(request, response);
        checkEquals(
                "{\n" +
                        "  \"type\": \"test-HateosResource\",\n" +
                        "  \"value\": {\n" +
                        "    \"id\": \"31\"\n" +
                        "  }\n" +
                        "}",
                response.entities()
                        .get(0)
                        .bodyText()
        );
    }

    @Test
    public void testHateosResourceMapping()  {
        final HateosResourceMapping<BigInteger, TestResource, TestResource, TestHateosResource, TestHateosResourceHandlerContext> mapping = HateosResourceMapping.with(HateosResourceName.with("resource1"),
                (s) -> {
                    return HateosResourceSelection.one(
                            BigInteger.valueOf(
                                    Integer.parseInt(
                                            s.substring(2),
                                            16
                                    )
                            )
                    ); // assumes hex digit in url
                },
                TestResource.class,
                TestResource.class,
                TestHateosResource.class,
                TestHateosResourceHandlerContext.class
        ).setHateosResourceHandler(
                LinkRelation.CONTENTS,
                HttpMethod.POST,
                new FakeHateosResourceHandler<>() {
                    @Override
                    public Optional<TestResource> handleOne(final BigInteger id,
                                                            final Optional<TestResource> resource,
                                                            final Map<HttpRequestAttribute<?>, Object> parameters,
                                                            final TestHateosResourceHandlerContext context) {
                        return Optional.of(
                                TestResource.with(
                                        TestHateosResource.with(
                                                BigInteger.valueOf(31)
                                        )
                                )
                        );
                    }
                }
        );

        final Router<HttpRequestAttribute<?>, HttpHandler> router = HateosResourceMapping.router(
                AbsoluteUrl.parseAbsolute("http://www.example.com/api"),
                Sets.of(mapping),
                Indentation.SPACES2,
                LineEnding.NL,
                new TestHateosResourceHandlerContext()
        );

        final HttpRequest request = new FakeHttpRequest() {

            @Override
            public HttpTransport transport() {
                return HttpTransport.UNSECURED;
            }

            @Override
            public HttpProtocolVersion protocolVersion() {
                return HttpProtocolVersion.VERSION_1_0;
            }

            @Override
            public HttpMethod method() {
                return HttpMethod.POST;
            }

            @Override
            public RelativeUrl url() {
                return Url.parseRelative("/api/resource1/0x123/contents");
            }

            @Override
            public Map<HttpHeaderName<?>, List<?>> headers() {
                return Maps.of(
                        HttpHeaderName.CONTENT_TYPE, Lists.of(TestHateosResourceHandlerContext.CONTENT_TYPE),
                        HttpHeaderName.ACCEPT, Lists.of(TestHateosResourceHandlerContext.CONTENT_TYPE.accept()),
                        HttpHeaderName.ACCEPT_CHARSET, Lists.of(AcceptCharset.parse("utf-8"))
                );
            }

            public String bodyText() {
                return "";
            }

            @Override
            public Map<HttpRequestParameterName, List<String>> parameters() {
                return Maps.empty();
            }

            @Override
            public List<String> parameterValues(final HttpRequestParameterName parameterName) {
                throw new UnsupportedOperationException();
            }

            @Override
            public String toString() {
                return this.method() + " " + this.url() + " " + parameters();
            }
        };
        final HttpHandler httpHandler = router.route(request.routerParameters())
                .orElseThrow(() -> new Error("Unable to route"));

        final HttpResponse response = HttpResponses.recording();
        httpHandler.handle(request, response);
        checkEquals(
                "{\n" +
                        "  \"type\": \"test-HateosResource\",\n" +
                        "  \"value\": {\n" +
                        "    \"id\": \"31\"\n" +
                        "  }\n" +
                        "}",
                response.entities()
                        .get(0)
                        .bodyText()
        );
    }

Replace Anonymous With Lambda test.JunitTest.testHateosResourceMapping.mapping.setHateosResourceHandler.new FakeHateosResourceHandler<> with (s, x) -> {return HateosResourceSelection.one(BigInteger.valueOf(Integer.parseInt(s.substring(2),16))); in method public testHateosResourceMapping() : void from class test.JunitTest


    @Test
    public void testMapRouteAndCheckStandaloneForItJunitTest() {
        final HateosResourceMapping<BigInteger, TestResource, TestResource, TestHateosResource, TestHateosResourceHandlerContext> mapping = HateosResourceMapping.with(
                HateosResourceName.with("resource-with-body"),
                (s, x) -> {
                    return HateosResourceSelection.one(
                            BigInteger.valueOf(
                                    Integer.parseInt(
                                            s.substring(2),
                                            16
                                    )
                            )
                    ); // assumes hex digit in url
                        },
                        TestResource.class,
                        TestResource.class,
                TestHateosResource.class,
                TestHateosResourceHandlerContext.class
        ).setHateosResourceHandler(
                        LinkRelation.CONTENTS,
                        HttpMethod.POST,
                new FakeHateosResourceHandler<BigInteger, TestResource, TestResource, TestHateosResourceHandlerContext>() {

                            @Override
                            public Optional<TestResource> handleOne(final BigInteger id,
                                                                    final Optional<TestResource> resource,
                                                                    final Map<HttpRequestAttribute<?>, Object> parameters,
                                                                    final TestHateosResourceHandlerContext context) {
                                return Optional.of(
                                        TestResource.with(
                                                TestHateosResource.with(
                                                        BigInteger.valueOf(31)
                                                )
                                        )
                                );
                            }
                }
        );

        final Router<HttpRequestAttribute<?>, HttpHandler> router = HateosResourceMapping.router(
                AbsoluteUrl.parseAbsolute("https://www.example.com/api"),
                Sets.of(mapping),
                INDENTATION,
                LINE_ENDING,
                CONTEXT
        );

        final HttpRequest request = new FakeHttpRequest() {

            @Override
            public HttpTransport transport() {
                return HttpTransport.UNSECURED;
            }

            @Override
            public HttpProtocolVersion protocolVersion() {
                return HttpProtocolVersion.VERSION_1_0;
            }

            @Override
            public HttpMethod method() {
                return HttpMethod.POST;
            }

            @Override
            public RelativeUrl url() {
                return Url.parseRelative("/api/resource-with-body/0x123/contents");
            }

            @Override
            public Map<HttpHeaderName<?>, List<?>> headers() {
                return Maps.of(
                        HttpHeaderName.CONTENT_TYPE, Lists.of(CONTENT_TYPE),
                        HttpHeaderName.ACCEPT, Lists.of(CONTENT_TYPE.accept()),
                        HttpHeaderName.ACCEPT_CHARSET, Lists.of(
                                AcceptCharset.parse("utf-8")
                        )
                );
            }

            @Test
            public String bodyText() {
                return "";
            }

            @Override
            public Map<HttpRequestParameterName, List<String>> parameters() {
                return Maps.empty();
            }

            @Override
            public List<String> parameterValues(final HttpRequestParameterName parameterName) {
                throw new UnsupportedOperationException();
            }

            @Override
            public String toString() {
                return this.method() + " " + this.url() + " " + parameters();
            }
        };
        final HttpHandler httpHandler = router.route(
                request.routerParameters()
        ).orElseThrow(
                () -> new Error("Unable to route")
        );

        final HttpResponse response = HttpResponses.recording();
        httpHandler.handle(request, response);
        this.checkEquals("{\n" +
                "  \"type\": \"test-HateosResource\",\n" +
                "  \"value\": {\n" +
                "    \"id\": \"31\"\n" +
                "  }\n" +
                "}", response.entities().get(0).bodyText());
    }

    @Test
    public void testMapRouteAndCheckStandaloneForItJunitTest() {
        final HateosResourceMapping<BigInteger, TestResource, TestResource, TestHateosResource, TestHateosResourceHandlerContext> mapping = HateosResourceMapping.with(
                HateosResourceName.with("resource-with-body"),
                        (s) -> {
                            return HateosResourceSelection.one(BigInteger.valueOf(Integer.parseInt(s.substring(2), 16))); // assumes hex digit in url
                        },
                        TestResource.class,
                        TestResource.class,
                TestHateosResource.class,
                TestHateosResourceHandlerContext.class
        ).setHateosResourceHandler(
                        LinkRelation.CONTENTS,
                        HttpMethod.POST,
                new FakeHateosResourceHandler<BigInteger, TestResource, TestResource, TestHateosResourceHandlerContext>() {

                            @Override
                            public Optional<TestResource> handleOne(final BigInteger id,
                                                                    final Optional<TestResource> resource,
                                                                    final Map<HttpRequestAttribute<?>, Object> parameters,
                                                                    final TestHateosResourceHandlerContext context) {
                                return Optional.of(
                                        TestResource.with(
                                                TestHateosResource.with(
                                                        BigInteger.valueOf(31)
                                                )
                                        )
                                );
                            }
                }
        );

        final Router<HttpRequestAttribute<?>, HttpHandler> router = HateosResourceMapping.router(
                AbsoluteUrl.parseAbsolute("https://www.example.com/api"),
                Sets.of(mapping),
                INDENTATION,
                LINE_ENDING,
                CONTEXT
        );

        final HttpRequest request = new FakeHttpRequest() {

            @Override
            public HttpTransport transport() {
                return HttpTransport.UNSECURED;
            }

            @Override
            public HttpProtocolVersion protocolVersion() {
                return HttpProtocolVersion.VERSION_1_0;
            }

            @Override
            public HttpMethod method() {
                return HttpMethod.POST;
            }

            @Override
            public RelativeUrl url() {
                return Url.parseRelative("/api/resource-with-body/0x123/contents");
            }

            @Override
            public Map<HttpHeaderName<?>, List<?>> headers() {
                return Maps.of(
                        HttpHeaderName.CONTENT_TYPE, Lists.of(CONTENT_TYPE),
                        HttpHeaderName.ACCEPT, Lists.of(CONTENT_TYPE.accept()),
                        HttpHeaderName.ACCEPT_CHARSET, Lists.of(
                                AcceptCharset.parse("utf-8")
                        )
                );
            }

            @Test
            public String bodyText() {
                return "";
            }

            @Override
            public Map<HttpRequestParameterName, List<String>> parameters() {
                return Maps.empty();
            }

            @Override
            public List<String> parameterValues(final HttpRequestParameterName parameterName) {
                throw new UnsupportedOperationException();
            }

            @Override
            public String toString() {
                return this.method() + " " + this.url() + " " + parameters();
            }
        };
        final HttpHandler httpHandler = router.route(
                request.routerParameters()
        ).orElseThrow(
                () -> new Error("Unable to route")
        );

        final HttpResponse response = HttpResponses.recording();
        httpHandler.handle(request, response);
        this.checkEquals("{\n" +
                "  \"type\": \"test-HateosResource\",\n" +
                "  \"value\": {\n" +
                "    \"id\": \"31\"\n" +
                "  }\n" +
                "}", response.entities().get(0).bodyText());
    }

Replace Anonymous With Lambda walkingkooka.net.http.server.hateos.HateosResourceMappingRouterTest.testMapRouteAndCheckStandaloneForItJunitTest.mapping.setHateosResourceHandler.new FakeHateosResourceHandler<BigInteger,TestResource,TestResource,TestHateosResourceHandlerContext> with (s, x) -> {return HateosResourceSelection.one(BigInteger.valueOf(Integer.parseInt(s.substring(2),16))); in method public testMapRouteAndCheckStandaloneForItJunitTest() : void from class walkingkooka.net.http.server.hateos.HateosResourceMappingRouterTest


    @Test
    public void testSetHateosHttpEntityHandlerAndRoute() {
        final MediaType mediaType = MediaType.TEXT_PLAIN;

        final HateosResourceMapping<BigInteger, TestResource, TestResource, TestHateosResource, TestHateosResourceHandlerContext> mapping = HateosResourceMapping.with(
                        HateosResourceName.with("resource-with-body"),
                (s, x) -> {
                            return HateosResourceSelection.one(
                                    BigInteger.valueOf(
                                            Integer.parseInt(
                                                    s.substring(2),
                                                    16
                                            )
                                    )
                            ); // assumes hex digit in url
                        },
                        TestResource.class,
                        TestResource.class,
                TestHateosResource.class,
                TestHateosResourceHandlerContext.class
        ).setHateosHttpEntityHandler(
                        LinkRelation.CONTENTS,
                        HttpMethod.POST,
                new FakeHateosHttpEntityHandler<BigInteger, TestHateosResourceHandlerContext>() {
                            @Override
                            public HttpEntity handleOne(final BigInteger id,
                                                        final HttpEntity entity,
                                                        final Map<HttpRequestAttribute<?>, Object> parameters,
                                                        final TestHateosResourceHandlerContext context) {
                                checkEquals(
                                        mediaType,
                                        HttpHeaderName.CONTENT_TYPE.headerOrFail(entity)
                                );
                                return HttpEntity.EMPTY.setBodyText(
                                        id +
                                                "\n" +
                                                entity.bodyText()
                                );
                            }
                }
        );

        final Router<HttpRequestAttribute<?>, HttpHandler> router = HateosResourceMapping.router(
                AbsoluteUrl.parseAbsolute("https://www.example.com/api"),
                Sets.of(mapping),
                INDENTATION,
                LINE_ENDING,
                CONTEXT
        );

        final HttpRequest request = new FakeHttpRequest() {

            @Override
            public HttpTransport transport() {
                return HttpTransport.UNSECURED;
            }

            @Override
            public HttpProtocolVersion protocolVersion() {
                return HttpProtocolVersion.VERSION_1_0;
            }

            @Override
            public HttpMethod method() {
                return HttpMethod.POST;
            }

            @Override
            public RelativeUrl url() {
                return Url.parseRelative("/api/resource-with-body/0x123/contents");
            }

            @Override
            public Map<HttpHeaderName<?>, List<?>> headers() {
                return Maps.of(
                        HttpHeaderName.CONTENT_TYPE, Lists.of(mediaType),
                        HttpHeaderName.ACCEPT, Lists.of(mediaType.accept()),
                        HttpHeaderName.ACCEPT_CHARSET, Lists.of(AcceptCharset.parse("utf-8"))
                );
            }

            @Override
            public byte[] body() {
                return this.bodyText()
                        .getBytes(StandardCharsets.UTF_8);
            }

            @Test
            public String bodyText() {
                return "RequestBodyText123";
            }

            @Override
            public Map<HttpRequestParameterName, List<String>> parameters() {
                return Maps.empty();
            }

            @Override
            public List<String> parameterValues(final HttpRequestParameterName parameterName) {
                throw new UnsupportedOperationException();
            }

            @Override
            public String toString() {
                return this.method() + " " + this.url() + " " + parameters();
            }
        };
        final HttpHandler httpHandler = router.route(
                request.routerParameters()
        ).orElseThrow(
                () -> new Error("Unable to route")
        );

        final HttpResponse response = HttpResponses.recording();
        httpHandler.handle(request, response);
        this.checkEquals(
                "291\n" + // 0x123
                        "RequestBodyText123",
                response.entities()
                        .get(0)
                        .bodyText()
        );
    }

    @Test
    public void testSetHateosHttpEntityHandlerAndRoute() {
        final MediaType mediaType = MediaType.TEXT_PLAIN;

        final HateosResourceMapping<BigInteger, TestResource, TestResource, TestHateosResource, TestHateosResourceHandlerContext> mapping = HateosResourceMapping.with(
                        HateosResourceName.with("resource-with-body"),
                        (s) -> {
                            return HateosResourceSelection.one(
                                    BigInteger.valueOf(
                                            Integer.parseInt(
                                                    s.substring(2),
                                                    16
                                            )
                                    )
                            ); // assumes hex digit in url
                        },
                        TestResource.class,
                        TestResource.class,
                TestHateosResource.class,
                TestHateosResourceHandlerContext.class
        ).setHateosHttpEntityHandler(
                        LinkRelation.CONTENTS,
                        HttpMethod.POST,
                new FakeHateosHttpEntityHandler<BigInteger, TestHateosResourceHandlerContext>() {
                            @Override
                            public HttpEntity handleOne(final BigInteger id,
                                                        final HttpEntity entity,
                                                        final Map<HttpRequestAttribute<?>, Object> parameters,
                                                        final TestHateosResourceHandlerContext context) {
                                checkEquals(
                                        mediaType,
                                        HttpHeaderName.CONTENT_TYPE.headerOrFail(entity)
                                );
                                return HttpEntity.EMPTY.setBodyText(
                                        id +
                                                "\n" +
                                                entity.bodyText()
                                );
                            }
                }
        );

        final Router<HttpRequestAttribute<?>, HttpHandler> router = HateosResourceMapping.router(
                AbsoluteUrl.parseAbsolute("https://www.example.com/api"),
                Sets.of(mapping),
                INDENTATION,
                LINE_ENDING,
                CONTEXT
        );

        final HttpRequest request = new FakeHttpRequest() {

            @Override
            public HttpTransport transport() {
                return HttpTransport.UNSECURED;
            }

            @Override
            public HttpProtocolVersion protocolVersion() {
                return HttpProtocolVersion.VERSION_1_0;
            }

            @Override
            public HttpMethod method() {
                return HttpMethod.POST;
            }

            @Override
            public RelativeUrl url() {
                return Url.parseRelative("/api/resource-with-body/0x123/contents");
            }

            @Override
            public Map<HttpHeaderName<?>, List<?>> headers() {
                return Maps.of(
                        HttpHeaderName.CONTENT_TYPE, Lists.of(mediaType),
                        HttpHeaderName.ACCEPT, Lists.of(mediaType.accept()),
                        HttpHeaderName.ACCEPT_CHARSET, Lists.of(AcceptCharset.parse("utf-8"))
                );
            }

            @Override
            public byte[] body() {
                return this.bodyText()
                        .getBytes(StandardCharsets.UTF_8);
            }

            @Test
            public String bodyText() {
                return "RequestBodyText123";
            }

            @Override
            public Map<HttpRequestParameterName, List<String>> parameters() {
                return Maps.empty();
            }

            @Override
            public List<String> parameterValues(final HttpRequestParameterName parameterName) {
                throw new UnsupportedOperationException();
            }

            @Override
            public String toString() {
                return this.method() + " " + this.url() + " " + parameters();
            }
        };
        final HttpHandler httpHandler = router.route(
                request.routerParameters()
        ).orElseThrow(
                () -> new Error("Unable to route")
        );

        final HttpResponse response = HttpResponses.recording();
        httpHandler.handle(request, response);
        this.checkEquals(
                "291\n" + // 0x123
                        "RequestBodyText123",
                response.entities()
                        .get(0)
                        .bodyText()
        );
    }

Replace Anonymous With Lambda walkingkooka.net.http.server.hateos.HateosResourceMappingRouterTest.testSetHateosHttpEntityHandlerAndRoute.mapping.setHateosHttpEntityHandler.new FakeHateosHttpEntityHandler<BigInteger,TestHateosResourceHandlerContext> with (s, x) -> {return HateosResourceSelection.one(BigInteger.valueOf(Integer.parseInt(s.substring(2),16))); in method public testSetHateosHttpEntityHandlerAndRoute() : void from class walkingkooka.net.http.server.hateos.HateosResourceMappingRouterTest