/**
	 * Returns a BmpDecoderIterator from a File.
	 *
	 * @throws BmpHeaderException
	 *             if this file does not appear to be a valid BMP image.
	 * @throws IOException
	 *             if an IO problem occurs.
	 */
	public static BmpDecoderIterator get(File file) throws IOException {
		try (InputStream in = new FileInputStream(file)) {
			return get(in);
		}
	}

/**
	 * Returns a BmpDecoderIterator from a File.
	 *
	 * @throws BmpHeaderException
	 *             if this file does not appear to be a valid BMP image.
	 * @throws IOException
	 *             if an IO problem occurs.
	 */
	public static BmpDecoderIterator get(File file) throws IOException {
		FileInputStream in = null;
		try {
			in = new FileInputStream(file);
			return get(in);
		} catch (IOException e) {
			if (in != null) {
				in.close();
			}
			throw e;
		}
	}

Try With Resources try(InputStream in=new FileInputStream(file)) in method public get(file File) : BmpDecoderIterator from class com.pump.image.bmp.BmpDecoderIterator


    private void updateDatabase() {
        try (Connection c = ds.getConnection()) {
            core.debug("A database connection was opened.");
            String Data
                    = "CREATE TABLE IF NOT EXISTS `Data`"
                    + "(`uuid` VARCHAR(50),"
                    + "`nick` VARCHAR(50),"
                    + "`balance` DOUBLE,"
                    + "`lastlogin` LONG);";
            String Multiplier = "CREATE TABLE IF NOT EXISTS `Multipliers`"
                    + "(`id` INTEGER PRIMARY KEY AUTOINCREMENT,"
                    + "`uuid` VARCHAR(50),"
                    + "`multiplier` INT,"
                    + "`queue` INT,"
                    + "`minutes` INT,"
                    + "`endtime` LONG,"
                    + "`server` VARCHAR(50),"
                    + "`enabled` BOOLEAN);";
            c.createStatement().executeUpdate(Data);
            core.debug("The data table was updated.");
            c.createStatement().executeUpdate(Multiplier);
            core.debug("The multipliers table was updated");
            if (core.getConfig().getBoolean("General.Purge.Enabled", true)) {
                c.createStatement().executeUpdate("DELETE FROM Data WHERE lastlogin < " + (System.currentTimeMillis() - (core.getConfig().getInt("General.Purge.Days") * 86400000)) + ";");
                core.debug("Inactive users were removed from the database.");
            }
        } catch (SQLException ex) {
            core.log("Something was wrong creating the default databases. Please check the debug log.");
            core.debug("The error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

    private void updateDatabase() {
        try {
            core.debug("A database connection was opened.");
            String Data
                    = "CREATE TABLE IF NOT EXISTS `Data`"
                    + "(`uuid` VARCHAR(50),"
                    + "`nick` VARCHAR(50),"
                    + "`balance` DOUBLE,"
                    + "`lastlogin` LONG);";
            String Multiplier = "CREATE TABLE IF NOT EXISTS `Multipliers`"
                    + "(`id` INTEGER PRIMARY KEY AUTOINCREMENT,"
                    + "`uuid` VARCHAR(50),"
                    + "`multiplier` INT,"
                    + "`queue` INT,"
                    + "`minutes` INT,"
                    + "`endtime` LONG,"
                    + "`server` VARCHAR(50),"
                    + "`enabled` BOOLEAN);";
            getConnection().createStatement().executeUpdate(Data);
            core.debug("The data table was updated.");
            getConnection().createStatement().executeUpdate(Multiplier);
            core.debug("The multipliers table was updated");
            if (core.getConfig().getBoolean("General.Purge.Enabled", true)) {
                getConnection().createStatement().executeUpdate("DELETE FROM Data WHERE lastlogin < " + (System.currentTimeMillis() - (core.getConfig().getInt("General.Purge.Days") * 86400000)) + ";");
                core.debug("Inactive users were removed from the database.");
            }
        } catch (SQLException ex) {
            core.log("Something was wrong creating the default databases. Please check the debug log.");
            core.debug("The error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

Try With Resources try(Connection c=ds.getConnection()) in method private updateDatabase() : void from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public Double getCoins(String player) {
        double coins = -1;
        try (Connection c = ds.getConnection()) {
            ResultSet res = Utils.generatePreparedStatement(c, SQLQuery.SEARCH_USER_OFFLINE, player).executeQuery();
            if (res.next() && res.getString("uuid") != null) {
                coins = res.getDouble("balance");
            } else {
                coins = core.getConfig().getDouble("General.Starting Coins", 0);
                createPlayer(c, player, core.getUUID(player), coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred creating the data for player: " + player);
            core.debug("The error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return coins;
    }

    @Override
    public Double getCoins(String player) {
        double coins = -1;
        try {
            ResultSet res = Utils.generatePreparedStatement(getConnection(), SQLQuery.SEARCH_USER_OFFLINE, player).executeQuery();
            if (res.next() && res.getString("uuid") != null) {
                coins = res.getDouble("balance");
            } else {
                coins = core.getConfig().getDouble("General.Starting Coins", 0);
                createPlayer(getConnection(), player, core.getUUID(player), coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred creating the data for player: " + player);
            core.debug("The error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return coins;
    }

Try With Resources try(Connection c=ds.getConnection()) in method public getCoins(player String) : Double from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public void addCoins(String player, Double coins) {
        try (Connection c = ds.getConnection()) {
            if (isindb(player) && getCoins(player) >= 0) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(c, SQLQuery.UPDATE_COINS_OFFLINE, oldCoins + coins, player).executeUpdate();
                getCoins(player);
                core.getMethods().callCoinsChangeEvent(core.getUUID(player), oldCoins, oldCoins + coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred adding coins to the player: " + player);
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

    @Override
    public void addCoins(String player, Double coins) {
        try {
            if (isindb(player) && getCoins(player) >= 0) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(getConnection(), SQLQuery.UPDATE_COINS_OFFLINE, oldCoins + coins, player).executeUpdate();
                getCoins(player);
                core.getMethods().callCoinsChangeEvent(core.getUUID(player), oldCoins, oldCoins + coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred adding coins to the player: " + player);
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

Try With Resources try(Connection c=ds.getConnection()) in method public addCoins(player String, coins Double) : void from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public void takeCoins(String player, Double coins) {
        try (Connection c = ds.getConnection()) {
            double beforeCoins = getCoins(player);
            if (beforeCoins - coins < 0 || beforeCoins == coins) {
                Utils.generatePreparedStatement(c, SQLQuery.UPDATE_COINS_OFFLINE, 0, player).executeUpdate();
                CacheManager.updateCoins(core.getUUID(player), 0D);
            } else {
                Utils.generatePreparedStatement(c, SQLQuery.UPDATE_COINS_OFFLINE, beforeCoins - coins, player).executeUpdate();
                getCoins(player);
            }
            core.getMethods().callCoinsChangeEvent(core.getUUID(player), beforeCoins, beforeCoins - coins);
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred taking coins to the player: " + player);
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

    @Override
    public void takeCoins(String player, Double coins) {
        try {
            double beforeCoins = getCoins(player);
            if (beforeCoins - coins < 0 || beforeCoins == coins) {
                Utils.generatePreparedStatement(getConnection(), SQLQuery.UPDATE_COINS_OFFLINE, 0, player).executeUpdate();
                CacheManager.updateCoins(core.getUUID(player), 0D);
            } else {
                Utils.generatePreparedStatement(getConnection(), SQLQuery.UPDATE_COINS_OFFLINE, beforeCoins - coins, player).executeUpdate();
                getCoins(player);
            }
            core.getMethods().callCoinsChangeEvent(core.getUUID(player), beforeCoins, beforeCoins - coins);
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred taking coins to the player: " + player);
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

Try With Resources try(Connection c=ds.getConnection()) in method public takeCoins(player String, coins Double) : void from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public void resetCoins(String player) {
        try (Connection c = ds.getConnection()) {
            if (isindb(player)) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(c, SQLQuery.UPDATE_COINS_OFFLINE, core.getConfig().getDouble("General.Starting Coins", 0), player).executeUpdate();
                CacheManager.updateCoins(core.getUUID(player), core.getConfig().getDouble("General.Starting Coins"));
                core.getMethods().callCoinsChangeEvent(core.getUUID(player), oldCoins, core.getConfig().getDouble("General.Starting Coins"));
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred reseting the coins of player: " + player);
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

    @Override
    public void resetCoins(String player) {
        try {
            if (isindb(player)) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(getConnection(), SQLQuery.UPDATE_COINS_OFFLINE, core.getConfig().getDouble("General.Starting Coins", 0), player).executeUpdate();
                CacheManager.updateCoins(core.getUUID(player), core.getConfig().getDouble("General.Starting Coins"));
                core.getMethods().callCoinsChangeEvent(core.getUUID(player), oldCoins, core.getConfig().getDouble("General.Starting Coins"));
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred reseting the coins of player: " + player);
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

Try With Resources try(Connection c=ds.getConnection()) in method public resetCoins(player String) : void from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public void setCoins(String player, Double coins) {
        try (Connection c = ds.getConnection()) {
            if (isindb(player)) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(c, SQLQuery.UPDATE_COINS_ONLINE, coins, player).executeUpdate();
                CacheManager.updateCoins(core.getUUID(player), coins);
                core.getMethods().callCoinsChangeEvent(core.getUUID(player), oldCoins, coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred setting the coins of player: " + player);
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

    @Override
    public void setCoins(String player, Double coins) {
        try {
            if (isindb(player)) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(getConnection(), SQLQuery.UPDATE_COINS_ONLINE, coins, player).executeUpdate();
                CacheManager.updateCoins(core.getUUID(player), coins);
                core.getMethods().callCoinsChangeEvent(core.getUUID(player), oldCoins, coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred setting the coins of player: " + player);
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

Try With Resources try(Connection c=ds.getConnection()) in method public setCoins(player String, coins Double) : void from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public boolean isindb(String player) {
        try (Connection c = ds.getConnection()) {
            ResultSet res = Utils.generatePreparedStatement(c, SQLQuery.SEARCH_USER_OFFLINE, player).executeQuery();
            if (res.next()) {
                return res.getString("nick") != null;
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred cheking if the player: " + player + " exists in the database.");
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return false;
    }

    @Override
    public boolean isindb(String player) {
        try {
            ResultSet res = Utils.generatePreparedStatement(getConnection(), SQLQuery.SEARCH_USER_OFFLINE, player).executeQuery();
            if (res.next()) {
                return res.getString("nick") != null;
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred cheking if the player: " + player + " exists in the database.");
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return false;
    }

Try With Resources try(Connection c=ds.getConnection()) in method public isindb(player String) : boolean from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public Double getCoins(UUID player) {
        double coins = -1;
        try (Connection c = ds.getConnection(); ResultSet res = Utils.generatePreparedStatement(c, SQLQuery.SEARCH_USER_ONLINE, player).executeQuery()) {
            if (res.next() && res.getString("uuid") != null) {
                coins = res.getDouble("balance");
            } else {
                coins = core.getConfig().getDouble("General.Starting Coins", 0);
                createPlayer(c, core.getNick(player), player, coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred creating the data for player: " + core.getNick(player));
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return coins;
    }

    @Override
    public Double getCoins(UUID player) {
        double coins = -1;
        try {
            ResultSet res = Utils.generatePreparedStatement(getConnection(), SQLQuery.SEARCH_USER_ONLINE, player).executeQuery();
            if (res.next() && res.getString("uuid") != null) {
                coins = res.getDouble("balance");
            } else {
                coins = core.getConfig().getDouble("General.Starting Coins", 0);
                createPlayer(getConnection(), core.getNick(player), player, coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred creating the data for player: " + core.getNick(player));
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return coins;
    }

Try With Resources try(Connection c=ds.getConnection(); ResultSet res=Utils.generatePreparedStatement(c,SQLQuery.SEARCH_USER_ONLINE,player).executeQuery()) in method public getCoins(player UUID) : Double from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public void addCoins(UUID player, Double coins) {
        try (Connection c = ds.getConnection()) {
            if (isindb(player) && getCoins(player) >= 0) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(c, SQLQuery.UPDATE_COINS_ONLINE, oldCoins + coins, player).executeUpdate();
                getCoins(player);
                core.getMethods().callCoinsChangeEvent(player, oldCoins, oldCoins + coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred adding coins to the player: " + core.getNick(player));
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

    @Override
    public void addCoins(UUID player, Double coins) {
        try {
            if (isindb(player) && getCoins(player) >= 0) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(getConnection(), SQLQuery.UPDATE_COINS_ONLINE, oldCoins + coins, player).executeUpdate();
                getCoins(player);
                core.getMethods().callCoinsChangeEvent(player, oldCoins, oldCoins + coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred adding coins to the player: " + core.getNick(player));
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

Try With Resources try(Connection c=ds.getConnection()) in method public addCoins(player UUID, coins Double) : void from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public void takeCoins(UUID player, Double coins) {
        try (Connection c = ds.getConnection()) {
            double beforeCoins = getCoins(player);
            if (beforeCoins - coins < 0 || beforeCoins == coins) {
                Utils.generatePreparedStatement(c, SQLQuery.UPDATE_COINS_ONLINE, 0, player).executeUpdate();
                CacheManager.updateCoins(player, 0D);
            } else {
                Utils.generatePreparedStatement(c, SQLQuery.UPDATE_COINS_ONLINE, beforeCoins - coins, player).executeUpdate();
                getCoins(player);
            }
            core.getMethods().callCoinsChangeEvent(player, beforeCoins, beforeCoins - coins);
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred taking coins to the player: " + core.getNick(player));
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

    @Override
    public void takeCoins(UUID player, Double coins) {
        try {
            double beforeCoins = getCoins(player);
            if (beforeCoins - coins < 0 || beforeCoins == coins) {
                Utils.generatePreparedStatement(getConnection(), SQLQuery.UPDATE_COINS_ONLINE, 0, player).executeUpdate();
                CacheManager.updateCoins(player, 0D);
            } else {
                Utils.generatePreparedStatement(getConnection(), SQLQuery.UPDATE_COINS_ONLINE, beforeCoins - coins, player).executeUpdate();
                getCoins(player);
            }
            core.getMethods().callCoinsChangeEvent(player, beforeCoins, beforeCoins - coins);
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred taking coins to the player: " + core.getNick(player));
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

Try With Resources try(Connection c=ds.getConnection()) in method public takeCoins(player UUID, coins Double) : void from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public void resetCoins(UUID player) {
        try (Connection c = ds.getConnection()) {
            if (isindb(player)) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(c, SQLQuery.UPDATE_COINS_ONLINE, core.getConfig().getDouble("General.Starting Coins", 0), player).executeUpdate();
                CacheManager.updateCoins(player, core.getConfig().getDouble("General.Starting Coins"));
                core.getMethods().callCoinsChangeEvent(player, oldCoins, core.getConfig().getDouble("General.Starting Coins"));
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred reseting the coins of player: " + core.getNick(player));
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

    @Override
    public void resetCoins(UUID player) {
        try {
            if (isindb(player)) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(getConnection(), SQLQuery.UPDATE_COINS_ONLINE, core.getConfig().getDouble("General.Starting Coins", 0), player).executeUpdate();
                CacheManager.updateCoins(player, core.getConfig().getDouble("General.Starting Coins"));
                core.getMethods().callCoinsChangeEvent(player, oldCoins, core.getConfig().getDouble("General.Starting Coins"));
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred reseting the coins of player: " + core.getNick(player));
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

Try With Resources try(Connection c=ds.getConnection()) in method public resetCoins(player UUID) : void from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public void setCoins(UUID player, Double coins) {
        try (Connection c = ds.getConnection()) {
            if (isindb(player)) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(c, SQLQuery.UPDATE_COINS_ONLINE, coins, player).executeUpdate();
                CacheManager.updateCoins(player, coins);
                core.getMethods().callCoinsChangeEvent(player, oldCoins, coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred setting the coins of player: " + core.getNick(player));
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

    @Override
    public void setCoins(UUID player, Double coins) {
        try {
            if (isindb(player)) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(getConnection(), SQLQuery.UPDATE_COINS_ONLINE, coins, player).executeUpdate();
                CacheManager.updateCoins(player, coins);
                core.getMethods().callCoinsChangeEvent(player, oldCoins, coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred setting the coins of player: " + core.getNick(player));
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

Try With Resources try(Connection c=ds.getConnection()) in method public setCoins(player UUID, coins Double) : void from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public boolean isindb(UUID player) {
        try (Connection c = ds.getConnection(); ResultSet res = Utils.generatePreparedStatement(c, SQLQuery.SEARCH_USER_ONLINE, player).executeQuery()) {
            if (res.next()) {
                return res.getString("nick") != null;
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred cheking if the player: " + player + " exists in the database.");
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return false;
    }

    @Override
    public boolean isindb(UUID player) {
        try {
            ResultSet res = Utils.generatePreparedStatement(getConnection(), SQLQuery.SEARCH_USER_ONLINE, player).executeQuery();
            if (res.next()) {
                return res.getString("nick") != null;
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred cheking if the player: " + player + " exists in the database.");
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return false;
    }

Try With Resources try(Connection c=ds.getConnection(); ResultSet res=Utils.generatePreparedStatement(c,SQLQuery.SEARCH_USER_ONLINE,player).executeQuery()) in method public isindb(player UUID) : boolean from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public List<String> getTop(int top) {
        List<String> toplist = new ArrayList<>();
        try (Connection c = ds.getConnection(); ResultSet res = Utils.generatePreparedStatement(c, SQLQuery.SELECT_TOP, top).executeQuery()) {
            while (res.next()) {
                String playername = res.getString("nick");
                int coins = (int) res.getDouble("balance");
                toplist.add(playername + ", " + coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred generating the toplist");
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return toplist;
    }

    @Override
    public List<String> getTop(int top) {
        List<String> toplist = new ArrayList<>();
        try {
            ResultSet res = Utils.generatePreparedStatement(getConnection(), SQLQuery.SELECT_TOP, top).executeQuery();
            while (res.next()) {
                String playername = res.getString("nick");
                int coins = (int) res.getDouble("balance");
                toplist.add(playername + ", " + coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred generating the toplist");
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return toplist;
    }

Try With Resources try(Connection c=ds.getConnection(); ResultSet res=Utils.generatePreparedStatement(c,SQLQuery.SELECT_TOP,top).executeQuery()) in method public getTop(top int) : List<String> from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public Map<String, Double> getTopPlayers(int top) {
        Map<String, Double> topplayers = new HashMap<>();
        try (Connection c = ds.getConnection(); ResultSet res = Utils.generatePreparedStatement(c, SQLQuery.SELECT_TOP, top).executeQuery()) {
            while (res.next()) {
                String playername = res.getString("nick");
                double coins = res.getDouble("balance");
                topplayers.put(playername, coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred generating the toplist");
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return Utils.sortByValue(topplayers);
    }

    @Override
    public Map<String, Double> getTopPlayers(int top) {
        Map<String, Double> topplayers = new HashMap<>();
        try {
            ResultSet res = Utils.generatePreparedStatement(getConnection(), SQLQuery.SELECT_TOP, top).executeQuery();
            while (res.next()) {
                String playername = res.getString("nick");
                double coins = res.getDouble("balance");
                topplayers.put(playername, coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred generating the toplist");
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return Utils.sortByValue(topplayers);
    }

Try With Resources try(Connection c=ds.getConnection(); ResultSet res=Utils.generatePreparedStatement(c,SQLQuery.SELECT_TOP,top).executeQuery()) in method public getTopPlayers(top int) : Map<String,Double> from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public String getNick(UUID uuid) {
        try (Connection c = ds.getConnection(); ResultSet res = Utils.generatePreparedStatement(c, SQLQuery.SEARCH_USER_ONLINE, uuid).executeQuery()) {
            if (res.next()) {
                return res.getString("nick");
            }
        } catch (SQLException ex) {
            core.log("Something was wrong getting the nick for the uuid '" + uuid + "'");
            core.debug("The error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return null;
    }

    @Override
    public String getNick(UUID uuid) {
        try {
            ResultSet res = Utils.generatePreparedStatement(getConnection(), SQLQuery.SEARCH_USER_ONLINE, uuid).executeQuery();
            if (res.next()) {
                return res.getString("nick");
            }
        } catch (SQLException ex) {
            core.log("Something was wrong getting the nick for the uuid '" + uuid + "'");
            core.debug("The error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return null;
    }

Try With Resources try(Connection c=ds.getConnection(); ResultSet res=Utils.generatePreparedStatement(c,SQLQuery.SEARCH_USER_ONLINE,uuid).executeQuery()) in method public getNick(uuid UUID) : String from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public UUID getUUID(String nick) {
        try (Connection c = ds.getConnection(); ResultSet res = Utils.generatePreparedStatement(c, SQLQuery.SEARCH_USER_OFFLINE, nick).executeQuery()) {
            if (res.next()) {
                return UUID.fromString(res.getString("uuid"));
            }
        } catch (SQLException ex) {
            core.log("Something was wrong getting the uuid for the nick '" + nick + "'");
            core.debug("The error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return null;
    }

    @Override
    public UUID getUUID(String nick) {
        try {
            ResultSet res = Utils.generatePreparedStatement(getConnection(), SQLQuery.SEARCH_USER_OFFLINE, nick).executeQuery();
            if (res.next()) {
                return UUID.fromString(res.getString("uuid"));
            }
        } catch (SQLException ex) {
            core.log("Something was wrong getting the uuid for the nick '" + nick + "'");
            core.debug("The error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return null;
    }

Try With Resources try(Connection c=ds.getConnection(); ResultSet res=Utils.generatePreparedStatement(c,SQLQuery.SEARCH_USER_OFFLINE,nick).executeQuery()) in method public getUUID(nick String) : UUID from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public Map<String, Double> getAllPlayers() {
        Map<String, Double> data = new HashMap<>();
        try (Connection c = ds.getConnection(); ResultSet res = c.prepareStatement("SELECT * FROM Data;").executeQuery()) {
            while (res.next()) {
                data.put(res.getString("nick") + "," + res.getString("uuid"), res.getDouble("balance"));
            }
        } catch (SQLException ex) {
            core.debug("An error has ocurred getting all the players from the database");
            core.debug(ex);
        }
        return data;
    }

    @Override
    public Map<String, Double> getAllPlayers() {
        Map<String, Double> data = new HashMap<>();
        try {
            ResultSet res = getConnection().prepareStatement("SELECT * FROM Data;").executeQuery();
            while (res.next()) {
                data.put(res.getString("nick") + "," + res.getString("uuid"), res.getDouble("balance"));
            }
        } catch (SQLException ex) {
            core.debug("An error has ocurred getting all the players from the database");
            core.debug(ex);
        }
        return data;
    }

Try With Resources try(Connection c=ds.getConnection(); ResultSet res=c.prepareStatement("SELECT * FROM Data;").executeQuery()) in method public getAllPlayers() : Map<String,Double> from class net.nifheim.beelzebu.coins.core.database.SQLite


    @Override
    public Double getCoins(String player) {
        try (Connection c = getConnection(); ResultSet res = Utils.generatePreparedStatement(c, SQLQuery.SEARCH_USER_OFFLINE, player).executeQuery();) {
            if (isindb(player)) {
                double coins = res.getDouble("balance");
                CacheManager.updateCoins(core.getUUID(player), coins);
                return coins;
            } else {
                CacheManager.updateCoins(core.getUUID(player), core.getConfig().getDouble("General.Starting Coins", 0));
                createPlayer(player, core.getUUID(player));
                return core.getConfig().getDouble("General.Starting Coins", 0);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred creating the data for player: " + player);
            core.debug(ex);
        }
        return 0D;
    }

    @Override
    public Double getCoins(String player) {
        try (Connection c = getConnection()) {
            ResultSet res = null;
            try {
                res = Utils.generatePreparedStatement(c, SQLQuery.SEARCH_USER_OFFLINE, player).executeQuery();
                if (res.next() && res.getString("uuid") != null) {
                    double coins = res.getDouble("balance");
                    CacheManager.updateCoins(core.getUUID(player), coins);
                    return coins;
                } else {
                    CacheManager.updateCoins(core.getUUID(player), 0D);
                    createPlayer(player, core.getUUID(player));
                    return 0D;
                }
            } finally {
                if (res != null) {
                    res.close();
                }
                c.close();
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred creating the data for player: " + player);
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return 0D;
    }

Try With Resources try(Connection c=getConnection(); ResultSet res=Utils.generatePreparedStatement(c,SQLQuery.SEARCH_USER_OFFLINE,player).executeQuery()) in method public getCoins(player String) : Double from class net.nifheim.beelzebu.coins.core.database.MySQL


    @Override
    public Double getCoins(UUID player) {
        try (Connection c = getConnection(); ResultSet res = Utils.generatePreparedStatement(c, SQLQuery.SEARCH_USER_ONLINE, player).executeQuery()) {
            if (isindb(player)) {
                double coins = res.getDouble("balance");
                CacheManager.updateCoins(player, coins);
                return coins;
            } else {
                CacheManager.updateCoins(player, core.getConfig().getDouble("General.Starting Coins", 0));
                createPlayer(core.getNick(player), player);
                return core.getConfig().getDouble("General.Starting Coins", 0);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred creating the data for player: " + core.getNick(player));
            core.debug(ex);
        }
        return 0D;
    }

    @Override
    public Double getCoins(UUID player) {
        try (Connection c = getConnection()) {
            ResultSet res = null;
            try {
                res = Utils.generatePreparedStatement(c, SQLQuery.SEARCH_USER_ONLINE, player).executeQuery();
                if (res.next() && res.getString("uuid") != null) {
                    double coins = res.getDouble("balance");
                    CacheManager.updateCoins(player, coins);
                    return coins;
                } else {
                    CacheManager.updateCoins(player, 0D);
                    createPlayer(core.getNick(player), player);
                    return 0D;
                }
            } finally {
                if (res != null) {
                    res.close();
                }
                c.close();
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred creating the data for player: " + core.getNick(player));
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
        return 0D;
    }

Try With Resources try(Connection c=getConnection(); ResultSet res=Utils.generatePreparedStatement(c,SQLQuery.SEARCH_USER_ONLINE,player).executeQuery()) in method public getCoins(player UUID) : Double from class net.nifheim.beelzebu.coins.core.database.MySQL


    @Override
    public void addCoins(UUID player, Double coins) {
        try (Connection c = getConnection()) {
            if (isindb(player)) {
                double oldCoins = getCoins(player);
                Utils.generatePreparedStatement(c, SQLQuery.UPDATE_COINS_ONLINE, oldCoins + coins, player).executeUpdate();
                core.updateCache(player, getCoins(player));
                core.getMethods().callCoinsChangeEvent(player, oldCoins, oldCoins + coins);
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred adding coins to the player: " + core.getNick(player));
            core.debug(ex);
        }
    }

    @Override
    public void addCoins(UUID player, Double coins) {
        try (Connection c = getConnection()) {
            try {
                if (isindb(player) && getCoins(player) >= 0) {
                    double oldCoins = getCoins(player);
                    Utils.generatePreparedStatement(c, SQLQuery.UPDATE_COINS_ONLINE, oldCoins + coins, player).executeUpdate();
                    core.updateCache(player, getCoins(player));
                    core.getMethods().callCoinsChangeEvent(player, oldCoins, oldCoins + coins);
                }
            } finally {
                c.close();
            }
        } catch (SQLException ex) {
            core.log("&cAn internal error has occurred adding coins to the player: " + core.getNick(player));
            core.debug("&cThe error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

Try With Resources try(Connection c=getConnection()) in method public addCoins(player UUID, coins Double) : void from class net.nifheim.beelzebu.coins.core.database.MySQL


    public void useMultiplier(UUID uuid, Integer id, String server, final MultiplierType type) {
        try (Connection c = getConnection()) {
            ResultSet res = null;
            Boolean enabled = isEnabled();
            try {
                if (!enabled) {
                    res = c.prepareStatement("SELECT * FROM " + PREFIX + "Multipliers WHERE id = " + id + " AND uuid = '" + uuid + "';").executeQuery();
                    if (res.next()) {
                        Long minutes = res.getLong("minutes");
                        Long endtime = System.currentTimeMillis() + (minutes * 60000);
                        switch (type) {
                            case GLOBAL:
                            case PERSONAL:
                                server = type.toString();
                                break;
                            case SERVER:
                            default:
                                break;
                        }
                        c.prepareStatement("UPDATE " + PREFIX + "Multipliers SET endtime = " + endtime + ", enabled = true, server = '" + server + "' WHERE id = " + id + ";").executeUpdate();
                        AMOUNT = res.getInt("multiplier");
                    } else {
                        //p.sendMessage(core.getString("Multipliers.No Multipliers"));
                    }
                }
            } finally {
                if (res != null) {
                    res.close();
                }
                c.close();
            }
        } catch (SQLException ex) {
            core.getMethods().log("&cSomething was wrong when creating a multiplier for " + core.getNick(uuid));
            core.debug("The error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

    public void useMultiplier(UUID uuid, Integer id, String server, final MultiplierType type) {
        try {
            ResultSet res0 = connection.createStatement().executeQuery("SELECT * FROM " + PREFIX + "Multipliers");
            res0.next();
            Boolean enabled = res0.getBoolean("enabled");
            if (!enabled) {
                ResultSet res = connection.createStatement().executeQuery("SELECT * FROM " + PREFIX + "Multipliers WHERE id = " + id + " AND uuid = '" + uuid + "';");
                if (res.next()) {
                    Long minutes = res.getLong("minutes");
                    Long endtime = System.currentTimeMillis() + (minutes * 60000);
                    switch (type) {
                        case GLOBAL:
                            server = type.toString();
                            break;
                        case PERSONAL:
                            server = type.toString();
                            break;
                        case SERVER:
                        default:
                            break;
                    }
                    connection.createStatement().executeUpdate("UPDATE " + PREFIX + "Multipliers SET endtime = " + endtime + ", enabled = true, server = '" + server + "' WHERE id = " + id + ";");
                    //plugin.getConfig().set("Multipliers.Amount", res.getInt("multiplier"));
                    //plugin.saveConfig();
                } else {
                    //p.sendMessage(core.getString("Multipliers.No Multipliers"));
                }
            }
        } catch (SQLException ex) {
            core.getMethods().log("&cSomething was wrong when creating a multiplier for " + core.getNick(uuid));
            core.debug("The error code is: " + ex.getErrorCode());
            core.debug(ex.getMessage());
        }
    }

Try With Resources try(Connection c=getConnection()) in method public useMultiplier(uuid UUID, id Integer, server String, type MultiplierType) : void from class net.nifheim.beelzebu.coins.core.multiplier.Multiplier


    public static void hook(Main plugin) {
        if (Bukkit.getPluginManager().isPluginEnabled("MVdWPlaceHolderAPI")) {
            PlaceholderAPI.registerPlaceholder(plugin, "coins", (PlaceholderReplaceEvent e) -> {
                final Player p = e.getPlayer();
                final OfflinePlayer offp = e.getPlayer();
                if (offp == null) {
                    return "Player is needed!";
                }
                String coins = CoinsAPI.getCoinsString(p);
                if (coins != null) {
                    return coins;
                } else {
                    return "0";
                }
            });
        }
    }

    public static void hook(Main plugin) {
        if (Bukkit.getPluginManager().isPluginEnabled("MVdWPlaceHolderAPI")) {
            PlaceholderAPI.registerPlaceholder(plugin, "coins",
                    new PlaceholderReplacer() {
                        @Override
                        public String onPlaceholderReplace(PlaceholderReplaceEvent e) {
                            final Player p = e.getPlayer();
                            final OfflinePlayer offp = e.getPlayer();
                            if (offp == null) {
                                return "Player is needed!";
                            }
                            String coins = "";
                            try {
                                coins = api.getCoinsString(p);
                            } catch (SQLException ex) {}
                            if (coins != null){
                                return coins;
                            }
                            else {
                            return "0";
                            }
                        }
                    });
        }
    }

Replace Anonymous With Lambda net.nifheim.broxxx.coins.hooks.MVdWPlaceholderAPIHook.hook.registerPlaceholder.new PlaceholderReplacer with (e) -> {final Player p=e.getPlayer(); in method public hook(plugin Main) : void from class net.nifheim.broxxx.coins.hooks.MVdWPlaceholderAPIHook


	protected void readPbfFiles() {
		/** Writer headings */
		try (CSVFileWriter writerQTStructure = new CSVFileWriter("E:/vgi/csv/quadtree_structure.csv")) {
			writerQTStructure.writeLine("geometry;quadtree_path;level;feature_count;border_intersect;");

			/** Read the quadtree index */
			PbfQuadtreeIndex pbfQuadtree = null;

			if (!new File(settings.getPbfDataFolder() + "/Quadtree/index.pbf").exists()) {
				log.error("Cannot find file '" + settings.getPbfDataFolder() + "/Quadtree/index.pbf'");
				return;
			}

			pbfQuadtree = PbfQuadtreeIndex.parseFrom(new FileInputStream(settings.getPbfDataFolder() + "/Quadtree/index.pbf"));

			readPbfQuadtree(pbfQuadtree.getRoot(), writerQTStructure);
		} catch (IOException e) {
			log.error("Error while writing CSV file", e);
		}
	}

	protected void readPbfFiles() {
		/** Writer headings */
		writerQTStructure.writeLine("geometry;quadtree_path;level;feature_count;border_intersect;");

		/** Read the quadtree index */
		PbfQuadtreeIndex pbfQuadtree = null;
		try {

			if (!new File(settings.getPbfDataFolder() + "/Quadtree/index.pbf").exists()) {
				log.error("Cannot find file '" + settings.getPbfDataFolder() + "/Quadtree/index.pbf'");
				return;
			}

			pbfQuadtree = PbfQuadtreeIndex.parseFrom(new FileInputStream(settings.getPbfDataFolder() + "/Quadtree/index.pbf"));

			readPbfQuadtree(pbfQuadtree.getRoot());
		} catch (IOException e) {
			e.printStackTrace();
		}

		/** Close quadtree writer */
		writerQTStructure.closeFile();
	}

Try With Resources try(CSVFileWriter writerQTStructure=new CSVFileWriter("E:/vgi/csv/quadtree_structure.csv")) in method protected readPbfFiles() : void from class at.salzburgresearch.vgi.vgianalyticsframework.activityanalysis.persistence.impl.VgiOperationPbfReaderQuadtreeImpl


	private void read(List<PbfOperationFile> pbfFileList, boolean keepInCache, int firstFileId, int lastFileId) {

		/** Iterate through operation files */
		for (PbfOperationFile file : pbfFileList) {

//			if (!file.getElementType().equals(ElementType.WAY)) continue;
//			if (file.getOperationFileId() < 20360) continue;

			if (filterFileId != -1) {
				if (file.getOperationFileId() != filterFileId) continue;
			}

//			if (startFileId > 1) {
//				if (filterGeometryType == VgiGeometryType.UNDEFINED) {
//					if (file.getOperationFileId() < startFileId) continue;
//				} else {
//					if (file.getOperationFileId() < startFileId && file.getElementType().equals(filterElementType)) continue;
//				}
//			}

			/** Skip files if multi-threading */
			if (file.getOperationFileId() < firstFileId || file.getOperationFileId() > lastFileId) continue;

			/** Does file exist? */
			String elementTypePrefix = "d";
			VgiGeometryType geometryType = VgiGeometryType.UNDEFINED;
			switch (file.getElementType()) {
			case NODE:
				elementTypePrefix = "n";
				geometryType = VgiGeometryType.POINT;
				break;
			case WAY:
				elementTypePrefix = "w";
				geometryType = VgiGeometryType.LINE;
				break;
			case RELATION:
				elementTypePrefix = "r";
				geometryType = VgiGeometryType.RELATION;
				break;
			default: break;
			}

			if (!containsRequestedOperations(file, geometryType)) continue;

			if (!new File(pbfDataFolder + "/operation_" + elementTypePrefix + "_" + file.getOperationFileId() + ".pbf").exists()) {
				log.error(pbfDataFolder + "/operation_" + elementTypePrefix + "_" + file.getOperationFileId() + ".pbf not found!");
				continue;
			}

//			log.info("[" + producerNumber+ ": Pbf " + elementTypePrefix + "_" + file.getOperationFileId() + "/" + pbfFileList.size() + "] Start: NumOps=" + file.getNumEntries() + "; Path=" + pbfDataFolder + "/operation_" + elementTypePrefix + "_" + file.getOperationFileId() + ".pbf");

			/** Initialize variables */
			previousOperationValues = new VgiOperationImpl();
			byteArray = new byte[0];
			byteArrayPointer = 0;

			previousPbfOperationOid = 0l;
			previousPbfOperationTimestamp = 0;
			previousPbfOperationChangeset = 0;
			previousPbfOperationRefId = 0l;
			previousPbfOperationLongitude = 0;
			previousPbfOperationLatitude = 0;

			/** Stream and read the operations */
			try (BufferedInputStream bis = new BufferedInputStream(
					new FileInputStream(pbfDataFolder + "/operation_" + elementTypePrefix + "_" + file.getOperationFileId() + ".pbf"), 1024*64)) {

				byte[] byteArray = null;
				PbfVgiFeature pbfFeature = null;

				while (true) {

					/** Parse start information (at least 4 bytes) */
					byteArray = readBytes(bis, 3);
					if (byteArray == null) break; /** no more features in this file */
					byte previousByte = 0;
					do { /** read bytes until the sequence 10-5 occurs */
						previousByte = byteArray[byteArray.length-1];
						byteArray = readBytes(bis, 1);
					} while (previousByte != 10 || byteArray[0] != 5);

					/** Parse PBF operation's length in bytes (5 bytes) */
					byteArray = readBytes(bis, 5);
					PbfVgiFeatureBytes b = PbfVgiFeatureBytes.parseFrom(byteArray);

					/** Parse other information (at least 2 bytes, until positive integer) */
					byteArray = readBytes(bis, 1);
					do {
						byteArray = readBytes(bis, 1);
					} while (byteArray[0] < 0);

					/** Parse Operation (x bytes) */
					byteArray = readBytes(bis, b.getBytes());

					pbfFeature = PbfVgiFeature.parseFrom(byteArray);

					/** Deserialize operation */
					IVgiFeature feature = deserializeFeature(pbfFeature, geometryType);

					/** Enqueue operation (feature can be null if filter is applied) */
					if (feature != null) {
						feature.setLocalizeType(localizeType);
						enqueueFeature(feature);
						if (keepInCache) settings.getCache().get(cacheIdentifier).add(feature);
					}

					/** No more filter values in this file */
					if (filterNodeId != null && file.getElementType().equals(ElementType.NODE) && (filterNodeIdPointer == filterNodeId.size() || file.getMaxElementId() < filterNodeId.get(filterNodeIdPointer))) break;
					if (filterWayId != null && file.getElementType().equals(ElementType.WAY) && (filterWayIdPointer == filterWayId.size() || file.getMaxElementId() < filterWayId.get(filterWayIdPointer))) break;
				}

			    if (bis != null) {
			    	bis.close();
			    }

			} catch (InvalidProtocolBufferException e) {
				log.error("Operation after: " + previousOperationValues.getVgiGeometryType() + "/" + previousOperationValues.getOid() + " > " + previousOperationValues.getVgiOperationType() + ", " + previousOperationValues.getTimestamp());
				e.printStackTrace();
				/** http://www.openstreetmap.org/browse/changeset/14246617 */
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				log.error("Operation after: " + previousOperationValues.getVgiGeometryType() + "/" + previousOperationValues.getOid() + " > " + previousOperationValues.getVgiOperationType() + ", " + previousOperationValues.getTimestamp());
				log.warn("End of operation file " + elementTypePrefix + "_" + file.getOperationFileId());// + " after entry " + numEntries + " of " + file.getNumEntries());
			}

//			/** log progress of reading PBFs */
//			log.info("[" + producerNumber+ ": Pbf " + elementTypePrefix + "_" + file.getOperationFileId() + "/" + pbfFileList.size() + "] End  : NumOps=" + file.getNumEntries() + ((numDuration > 0) ? "; Dur=" + (duration/numDuration) : ""));
		}
    }

	private void read(List<PbfOperationFile> pbfFileList, boolean keepInCache, int firstFileId, int lastFileId) {

		/** Iterate through operation files */
		for (PbfOperationFile file : pbfFileList) {

//			if (!file.getElementType().equals(ElementType.WAY)) continue;
//			if (file.getOperationFileId() < 20360) continue;

			if (filterFileId != -1) {
				if (file.getOperationFileId() != filterFileId) continue;
			}

//			if (startFileId > 1) {
//				if (filterGeometryType == VgiGeometryType.UNDEFINED) {
//					if (file.getOperationFileId() < startFileId) continue;
//				} else {
//					if (file.getOperationFileId() < startFileId && file.getElementType().equals(filterElementType)) continue;
//				}
//			}

			/** Skip files if multi-threading */
			if (file.getOperationFileId() < firstFileId || file.getOperationFileId() > lastFileId) continue;

			/** Does file exist? */
			String elementTypePrefix = "d";
			VgiGeometryType geometryType = VgiGeometryType.UNDEFINED;
			switch (file.getElementType()) {
			case NODE:
				elementTypePrefix = "n";
				geometryType = VgiGeometryType.POINT;
				break;
			case WAY:
				elementTypePrefix = "w";
				geometryType = VgiGeometryType.LINE;
				break;
			case RELATION:
				elementTypePrefix = "r";
				geometryType = VgiGeometryType.RELATION;
				break;
			default: break;
			}

			if (!containsRequestedOperations(file, geometryType)) continue;

			if (!new File(pbfDataFolder + "/operation_" + elementTypePrefix + "_" + file.getOperationFileId() + ".pbf").exists()) {
				log.error(pbfDataFolder + "/operation_" + elementTypePrefix + "_" + file.getOperationFileId() + ".pbf not found!");
				continue;
			}

//			log.info("[" + producerNumber+ ": Pbf " + elementTypePrefix + "_" + file.getOperationFileId() + "/" + pbfFileList.size() + "] Start: NumOps=" + file.getNumEntries() + "; Path=" + pbfDataFolder + "/operation_" + elementTypePrefix + "_" + file.getOperationFileId() + ".pbf");

			/** Initialize variables */
			previousOperationValues = new VgiOperationImpl();
			byteArray = new byte[0];
			byteArrayPointer = 0;
			BufferedInputStream bis = null;

			previousPbfOperationOid = 0l;
			previousPbfOperationTimestamp = 0;
			previousPbfOperationChangeset = 0;
			previousPbfOperationRefId = 0l;
			previousPbfOperationLongitude = 0;
			previousPbfOperationLatitude = 0;

			/** Stream and read the operations*/
			try {

				bis = new BufferedInputStream(new FileInputStream(pbfDataFolder + "/operation_" + elementTypePrefix + "_" + file.getOperationFileId() + ".pbf"), 1024*64);

				byte[] byteArray = null;
				PbfVgiFeature pbfFeature = null;

				while (true) {

					/** Parse start information (at least 4 bytes) */
					byteArray = readBytes(bis, 3);
					if (byteArray == null) break; /** no more features in this file */
					byte previousByte = 0;
					do { /** read bytes until the sequence 10-5 occurs */
						previousByte = byteArray[byteArray.length-1];
						byteArray = readBytes(bis, 1);
					} while (previousByte != 10 || byteArray[0] != 5);

					/** Parse PBF operation's length in bytes (5 bytes) */
					byteArray = readBytes(bis, 5);
					PbfVgiFeatureBytes b = PbfVgiFeatureBytes.parseFrom(byteArray);

					/** Parse other information (at least 2 bytes, until positive integer) */
					byteArray = readBytes(bis, 1);
					do {
						byteArray = readBytes(bis, 1);
					} while (byteArray[0] < 0);

					/** Parse Operation (x bytes) */
					byteArray = readBytes(bis, b.getBytes());

					pbfFeature = PbfVgiFeature.parseFrom(byteArray);

					/** Deserialize operation */
					IVgiFeature feature = deserializeFeature(pbfFeature, geometryType);

					/** Enqueue operation (feature can be null if filter is applied) */
					if (feature != null) createFeature(feature, keepInCache);

					/** No more filter values in this file */
					if (filterNodeId != null && file.getElementType().equals(ElementType.NODE) && (filterNodeIdPointer == filterNodeId.size() || file.getMaxElementId() < filterNodeId.get(filterNodeIdPointer))) break;
					if (filterWayId != null && file.getElementType().equals(ElementType.WAY) && (filterWayIdPointer == filterWayId.size() || file.getMaxElementId() < filterWayId.get(filterWayIdPointer))) break;
				}

			    if (bis!=null) {
			    	bis.close();
			    }

			} catch (InvalidProtocolBufferException e) {
				log.error("Operation after: " + previousOperationValues.getVgiGeometryType() + "/" + previousOperationValues.getOid() + " > " + previousOperationValues.getVgiOperationType() + ", " + previousOperationValues.getTimestamp());
				e.printStackTrace();
				/** http://www.openstreetmap.org/browse/changeset/14246617 */
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				log.error("Operation after: " + previousOperationValues.getVgiGeometryType() + "/" + previousOperationValues.getOid() + " > " + previousOperationValues.getVgiOperationType() + ", " + previousOperationValues.getTimestamp());
				log.warn("End of operation file " + elementTypePrefix + "_" + file.getOperationFileId());// + " after entry " + numEntries + " of " + file.getNumEntries());
			}

//			/** log progress of reading PBFs */
//			log.info("[" + producerNumber+ ": Pbf " + elementTypePrefix + "_" + file.getOperationFileId() + "/" + pbfFileList.size() + "] End  : NumOps=" + file.getNumEntries() + ((numDuration > 0) ? "; Dur=" + (duration/numDuration) : ""));
		}
    }

Try With Resources try(BufferedInputStream bis=new BufferedInputStream(new FileInputStream(pbfDataFolder + "/operation_" + elementTypePrefix + "_" + file.getOperationFileId() + ".pbf"),1024 * 64)) in method private read(pbfFileList List<PbfOperationFile>, keepInCache boolean, firstFileId int, lastFileId int) : void from class at.salzburgresearch.vgi.vgianalyticsframework.activityanalysis.persistence.impl.VgiOperationPbfReaderImpl


	public static void launch (Options options, String[] args) {

        CommandLineParser parser = new DefaultParser();
        CommandLine cmd = null;
        try (ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:/application-context-osm-op-generator.xml")) {
            cmd = parser.parse(options, args);

            File osmHistoryFile = null;
            File settingsFile = null;

            if (cmd.hasOption('h')) {
                HelpFormatter helpFormatter = new HelpFormatter();
                helpFormatter.printHelp("java -jar vgi-activity-1.0.jar [OPTION]...", options);
                return;
            }
            if (cmd.hasOption('o')) {
            	osmHistoryFile = new File(cmd.getOptionValue('o'));
            	if (!osmHistoryFile.exists()) {
            		log.warn("OSM History file does not exist! (" + osmHistoryFile.getAbsolutePath() + ")");
            		System.exit(0);
            	}
            } else {
                settingsFile = null;
            }
            if (cmd.hasOption('s')) {
                settingsFile = new File(cmd.getOptionValue('s'));
            	if (!settingsFile.exists()) {
            		log.warn("Setting file does not exist! (" + settingsFile.getAbsolutePath() + ")");
            		System.exit(0);
            	}
            } else {
				log.warn("No setting file specified! Use option -s to specify a settings XML file");
				System.exit(0);
                settingsFile = null;
            }

			IVgiPipelineSettings settings = ((IVgiPipelineSettings)ctx.getBean("vgiPipelineSettings"));
			settings.loadSettings(settingsFile);

			InputStream input = new FileInputStream(osmHistoryFile);
			OsmPbfParser osmParser = new OsmPbfParser();

			OsmDataConsumer osmDataConsumer = ((VgiOperationGeneratorDataHandlerImpl)ctx.getBean("vgiOperationGeneratorDataHandler"));
			settings.loadSettings(settingsFile);
			osmParser.setSink(osmDataConsumer);
			new BlockInputStream(input, osmParser).process();

			log.info("importer done");

		} catch (ParseException e) {
			log.error("Parse Error");
		} catch (IOException e) {
			log.error("File Error");
        } catch (Exception e) {
            HelpFormatter helpFormatter = new HelpFormatter();
            if (e.getMessage() != null) {
                log.error(e.getMessage() + '\n');
            } else {
                log.error("Unknown error",e);
            }
            helpFormatter.printHelp("java -jar vgi-activity-1.0.jar [OPTION]...", options);
        }
	}

	public static void main(String[] args) {
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:/application-context-osm-op-generator.xml");

		Options options = new Options();
		options.addOption("h", "help", false, "Display this help page");
		options.addOption(Option.builder("o").longOpt("osm").hasArg().argName("osm_history_file").desc("osm history file").build());
		options.addOption(Option.builder("s").longOpt("settings").hasArg().argName("settings_file").desc("settings file").build());

        CommandLineParser parser = new DefaultParser();
        CommandLine cmd = null;
        try {
            cmd = parser.parse(options, args);

            File osmHistoryFile = null;
            File settingsFile = null;

            if (cmd.hasOption('h')) {
                HelpFormatter helpFormatter = new HelpFormatter();
                helpFormatter.printHelp("java -jar vgi-activity-1.0.jar [OPTION]...", options);
                return;
            }
            if (cmd.hasOption('o')) {
            	osmHistoryFile = new File(cmd.getOptionValue('o'));
            	if (!osmHistoryFile.exists()) {
            		log.warn("OSM History file does not exist! (" + osmHistoryFile.getAbsolutePath() + ")");
            		System.exit(0);
            	}
            } else {
                settingsFile = null;
            }
            if (cmd.hasOption('s')) {
                settingsFile = new File(cmd.getOptionValue('s'));
            	if (!settingsFile.exists()) {
            		log.warn("Setting file does not exist! (" + settingsFile.getAbsolutePath() + ")");
            		System.exit(0);
            	}
            } else {
                settingsFile = null;
            }

			IVgiPipelineSettings settings = ((IVgiPipelineSettings)ctx.getBean("vgiPipelineSettings"));
			settings.loadSettings(settingsFile);

			InputStream input = new FileInputStream(osmHistoryFile);
			OsmPbfParser osmParser = new OsmPbfParser();

			OsmDataConsumer osmDataConsumer = ((VgiOperationGeneratorDataHandlerImpl)ctx.getBean("vgiOperationGeneratorDataHandler"));
			settings.loadSettings(settingsFile);
			osmParser.setSink(osmDataConsumer);
			new BlockInputStream(input, osmParser).process();

			log.info("importer done");

		} catch (ParseException e) {
			log.error("Parse Error");
		} catch (IOException e) {
			log.error("File Error");
        } catch (Exception e) {
            HelpFormatter helpFormatter = new HelpFormatter();
            if (e.getMessage() != null) {
                log.error(e.getMessage() + '\n');
            } else {
                log.error("Unknown error",e);
            }
            helpFormatter.printHelp("java -jar vgi-activity-1.0.jar [OPTION]...", options);
        }
	}

Try With Resources try(ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("classpath:/application-context-osm-op-generator.xml")) in method public launch(options Options, args String[]) : void from class at.salzburgresearch.vgi.vgianalyticsframework.activityanalysis.application.OsmHistoryImporter


	public static void launch (Options options, String[] args) {

		CommandLineParser parser = new DefaultParser();
		CommandLine cmd = null;
		try (ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
				"classpath:/application-context-vgi-pipeline.xml")) {
			cmd = parser.parse(options, args);

			File settingsFile = null;
			File polygonFile = null;
			boolean batchProcessing = false;

			if (cmd.hasOption('h')) {
				HelpFormatter helpFormatter = new HelpFormatter();
				helpFormatter.printHelp("java -jar vgi-activity-1.0.jar [OPTION]...", options);
				return;
			}
			if (cmd.hasOption('s')) {
				settingsFile = new File(cmd.getOptionValue('s'));
				if (!settingsFile.exists()) {
					log.warn("Setting file does not exist! (" + settingsFile.getAbsolutePath() + ")");
					settingsFile = null;
				}
			} else {
				settingsFile = null;
				log.warn("No setting file specified! Use option -s to specify a settings XML file");
				System.exit(0);
			}
			if (cmd.hasOption('p')) {
				polygonFile = new File(cmd.getOptionValue('p'));
				if (polygonFile.exists()) {
					batchProcessing = true;
				} else {
					log.warn("Polygon file does not exist!");
				}
			} else {
				polygonFile = null;
			}

			WKTReader wktReader = new WKTReader();

			IVgiPipeline pipeline = ((IVgiPipeline) ctx.getBean("vgiPipeline"));

			IVgiPipelineSettings settings = ((IVgiPipelineSettings) ctx.getBean("vgiPipelineSettings"));
			settings.loadSettings(settingsFile);

			if (!batchProcessing) {
				pipeline.start();

			} else {
				try {
					BufferedReader fileReader = new BufferedReader(new FileReader(polygonFile));

					String line = "";

					while ((line = fileReader.readLine()) != null) {

						String[] split = line.split(";");
						try {
							settings.setFilterPolygonLabel(split[1]);
							settings.setFilterPolygon((Polygon) wktReader.read(split[0]));
						} catch (ParseException e) {
							log.warn("Cannot parse geometry!! (" + split[0] + ")");
							continue;
						}

						if (settings.getFilterPolygon() != null) {
							log.info("Start analysis... " + settings.getFilterPolygonLabel());
							pipeline.start();
						}
					}
					fileReader.close();

				} catch (Exception e) {
					e.printStackTrace();
				}
			}

		} catch (Exception e) {
			HelpFormatter helpFormatter = new HelpFormatter();
			if (e.getMessage() != null) {
				log.error(e.getMessage() + '\n');
			} else {
				log.error("Unknown error", e);
			}
			helpFormatter.printHelp("java -jar vgi-activity-1.0.jar [OPTION]...", options);
		}
	}

	public static void main(String[] args) {
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
				"classpath:/application-context-vgi-pipeline.xml");

		Options options = new Options();
		options.addOption("h", "help", false, "Display this help page");
		options.addOption(Option.builder("s").longOpt("settings").hasArg().argName("settings_file")
				.desc("settings file").build());
		options.addOption(
				Option.builder("p").longOpt("polygons").hasArg().argName("polygon_file").desc("polygon file").build());

		CommandLineParser parser = new DefaultParser();
		CommandLine cmd = null;
		try {
			cmd = parser.parse(options, args);

			File settingsFile = null;
			File polygonFile = null;
			boolean batchProcessing = false;

			if (cmd.hasOption('h')) {
				HelpFormatter helpFormatter = new HelpFormatter();
				helpFormatter.printHelp("java -jar vgi-activity-1.0.jar [OPTION]...", options);
				return;
			}
			if (cmd.hasOption('s')) {
				settingsFile = new File(cmd.getOptionValue('s'));
				if (!settingsFile.exists()) {
					log.warn("Setting file does not exist! (" + settingsFile.getAbsolutePath() + ")");
					settingsFile = null;
				}
			} else {
				settingsFile = null;
			}
			if (cmd.hasOption('p')) {
				polygonFile = new File(cmd.getOptionValue('p'));
				if (polygonFile.exists()) {
					batchProcessing = true;
				} else {
					log.warn("Polygon file does not exist!");
				}
			} else {
				polygonFile = null;
			}

			WKTReader wktReader = new WKTReader();

			IVgiPipeline pipeline = ((IVgiPipeline) ctx.getBean("vgiPipeline"));

			IVgiPipelineSettings settings = ((IVgiPipelineSettings) ctx.getBean("vgiPipelineSettings"));
			settings.loadSettings(settingsFile);

			if (!batchProcessing) {
				pipeline.start();

			} else {
				try {
					BufferedReader fileReader = new BufferedReader(new FileReader(polygonFile));

					String line = "";

					while ((line = fileReader.readLine()) != null) {

						String[] split = line.split(";");
						try {
							settings.setFilterPolygonLabel(split[2]);
							settings.setFilterPolygon((Polygon) wktReader.read(split[0]));
						} catch (ParseException e) {
							log.warn("Cannot parse geometry!! (" + split[0] + ")");
							continue;
						}

						if (settings.getFilterPolygon() != null) {
							log.info("Start analysis... " + settings.getFilterPolygonLabel());
							pipeline.start();
						}
					}
					fileReader.close();

				} catch (Exception e) {
					e.printStackTrace();
				}
			}

		} catch (Exception e) {
			HelpFormatter helpFormatter = new HelpFormatter();
			if (e.getMessage() != null) {
				log.error(e.getMessage() + '\n');
			} else {
				log.error("Unknown error", e);
			}
			helpFormatter.printHelp("java -jar vgi-activity-1.0.jar [OPTION]...", options);
		}
	}

Try With Resources try(ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("classpath:/application-context-vgi-pipeline.xml")) in method public launch(options Options, args String[]) : void from class at.salzburgresearch.vgi.vgianalyticsframework.activityanalysis.application.VgiAnalysis


	public static void launch (Options options, String[] args) {

        CommandLineParser parser = new DefaultParser();
        CommandLine cmd = null;
        try (ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:/application-context-vgi-quadtree.xml")) {
            cmd = parser.parse(options, args);

            File settingsFile = null;

            if (cmd.hasOption('h')) {
                HelpFormatter helpFormatter = new HelpFormatter();
                helpFormatter.printHelp("java -jar vgi-activity-1.0.jar [OPTION]...", options);
                return;
            }
            if (cmd.hasOption('s')) {
                settingsFile = new File(cmd.getOptionValue('s'));
            	if (!settingsFile.exists()) {
            		log.warn("Setting file does not exist! (" + settingsFile.getAbsolutePath() + ")");
            		settingsFile = null;
            	}
            } else {
				log.warn("No setting file specified! Use option -s to specify a settings XML file");
				System.exit(0);
                settingsFile = null;
            }

			IVgiPipeline pipeline = ((IVgiPipeline)ctx.getBean("vgiPipeline"));

			IVgiPipelineSettings settings = ((IVgiPipelineSettings)ctx.getBean("vgiPipelineSettings"));
			settings.loadSettings(settingsFile);

			pipeline.start();

        } catch (Exception e) {
            HelpFormatter helpFormatter = new HelpFormatter();
            if (e.getMessage() != null) {
                log.error(e.getMessage() + '\n');
            } else {
                log.error("Unknown error",e);
            }
            helpFormatter.printHelp("java -jar vgi-activity-1.0.jar [OPTION]...", options);
        }
	}

	public static void main(String[] args) {
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:/application-context-vgi-quadtree.xml");

		Options options = new Options();
		options.addOption("h", "help", false, "Display this help page");
		options.addOption(Option.builder("s").longOpt("settings").hasArg().argName("settings_file").desc("settings file").build());

        CommandLineParser parser = new DefaultParser();
        CommandLine cmd = null;
        try {
            cmd = parser.parse(options, args);

            File settingsFile = null;

            if (cmd.hasOption('h')) {
                HelpFormatter helpFormatter = new HelpFormatter();
                helpFormatter.printHelp("java -jar vgi-activity-1.0.jar [OPTION]...", options);
                return;
            }
            if (cmd.hasOption('s')) {
                settingsFile = new File(cmd.getOptionValue('s'));
            	if (!settingsFile.exists()) {
            		log.warn("Setting file does not exist! (" + settingsFile.getAbsolutePath() + ")");
            		settingsFile = null;
            	}
            } else {
                settingsFile = null;
            }

			IVgiPipeline pipeline = ((IVgiPipeline)ctx.getBean("vgiPipeline"));

			IVgiPipelineSettings settings = ((IVgiPipelineSettings)ctx.getBean("vgiPipelineSettings"));
			settings.loadSettings(settingsFile);

			pipeline.start();

        } catch (Exception e) {
            HelpFormatter helpFormatter = new HelpFormatter();
            if (e.getMessage() != null) {
                log.error(e.getMessage() + '\n');
            } else {
                log.error("Unknown error",e);
            }
            helpFormatter.printHelp("java -jar vgi-activity-1.0.jar [OPTION]...", options);
        }
	}

Try With Resources try(ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("classpath:/application-context-vgi-quadtree.xml")) in method public launch(options Options, args String[]) : void from class at.salzburgresearch.vgi.vgianalyticsframework.activityanalysis.application.VgiQuadtreeBuilder


    @Test
    public void successWithNonExistentField() throws Throwable
    {
        IsBlank named =
            new IsBlank(
                new Named<>(
                    "vasya",
                    Either.right(
                        new Absent<>()
                    )
                )
            );

        assertTrue(named.result().isSuccessful());
        assertEquals("vasya", named.result().name());
        assertFalse(named.result().value().isPresent());
    }

    @Test
    public void failedWithNonExistentField() throws Throwable
    {
        IsBlank named =
            new IsBlank(
                new Named<>(
                    "vasya",
                    Either.right(
                        new Present<>(
                            new Gson().toJsonTree(
                                List.of(
                                    Map.of("id", 1900),
                                    Map.of("id", 777)
                                ),
                                new TypeToken<List<Map<String, Object>>>() {}.getType()
                            )
                        )
                    )
                )
            );

        assertFalse(named.result().isSuccessful());
        assertEquals("vasya", named.result().name());
        assertEquals("This value must be a string.", named.result().error());
    }

Replace Generic With Diamond IsBlank with IsBlank in method public successWithNonExistentField() : void from class validation.leaf.is.IsBlankTest


    @Test
    public void successfulComplexRequest() throws Throwable
    {
        Result<OrderRegistrationRequest> result =
            new FastFail<>(
                // Если сделать тут AsMap, то внутри следующих AsMap будет уже не JsonElement, а Map<String, Object>.
                // А AsMap принимает Validatable<JsonElement>!
//                new AsMap(
                    new WellFormedJson(
                        new Named<>("request body", Either.right(new Present<>(this.validJsonRequest())))
                    )
//                )
                ,
                requestJsonMap ->
                    new NamedBloc<>(
                        "request body",
                        List.of(
                            new FastFail<>(
//                                new AsMap(
                                    new IsMap(
                                        new Required(
                                            new IndexedValue("guest", requestJsonMap)
                                        )
                                    )
//                                )
                                ,
                                guestJsonObject ->
                                    new NamedBloc<>(
                                        "guest",
                                        List.of(
                                            new AsString(
                                                new Required(
                                                    new IndexedValue("email", guestJsonObject)
                                                )
                                            ),
                                            new AsString(
                                                new Required(
                                                    new IndexedValue("name", guestJsonObject)
                                                )
                                            )
                                        ),
                                        Guest.class
                                    )
                            ),
                            // TODO: move this check into NamedBloc class (a la Block class in Validatable)
                            new FastFail<>(
//                                new AsList(
//                                    new IsArrayOfArrays(
                                        new Required(
                                            new IndexedValue("items", requestJsonMap)
                                        )
//                                    )
//                                )
                                ,
                                itemsJsonElement ->
                                    new NamedBloc<>(
                                    "items",
                                        List.of(
                                            new Mapped<>(
                                                itemsJsonElement,
                                                item ->
                                                    new UnnamedBloc<>(
                                                        List.of(
                                                            new AsInteger(
                                                                new Required(
                                                                    new IndexedValue("id", item)
                                                                )
                                                            )
                                                        ),
                                                        Item.class
                                                    )
                                            )
                                        ),
                                        Items.class
                                    )
                            ),
                            new IsInteger(
                                new Required(
                                    new IndexedValue("source", requestJsonMap)
                                )
                            )
                        ),
                        OrderRegistrationRequest.class
                    )
            )
                .result();

        assertTrue(result.isSuccessful());
        assertEquals("samokhinvadim@gmail.com", result.value().raw().guest().email());
        assertEquals("Vadim Samokhin", result.value().raw().guest().name());
        assertEquals(1488, result.value().raw().items().list().get(0).id().intValue());
        assertEquals(666, result.value().raw().items().list().get(1).id().intValue());
        assertEquals(Integer.valueOf(1), result.value().raw().source());
    }

    @Test
    public void successfulComplexRequest() throws Throwable
    {
        Result<OrderRegistrationRequest> result =
            new FastFail<>(
                // Если сделать тут AsMap, то внутри следующих AsMap будет уже не JsonElement, а Map<String, Object>.
                // А AsMap принимает Validatable<JsonElement>!
//                new AsMap(
                    new WellFormedJson(
                        new Named<>("request body", Either.right(new Present<>(this.validJsonRequest())))
                    )
//                )
                ,
                requestJsonMap ->
                    new NamedBloc<>(
                        "request body",
                        List.of(
                            new FastFail<>(
//                                new AsMap(
                                    new IsMap(
                                        new Required(
                                            new IndexedValue("guest", requestJsonMap)
                                        )
                                    )
//                                )
                                ,
                                guestJsonObject ->
                                    new NamedBloc<>(
                                        "guest",
                                        List.of(
                                            new AsString(
                                                new Required(
                                                    new IndexedValue("email", guestJsonObject)
                                                )
                                            ),
                                            new AsString(
                                                new Required(
                                                    new IndexedValue("name", guestJsonObject)
                                                )
                                            )
                                        ),
                                        Guest.class
                                    )
                            ),
                            new FastFail<JsonElement, Items>(
//                                new AsList(
//                                    new IsArrayOfArrays(
                                        new Required(
                                            new IndexedValue("items", requestJsonMap)
                                        )
//                                    )
//                                )
                                ,
                                itemsJsonElement ->
                                    new NamedBloc<>(
                                        "items",
                                            List.of(
                                                    // TODO: Extract this fucntionality to Mapped class, add list iteration there
                                                    new Validatable<List<Item>>() {
                                                        @Override
                                                        public Result<List<Item>> result() throws Throwable
                                                        {
                                                            Pair<List<Object>, Map<String, Object>> valuesAndErrors =
                                                                    new ValuesAndErrors(
                                                                            List.of(
                                                                                // TODO: form UnnamedBlocs dynamically, as many as there are in json
                                                                                new UnnamedBloc<>(
                                                                                List.of(
                                                                                new Named<>("id", Either.right(new Present<>(1488)))
                                                                                ),
                                                                                Item.class
                                                                                )
                                                                            )
                                                                    )
                                                                            .value();

                                                            if (valuesAndErrors.getValue1().size() > 0) {
                                                                return
                                                                        new Validation.Result.Named<>(
                                                                                "vasya",
                                                                                Either.left(
                                                                                List.of(
                                                                                valuesAndErrors.getValue1()
                                                                                )
                                                                                )
                                                                        );
                                                            }

                                                            return
                                                                    new Validation.Result.Named<>(
                                                                            "vasya",
                                                                            Either.right(
                                                                                new Present<>(
                                                                                List.of(
                                                                                // TODO: pass through values and cast them  to Item
                                                                                (Item) valuesAndErrors.getValue0().get(0)
                                                                                )
                                                                                )
                                                                            )
                                                                    );
                                                        }
                                                    }
                                            )
//                                        new Mapped<Item>(
//                                            itemsJsonElement,
//                                            item ->
//                                                new UnnamedBloc<>(
//                                                    List.of(
//                                                        new IsInteger(
//                                                            new Required(
//                                                                new IndexedValue("id", item)
//                                                            )
//                                                        )
//                                                    ),
//                                                    Item.class
//                                                )
//                                        )
//                                            .result()
//                                            .value()
//                                            .raw()
                                            ,
                                        Items.class
                                    )
                            ),
                            new IsInteger(
                                new Required(
                                    new IndexedValue("source", requestJsonMap)
                                )
                            )
                        ),
                        OrderRegistrationRequest.class
                    )
            )
                .result();

        assertTrue(result.isSuccessful());
        assertEquals("samokhinvadim@gmail.com", result.value().raw().guest().email());
        assertEquals("Vadim Samokhin", result.value().raw().guest().name());
        assertEquals(1488, result.value().raw().items().list().get(0).id().intValue());
        assertEquals(Integer.valueOf(1), result.value().raw().source());
    }

Replace Generic With Diamond NamedBloc<> with NamedBloc<> in method public successfulComplexRequest() : void from class Validation.Composite.WellFormedJsonTest


    @Test
    public void success() throws Exception {
        Result<Team> result =
            new Bloc<>(
                List.of(
                    () -> new Named<>("vasya", Either.right("belov")),
                    () -> new Named<>("fedya", Either.right(7)),
                    () -> new Named<>("jenya", Either.right(false))
//                    () ->
//                        new Bloc<>(
//                            List.of(
//                                () -> new Named<>("vasya", Either.right("belov")),
//                                () -> new Named<>("fedya", Either.right(7)),
//                                () -> new Named<>("jenya", Either.right(false))
//                            )
//                        )
//                            .result()
                ),
                Team.class
            )
                .result();

        assertTrue(result.isSuccessful());
//        assertEquals("vasiliev", result.value());
    }

    @Test
    public void success() throws Exception {
        Result<Team> result =
            new Bloc<Team>(
                List.of(
                    () -> new Named<>("vasya", Either.right("belov")),
                    () -> new Named<>("fedya", Either.right(7)),
                    () -> new Named<>("jenya", Either.right(false))
//                    () ->
//                        new Bloc<>(
//                            List.of(
//                                () -> new Named<>("vasya", Either.right("belov")),
//                                () -> new Named<>("fedya", Either.right(7)),
//                                () -> new Named<>("jenya", Either.right(false))
//                            )
//                        )
//                            .result()
                ),
                Team.class
            )
                .result();

        assertTrue(result.isSuccessful());
//        assertEquals("vasiliev", result.value());
    }

Replace Generic With Diamond Bloc<Team> with Bloc<> in method public success() : void from class Validation.Composite.BlocTest


    @Test
    public void wellFormedJson() throws Exception
    {
        assertTrue(
            (new WellFormedJson(
                new Named<>("vasya", Either.right(this.json()))
            ))
                .result()
                    .isSuccessful()
        );
    }

    @Test
    public void wellFormedJson()
    {
        assertTrue(
            (new WellFormedJson(
                new Named<String>("vasya", "invalid json", true)
            ))
                .result()
                    .isSuccessful()
        );
    }

Replace Generic With Diamond WellFormedJson with WellFormedJson in method public wellFormedJson() : void from class Validation.Composite.WellFormedJsonTest


  public static <E> Matrix<E> buildMatrix(int h, int w, MatrixPopulator<E> populator) {
    return new Matrix<>(h, w, i -> IntStream.range(0, w).mapToObj(j -> populator.apply(i, j))
        .collect(Collectors.toCollection(ArrayList::new)));
  }

  public static <E> Matrix<E> buildMatrix(int h, int w, BiFunction<Integer, Integer, E> populator) {
    return new Matrix<E>(h, w, i -> IntStream.range(0, w).mapToObj(j -> populator.apply(i, j))
        .collect(Collectors.toCollection(ArrayList::new)));
  }

Replace Generic With Diamond Matrix<E> with Matrix<> in method public buildMatrix(h int, w int, populator MatrixPopulator<E>) : Matrix<E> from class dk.alexandra.fresco.stat.linearalgebra.MatrixUtils


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

        @Override
        public void test() {

          List<Double> row = List.of(4.0);
          List<Double> b = List.of(-4.0777, 1.5046);

          Application<BigDecimal, ProtocolBuilderNumeric> testApplication = seq -> {

            List<DRes<SFixed>> secretRow =
                row.stream().map(i -> FixedNumeric.using(seq).known(BigDecimal.valueOf(i)))
                    .collect(Collectors.toList());

            List<DRes<SFixed>> secretB =
                b.stream().map(i -> FixedNumeric.using(seq).known(BigDecimal.valueOf(i)))
                    .collect(Collectors.toList());

            DRes<SFixed> y =
                new LogisticRegressionPrediction(secretRow, secretB).buildComputation(seq);

            return FixedNumeric.using(seq).open(y);
          };
          double expected = 1.0 / (1.0 + Math.exp(-b.get(0) - b.get(1) * row.get(0)));
          BigDecimal output = runApplication(testApplication);
          Assert.assertEquals(expected, output.doubleValue(), 0.001);
        }
      };
    }

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

        @Override
        public void test() throws Exception {

          List<Double> row = List.of(4.0);
          List<Double> b = List.of(-4.0777, 1.5046);

          Application<BigDecimal, ProtocolBuilderNumeric> testApplication = seq -> {

            List<DRes<SFixed>> secretRow =
                row.stream().map(i -> FixedNumeric.using(seq).known(BigDecimal.valueOf(i)))
                    .collect(Collectors.toList());

            List<DRes<SFixed>> secretB =
                b.stream().map(i -> FixedNumeric.using(seq).known(BigDecimal.valueOf(i)))
                    .collect(Collectors.toList());

            DRes<SFixed> y =
                new LogisticRegressionPrediction(secretRow, secretB).buildComputation(seq);

            return FixedNumeric.using(seq).open(y);
          };
          double expected = 1.0 / (1.0 + Math.exp(-b.get(0) - b.get(1) * row.get(0)));
          BigDecimal output = runApplication(testApplication);
          Assert.assertEquals(expected, output.doubleValue(), 0.001);
        }
      };
    }

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


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

        @Override
        public void test() {

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

                List<DRes<SFixed>> initB = List.of(FixedNumeric.using(seq).known(-3.0),
                    FixedNumeric.using(seq).known(2.0));

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

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

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

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

          List<BigDecimal> output = runApplication(testApplication);

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

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

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

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

        @Override
        public void test() throws Exception {

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

                List<DRes<SFixed>> initB = List.of(FixedNumeric.using(seq).known(-3.0),
                    FixedNumeric.using(seq).known(2.0));

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

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

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

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

          List<BigDecimal> output = runApplication(testApplication);

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

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

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

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