Source:
public List<Detector> getListOfDetectors(InetAddress inetAddress, String location) { String ipAddress = InetAddressUtils.toIpAddrString(inetAddress); if (Strings.isNullOrEmpty(location)) { location = LocationUtils.DEFAULT_LOCATION_NAME; } final String sourceLocation = location; final String defaultLocation = getConfiguration().getLocation().orElse(LocationUtils.DEFAULT_LOCATION_NAME); Optional<Definition> definition = getConfiguration().getDefinitions().stream().filter(def -> { boolean specificMatch = def.getSpecifics().stream().anyMatch(specific -> { return specific.getLocation().orElse(def.getLocation().orElse(defaultLocation)).equals(sourceLocation) && specific.getAddress().equals(ipAddress); }); if (!specificMatch) { boolean urlSpecficMatch = def.getIncludeUrls().stream().anyMatch(includeUrl -> { boolean urlLocationMatch = includeUrl.getUrl().isPresent() && includeUrl.getLocation().orElse(def.getLocation().orElse(defaultLocation)).equals(sourceLocation); if (urlLocationMatch) { List<String> urlSpecifics = m_urlSpecifics.get(includeUrl.getUrl().get()); if (urlSpecifics != null) { return urlSpecifics.contains(ipAddress); } } return false; }); if (!urlSpecficMatch) { return def.getIncludeRanges().stream().anyMatch(includeRange -> includeRange.getLocation().orElse(def.getLocation().orElse(defaultLocation)).equals(sourceLocation) && InetAddressUtils.isInetAddressInRange(ipAddress, includeRange.getBegin(), includeRange.getEnd())); } } return true; }).findFirst(); if (definition.isPresent()) { return definition.get().getDetectors(); } else { return new ArrayList<>(); } }

Target:
public List<Detector> getListOfDetectors(InetAddress inetAddress, String location) { String ipAddress = InetAddressUtils.toIpAddrString(inetAddress); if (Strings.isNullOrEmpty(location)) { location = LocationUtils.DEFAULT_LOCATION_NAME; } final String sourceLocation = location; final String defaultLocation = getConfiguration().getLocation().orElse(LocationUtils.DEFAULT_LOCATION_NAME); Optional<Definition> definition = getConfiguration().getDefinitions().stream().filter(def -> { boolean specificMatch = def.getSpecifics().stream().anyMatch(specific -> { return specific.getLocation().orElse(def.getLocation().orElse(defaultLocation)).equals(sourceLocation) && specific.getAddress().equals(ipAddress); }); if(specificMatch) { return true; } boolean urlSpecficMatch = def.getIncludeUrls().stream().anyMatch(includeUrl -> { boolean urlLocationMatch = includeUrl.getUrl().isPresent() && includeUrl.getLocation().orElse(def.getLocation().orElse(defaultLocation)).equals(sourceLocation); if (urlLocationMatch) { List<String> urlSpecifics = m_urlSpecifics.get(includeUrl.getUrl().get()); if (urlSpecifics != null) { return urlSpecifics.contains(ipAddress); } } return false; }); if (urlSpecficMatch) { return true; } return def.getIncludeRanges().stream().anyMatch(includeRange -> includeRange.getLocation().orElse(def.getLocation().orElse(defaultLocation)).equals(sourceLocation) && InetAddressUtils.isInetAddressInRange(ipAddress, includeRange.getBegin(), includeRange.getEnd())); }).findFirst(); if (definition.isPresent()) { return definition.get().getDetectors(); } else { return new ArrayList<>(); } }