    private void setCookies(HttpResponse httpResponse) {
        List<Cookie> mappedCookies = new ArrayList<>();
        for (Header header : httpResponse.getHeaders()) {
            if (header.getName().equals("Cookie") || header.getName().equals("Set-Cookie")) {
                for (String cookieHeader : header.getValues()) {
                    try {
                        for (HttpCookie httpCookie : HttpCookie.parse(cookieHeader)) {
                            mappedCookies.add(new Cookie(httpCookie.getName(), httpCookie.getValue()));
                        }
                    } catch (IllegalArgumentException iae) {
                        logger.warn("Exception while parsing cookie header [" + cookieHeader + "]", iae);
                    }
                }
            }
        }
        httpResponse.withCookies(mappedCookies);
    }

    private void setCookies(HttpResponse httpResponse) {
        List<Cookie> mappedCookies = new ArrayList<Cookie>();
        for (Header header : httpResponse.getHeaders()) {
            if (header.getName().equals("Cookie") || header.getName().equals("Set-Cookie")) {
                for (String cookieHeader : header.getValues()) {
                    try {
                        for (HttpCookie httpCookie : HttpCookie.parse(cookieHeader)) {
                            mappedCookies.add(new Cookie(httpCookie.getName(), httpCookie.getValue()));
                        }
                    } catch (IllegalArgumentException iae) {
                        logger.warn("Exception while parsing cookie header [" + cookieHeader + "]", iae);
                    }
                }
            }
        }
        httpResponse.withCookies(mappedCookies);
    }

Replace Generic With Diamond ArrayList<Cookie> with ArrayList<> in method private setCookies(httpResponse HttpResponse) : void from class org.mockserver.mappers.jetty.HttpClientResponseMapper


    private void setHeaders(HttpResponse httpResponse, HttpClientResponse httpServletResponse) {
        List<Header> mappedHeaders = new ArrayList<Header>();
        MultiMap headers = httpServletResponse.headers();
        for (String headerName : headers.names()) {
            mappedHeaders.add(new Header(headerName, new ArrayList<>(headers.getAll(headerName))));
        }
        httpResponse.withHeaders(mappedHeaders);
    }

    private void setHeaders(HttpResponse httpResponse, HttpClientResponse httpServletResponse) {
        List<Header> mappedHeaders = new ArrayList<Header>();
        MultiMap headers = httpServletResponse.headers();
        for (String headerName : headers.names()) {
            mappedHeaders.add(new Header(headerName, new ArrayList<String>(headers.getAll(headerName))));
        }
        httpResponse.withHeaders(mappedHeaders);
    }

Replace Generic With Diamond Header with Header in method private setHeaders(httpResponse HttpResponse, httpServletResponse HttpClientResponse) : void from class org.mockserver.mappers.vertx.HttpClientResponseMapper


    private void setCookies(HttpResponse httpResponse, HttpClientResponse httpServletResponse) {
        List<Cookie> mappedCookies = new ArrayList<>();
        MultiMap headers = httpServletResponse.headers();
        for (String headerName : headers.names()) {
            if (headerName.equals("Cookie") || headerName.equals("Set-Cookie")) {
                for (String cookieHeader : headers.getAll(headerName)) {
                    for (HttpCookie httpCookie : HttpCookie.parse(cookieHeader)) {
                        mappedCookies.add(new Cookie(httpCookie.getName(), httpCookie.getValue()));
                    }
                }
            }
        }
        httpResponse.withCookies(mappedCookies);
    }

    private void setCookies(HttpResponse httpResponse, HttpClientResponse httpServletResponse) {
        List<Cookie> mappedCookies = new ArrayList<Cookie>();
        MultiMap headers = httpServletResponse.headers();
        for (String headerName : headers.names()) {
            if (headerName.equals("Cookie") || headerName.equals("Set-Cookie")) {
                for (String cookieHeader : headers.getAll(headerName)) {
                    for (HttpCookie httpCookie : HttpCookie.parse(cookieHeader)) {
                        mappedCookies.add(new Cookie(httpCookie.getName(), httpCookie.getValue()));
                    }
                }
            }
        }
        httpResponse.withCookies(mappedCookies);
    }

Replace Generic With Diamond ArrayList<Cookie> with ArrayList<> in method private setCookies(httpResponse HttpResponse, httpServletResponse HttpClientResponse) : void from class org.mockserver.mappers.vertx.HttpClientResponseMapper


    private void setCookies(HttpRequest httpRequest, HttpServletRequest httpServletRequest) {
        List<Cookie> mappedCookies = new ArrayList<>();
        if (httpServletRequest.getCookies() != null) {
            for (javax.servlet.http.Cookie cookie : httpServletRequest.getCookies()) {
                mappedCookies.add(new Cookie(cookie.getName(), cookie.getValue()));
            }
        }
        httpRequest.withCookies(mappedCookies);
    }

    private void setCookies(HttpRequest httpRequest, HttpServletRequest httpServletRequest) {
        List<Cookie> mappedCookies = new ArrayList<Cookie>();
        if (httpServletRequest.getCookies() != null) {
            for (javax.servlet.http.Cookie cookie : httpServletRequest.getCookies()) {
                mappedCookies.add(new Cookie(cookie.getName(), cookie.getValue()));
            }
        }
        httpRequest.withCookies(mappedCookies);
    }

Replace Generic With Diamond ArrayList<Cookie> with ArrayList<> in method private setCookies(httpRequest HttpRequest, httpServletRequest HttpServletRequest) : void from class org.mockserver.mappers.HttpServletRequestMapper


    private void setCookies(HttpRequest httpRequest, HttpServerRequest httpServerRequest) {
        List<Cookie> mappedCookies = new ArrayList<>();
        MultiMap headers = httpServerRequest.headers();
        for (String headerName : headers.names()) {
            if (headerName.equals("Cookie") || headerName.equals("Set-Cookie")) {
                for (String cookieHeader : headers.getAll(headerName)) {
                    for (HttpCookie httpCookie : HttpCookie.parse(cookieHeader)) {
                        mappedCookies.add(new Cookie(httpCookie.getName(), httpCookie.getValue()));
                    }
                }
            }
        }
        httpRequest.withCookies(mappedCookies);
    }

    private void setCookies(HttpRequest httpRequest, HttpServerRequest httpServerRequest) {
        List<Cookie> mappedCookies = new ArrayList<Cookie>();
        MultiMap headers = httpServerRequest.headers();
        for (String headerName : headers.names()) {
            if (headerName.equals("Cookie") || headerName.equals("Set-Cookie")) {
                for (String cookieHeader : headers.getAll(headerName)) {
                    for (HttpCookie httpCookie : HttpCookie.parse(cookieHeader)) {
                        mappedCookies.add(new Cookie(httpCookie.getName(), httpCookie.getValue()));
                    }
                }
            }
        }
        httpRequest.withCookies(mappedCookies);
    }

Replace Generic With Diamond ArrayList<Cookie> with ArrayList<> in method private setCookies(httpRequest HttpRequest, httpServerRequest HttpServerRequest) : void from class org.mockserver.mappers.HttpServerRequestMapper


    public void clear(HttpRequest httpRequest) {
        for (Expectation expectation : new ArrayList<>(expectations)) {
            if (expectation.matches(httpRequest)) {
                expectations.remove(expectation);
            }
        }
    }

    public void clear(HttpRequest httpRequest) {
        for (Expectation expectation : new ArrayList<Expectation>(expectations)) {
            if (expectation.matches(httpRequest)) {
                expectations.remove(expectation);
            }
        }
    }

Replace Generic With Diamond ArrayList<Expectation> with ArrayList<> in method public clear(httpRequest HttpRequest) : void from class org.mockserver.mock.MockServer


	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<Template> loadResources(ProjectTemplateLocator locator) {

		ArrayList<Template> templates = new ArrayList<Template>();
		for (IFile file: locator.locateResources()) {
			String fileName = file.getName();
			try (BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()))) {
				DOMMarkupParser parser = new DOMMarkupParser(ParseConfiguration.htmlConfiguration());
				Document document = parser.parse(fileName, reader);
				templates.add(new Template(document));
			}
			catch (CoreException | IOException | ParseException ex) {
				logError("An error occured while reading " + fileName, ex);
			}
		}

		return templates;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<Template> loadResources(ProjectTemplateLocator locator) {

		ArrayList<Template> templates = new ArrayList<Template>();
		for (IFile file: locator.locateResources()) {
			BufferedReader reader = null;
			try {
				reader = new BufferedReader(new InputStreamReader(file.getContents()));
				DOMHtmlAttoHandler handler = new DOMHtmlAttoHandler(file.getName());
				parser.parse(reader, handler);
				templates.add(new Template(handler.getDocument()));
			}
			catch (CoreException ex) {
				logError("File " + file.getName() + " could not be read", ex);
			}
			catch (AttoParseException ex) {
				logError("Error reading the template file", ex);
			}
			finally {
				try {
					if (reader != null) {
						reader.close();
					}
				}
				catch (IOException ex) {
					logError("Unable to close the template file input stream", ex);
				}
			}
		}

		return templates;
	}

Try With Resources try(BufferedReader reader=new BufferedReader(new InputStreamReader(file.getContents()))) in method public loadResources(locator ProjectTemplateLocator) : List<Template> from class org.thymeleaf.extras.eclipse.template.TemplateLoader


    private void HandleKeys() {
        Main.mainStage.getScene().setOnKeyPressed(keyEvent -> {
            if (keyEvent.getCode().equals(KeyCode.ENTER)) {
                try {
                    login();
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        });
    }

    private void HandleKeys() {
        Main.mainStage.getScene().setOnKeyPressed(new EventHandler<KeyEvent>() {
            @Override
            public void handle(KeyEvent keyEvent) {
                if (keyEvent.getCode().equals(KeyCode.ENTER)) {
                    try {
                        login();
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });
    }

Replace Anonymous With Lambda view.UserMenus.LoginMenu.HandleKeys.setOnKeyPressed.new EventHandler<KeyEvent> with keyEvent -> {if(keyEvent.getCode().equals(KeyCode.ENTER)){trylogin(); in method private HandleKeys() : void from class view.UserMenus.LoginMenu


    private Thread setNewThreadForCountingLoginTime() {
        Thread timeThread = new Thread(() -> {
            while (true) {
                if (attemptsError == null) break;
                if ((loginController.getLoginTime() != null) && LocalDateTime.now().isBefore(loginController.getLoginTime())) {
                    convertLoginTime();
                } else
                    attemptsError.setText("");

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        timeThread.setDaemon(true);
        return timeThread;
    }

    private Thread setNewThreadForCountingLoginTime() {
        Thread timeThread = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    if (attemptsError == null) break;
                    if ((loginController.getLoginTime() != null) && LocalDateTime.now().isBefore(loginController.getLoginTime())) {
                        convertLoginTime();
                    } else
                        attemptsError.setText("");

                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });
        timeThread.setDaemon(true);
        return timeThread;
    }

Replace Anonymous With Lambda view.UserMenus.LoginMenu.setNewThreadForCountingLoginTime.timeThread.new Thread.new Runnable with () -> {while(true){if(attemptsError == null)break; in method private setNewThreadForCountingLoginTime() : Thread from class view.UserMenus.LoginMenu


    private void sendWithEnterHandler(Stage stage) {
        if (stage.getScene().getOnKeyPressed() != null) return;
        stage.getScene().setOnKeyPressed(keyEvent -> {
            if (keyEvent.getCode().equals(KeyCode.ENTER)) {
                try {
                    processSendMessage();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        });
    }

    private void sendWithEnterHandler(Stage stage) {
        if (stage.getScene().getOnKeyPressed() != null) return;
        stage.getScene().setOnKeyPressed(new EventHandler<KeyEvent>() {
            @Override
            public void handle(KeyEvent keyEvent) {
                if (keyEvent.getCode().equals(KeyCode.ENTER)) {
                    try {
                        processSendMessage();
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        });
    }

Replace Anonymous With Lambda view.ChatMenus.MainChatMenu.sendWithEnterHandler.setOnKeyPressed.new EventHandler<KeyEvent> with keyEvent -> {if(keyEvent.getCode().equals(KeyCode.ENTER)){tryprocessSendMessage(); in method private sendWithEnterHandler(stage Stage) : void from class view.ChatMenus.MainChatMenu


    private void initializeMinimap() {
        minimap.setOnMouseClicked(mouseEvent -> {
            double xRatio = mouseEvent.getX() / minimap.getBoundsInLocal().getWidth();
            double yRatio = mouseEvent.getY() / minimap.getBoundsInLocal().getHeight();
            mainScrollPane.setVvalue(xRatio);
            mainScrollPane.setHvalue(yRatio);
        });
    }

    private void initializeMinimap() {
        minimap.setOnMouseClicked(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent mouseEvent) {
                double xRatio = mouseEvent.getX() / minimap.getBoundsInLocal().getWidth();
                double yRatio = mouseEvent.getY() / minimap.getBoundsInLocal().getHeight();
                mainScrollPane.setVvalue(xRatio);
                mainScrollPane.setHvalue(yRatio);
            }
        });
    }

Replace Anonymous With Lambda view.GameMenus.GraphicGameMenu.initializeMinimap.setOnMouseClicked.new EventHandler<MouseEvent> with mouseEvent -> {double xRatio=mouseEvent.getX() / minimap.getBoundsInLocal().getWidth(); in method private initializeMinimap() : void from class view.GameMenus.GraphicGameMenu


    static Pair<Pod, Node> bindPodToNode(Pod pod, Node node, Integer score) {
        Binding b1 = new Binding();

        ObjectMeta om = new ObjectMeta();
        om.setName(pod.getMetadata().getName());
        om.setNamespace(pod.getMetadata().getNamespace());
        b1.setMetadata(om);

        ObjectReference objectReference = new ObjectReference();
        objectReference.setApiVersion("v1");
        objectReference.setKind("Node");
        objectReference.setName(node.getMetadata().getName()); //hier ersetzen durch tatsächliche Node

        b1.setTarget(objectReference);

        try {
            System.out.println("Bind " + pod.getMetadata().getName() + " to " + node.getMetadata().getName());
            var bind = KubernetesClientSingleton.getKubernetesClient().bindings().create(b1);
            //  TaskDB.addSchedulingReportToDB(pod, node, score);
            return new Pair<>(pod, node);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }

    static Pair<Pod, Node> bindPodToNode(Pod pod, Node node, Integer score) {
        Binding b1 = new Binding();

        ObjectMeta om = new ObjectMeta();
        om.setName(pod.getMetadata().getName());
        om.setNamespace(pod.getMetadata().getNamespace());
        b1.setMetadata(om);

        ObjectReference objectReference = new ObjectReference();
        objectReference.setApiVersion("v1");
        objectReference.setKind("Node");
        objectReference.setName(node.getMetadata().getName()); //hier ersetzen durch tatsächliche Node

        b1.setTarget(objectReference);

        try {
            System.out.println("Bind " + pod.getMetadata().getName() + " to " + node.getMetadata().getName());
            var bind = KubernetesClientSingleton.getKubernetesClient().bindings().create(b1);
            //  TaskDB.addSchedulingReportToDB(pod, node, score);
            return new Pair<Pod, Node>(pod, node);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }

Replace Generic With Diamond Pair<Pod,Node> with Pair<> in method package bindPodToNode(pod Pod, node Node, score Integer) : Pair<Pod,Node> from class fonda.scheduler.distributedscheduler.PodNodeScheduler


    public CurrentPodNodeStatus(KubernetesClient client) {
        this.client = client;

        PodNodeScheduler.podList = new PodListWithIndex();

        this.workerQueueNode = new ConcurrentLinkedQueue<>();

        this.operationContext = new OperationContext();

        setUpIndexInformerNode();

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

        // setUpIndexInformerPod();

        ListOptions options = new ListOptions();
        options.setFieldSelector("spec.schedulerName=new-scheduler");

        client.pods().watch(new Watcher<>() {
            @Override
            public void eventReceived(Action action, Pod pod) {

                PodWithAge pwa = new PodWithAge(pod);
                switch (action) {
                    case ADDED:
                        PodNodeScheduler.podList.addPodToList(pwa);
                        if (pwa.getSpec().getNodeName() == null) {
                            Pair<Pod, Node> scheduledPair = PodNodeScheduler.schedule(pwa, "").orElse(new Pair<>(pwa, null));
                            pwa.getSpec().setNodeName(scheduledPair.getValue1().getMetadata().getName()); // Hier stimmt evtl etwas nicht
                            PodNodeScheduler.podList.addPodToList(pwa);
                        }
                        break;
                    case MODIFIED:
                        break;
                    case DELETED:
                        PodNodeScheduler.podList.removePodFromList(pwa); //klappt das?
                        PodNodeScheduler.schedule(null, "");
                }

                //  System.out.println("Currently unscheduled pods: ");
                //  PodNodeScheduler.unscheduledPods.getItems().forEach(podItem ->System.out.println(podItem.getMetadata().getName() + " age " + ((PodWithAge)podItem).getAge()) );

            }

            @Override
            public void onClose(WatcherException cause) {

            }
        });

    }

    public CurrentPodNodeStatus(KubernetesClient client) {
        this.client = client;

        PodNodeScheduler.podList = new PodListWithIndex();

        this.workerQueueNode = new ConcurrentLinkedQueue<>();

        this.operationContext = new OperationContext();

        setUpIndexInformerNode();

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

        // setUpIndexInformerPod();

        ListOptions options = new ListOptions();
        options.setFieldSelector("spec.schedulerName=new-scheduler");

        client.pods().watch(new Watcher<Pod>() {
            @Override
            public void eventReceived(Action action, Pod pod) {

                switch (action) {
                    case ADDED:
                        PodNodeScheduler.podList.addPodToList(pod);
                        if (pod.getSpec().getNodeName() == null) {
                            Pair<Pod, Node> scheduledPair = PodNodeScheduler.schedule(pod, "").orElse(new Pair<>(pod, null));
                            pod.getSpec().setNodeName(scheduledPair.getValue1().getMetadata().getName()); // Hier stimmt evtl etwas nicht
                            PodNodeScheduler.podList.addPodToList(pod);
                        }
                        break;
                    case MODIFIED:
                        break;
                    case DELETED:
                        PodNodeScheduler.podList.removePodFromList(pod); //klappt das?
                        PodNodeScheduler.schedule( null, "");
                }

            }

            @Override
            public void onClose(WatcherException cause) {

            }
        });

    }

Replace Generic With Diamond Watcher<Pod> with Watcher<> in method public CurrentPodNodeStatus(client KubernetesClient) from class tuberlin.dos.kubscheduler.CurrentPodNodeStatus


            @Override
            public Watch watch(ListOptions params, String namespace, OperationContext context, Watcher watcher) {
                return client.nodes().watch(new Watcher<>() {
                    @Override
                    public void eventReceived(Action action, Node resource) {

                    }

                    @Override
                    public void onClose(WatcherException cause) {

                    }
                });
            }

            @Override
            public Watch watch(ListOptions params, String namespace, OperationContext context, Watcher watcher) {
                return client.nodes().watch(new Watcher<Node>() {
                    @Override
                    public void eventReceived(Action action, Node resource) {

                    }

                    @Override
                    public void onClose(WatcherException cause) {

                    }
                });
            }

Replace Generic With Diamond Watcher<Node> with Watcher<> in method public watch(params ListOptions, namespace String, context OperationContext, watcher Watcher) : Watch from class tuberlin.dos.kubscheduler.CurrentPodNodeStatus.setUpIndexInformerNode.listerWatcher.new ListerWatcher


    /**
     *
     */
    private void setUpIndexInformerNode() {
        ListerWatcher listerWatcher = new ListerWatcher() {
            @Override
            public Watch watch(ListOptions params, String namespace, OperationContext context, Watcher watcher) {
                return client.nodes().watch(new Watcher<>() {
                    @Override
                    public void eventReceived(Action action, Node resource) {

                    }

                    @Override
                    public void onClose(WatcherException cause) {

                    }
                });
            }

            @Override
            public Object list(ListOptions params, String namespace, OperationContext context) {
                PodNodeScheduler.nodeList = client.nodes().list();
                return PodNodeScheduler.nodeList;
            }
        };

        defaultSharedIndexInformerNode = new DefaultSharedIndexInformer(Node.class, listerWatcher, 600000, operationContext, workerQueueNode);

        try {
            defaultSharedIndexInformerNode.run();
        } catch (Exception e) {
            e.printStackTrace();
        }

        defaultSharedIndexInformerNode.addEventHandler(new ResourceEventHandler<>() {
            @Override
            public void onAdd(Node obj) {

            }

            @Override
            public void onUpdate(Node oldObj, Node newObj) {

            }

            @Override
            public void onDelete(Node obj, boolean deletedFinalStateUnknown) {

            }
        });
    }

    /**
     *
     */
    private void setUpIndexInformerNode() {
        ListerWatcher listerWatcher = new ListerWatcher() {
            @Override
            public Watch watch(ListOptions params, String namespace, OperationContext context, Watcher watcher) {
                return client.nodes().watch(new Watcher<Node>() {
                    @Override
                    public void eventReceived(Action action, Node resource) {

                    }

                    @Override
                    public void onClose(WatcherException cause) {

                    }
                });
            }

            @Override
            public Object list(ListOptions params, String namespace, OperationContext context) {
                PodNodeScheduler.nodeList = client.nodes().list();
                return PodNodeScheduler.nodeList;
            }
        };

        defaultSharedIndexInformerNode = new DefaultSharedIndexInformer(Node.class, listerWatcher, 600000, operationContext, workerQueueNode);

        try {
            defaultSharedIndexInformerNode.run();
        } catch (Exception e) {
            e.printStackTrace();
        }

        defaultSharedIndexInformerNode.addEventHandler(new ResourceEventHandler<Node>() {
            @Override
            public void onAdd(Node obj) {

            }

            @Override
            public void onUpdate(Node oldObj, Node newObj) {

            }

            @Override
            public void onDelete(Node obj, boolean deletedFinalStateUnknown) {

            }
        });
    }

Replace Generic With Diamond Watcher<Node> with Watcher<> in method private setUpIndexInformerNode() : void from class tuberlin.dos.kubscheduler.CurrentPodNodeStatus


  public static List<AnropsBehorighetsInfoType> createAnropsBehorigheterWithDuplicates() {
    List<AnropsBehorighetsInfoType> authorization = new ArrayList<>();
    authorization.add(createAuthorization(TestTakDataDefines.SENDER_1, TestTakDataDefines.NAMNRYMD_1, TestTakDataDefines.RECEIVER_1));
    authorization.add(createAuthorization(TestTakDataDefines.SENDER_1, TestTakDataDefines.NAMNRYMD_1, TestTakDataDefines.RECEIVER_1));
    return authorization;
  }

  public static List<AnropsBehorighetsInfoType> createAnropsBehorigheterWithDuplicates() {
    List<AnropsBehorighetsInfoType> authorization = new ArrayList<AnropsBehorighetsInfoType>();
    authorization.add(createAuthorization(TestTakDataDefines.SENDER_1, TestTakDataDefines.NAMNRYMD_1, TestTakDataDefines.RECEIVER_1));
    authorization.add(createAuthorization(TestTakDataDefines.SENDER_1, TestTakDataDefines.NAMNRYMD_1, TestTakDataDefines.RECEIVER_1));
    return authorization;
  }

Replace Generic With Diamond ArrayList<AnropsBehorighetsInfoType> with ArrayList<> in method public createAnropsBehorigheterWithDuplicates() : List<AnropsBehorighetsInfoType> from class se.skltp.tak.services.impl.TakCacheServiceImplTest


  @Override
  @Synchronized
  public Set<String> getAllSupportedNamespacesByLogicalAddressAndConsumer(String logicalAddress, String consumerId) {
    final Set<String> namespaces = new HashSet<>();

    for (final AnropsBehorighetsInfoType authInfo : geAnropsBehorigheter()) {
      if (authInfo.getReceiverId().equalsIgnoreCase(logicalAddress) && isConsumerIdMatchingOrNull(authInfo, consumerId) && isValidAccordingToTime(authInfo) ) {
        namespaces.add(authInfo.getTjansteKontrakt());
      }
    }
    return namespaces;
  }

  @Override
  @Synchronized
  public Set<String> getAllSupportedNamespacesByLogicalAddressAndConsumer(String logicalAddress, String consumerId) {
    final Set<String> namespaces = new HashSet<String>();

    for (final AnropsBehorighetsInfoType authInfo : geAnropsBehorigheter()) {
      if (authInfo.getReceiverId().equalsIgnoreCase(logicalAddress) && isConsumerIdMatchingOrNull(authInfo, consumerId) && isValidAccordingToTime(authInfo) ) {
        namespaces.add(authInfo.getTjansteKontrakt());
      }
    }
    return namespaces;
  }

Replace Generic With Diamond HashSet<String> with HashSet<> in method public getAllSupportedNamespacesByLogicalAddressAndConsumer(logicalAddress String, consumerId String) : Set<String> from class se.skltp.tak.services.impl.TakCacheServiceImpl


	/**
	 * Constructeur privé de la classe Partie.
	 * <p>
	 * Initialise les joueurs et les zones de la partie.
	 */
	private Partie() {
		this.joueur1 = new Joueur(Equipe.UNE);
		this.joueur2 = new Joueur(Equipe.DEUX);
		this.zones = new ArrayList<>();

		// on récupère tous les noms de zones
		EnumSet<NomZone> zones = EnumSet.allOf(NomZone.class);
		// on crée une zone pour chaque nom de zone
		for (NomZone nom : zones) {
			this.zones.add(new Zone(nom));
		}
	}

	/**
	 * Constructeur privé de la classe Partie.
	 * <p>
	 * Initialise les joueurs et les zones de la partie.
	 */
	private Partie() {
		this.joueur1 = new Joueur(Equipe.UNE);
		this.joueur2 = new Joueur(Equipe.DEUX);
		this.zones = new ArrayList<Zone>();

		// on récupère tous les noms de zones
		EnumSet<NomZone> zones = EnumSet.allOf(NomZone.class);
		// on crée une zone pour chaque nom de zone
		for (NomZone nom : zones) {
			this.zones.add(new Zone(nom));
		}
	}

Replace Generic With Diamond ArrayList<Zone> with ArrayList<> in method private Partie() from class Partie


	/**
	 * Retourne la liste de tous les étudiants présents sur cette zone triés par
	 * leur initiative, de la plus grande à la plus petite.
	 *
	 * @return la liste des étudiants triés par initiative
	 */
	private List<Etudiant> getTroupesParInitiative() {
		List<Etudiant> troupes = new ArrayList<>();
		troupes.addAll(this.troupesEquipe1.values());
		troupes.addAll(this.troupesEquipe2.values());
		troupes.sort(Comparator.comparingInt(Etudiant::getInitiative).reversed());
		return troupes;
	}

	/**
	 * Retourne la liste de tous les étudiants présents sur cette zone triés par
	 * leur initiative, de la plus grande à la plus petite.
	 *
	 * @return la liste des étudiants triés par initiative
	 */
	private List<Etudiant> getTroupesParInitiative() {
		List<Etudiant> troupes = new ArrayList<Etudiant>();
		troupes.addAll(this.troupesEquipe1.values());
		troupes.addAll(this.troupesEquipe2.values());
		troupes.sort(Comparator.comparingInt(Etudiant::getInitiative).reversed());
		return troupes;
	}

Replace Generic With Diamond ArrayList<Etudiant> with ArrayList<> in method private getTroupesParInitiative() : List<Etudiant> from class Zone


    public Completable apply() {
        return Completable.create(completableEmitter -> {
            try {
                User user = User.getInstance().blockingGet();
                user.setAge(user.getAge() + deltaAge);
                user.setCash(user.getCash() + deltaCash);
                user.setCredit(user.getCredit() + deltaCredit);
                user.setMoneyFlow(user.getMoneyFlow() + deltaMoneyFlow);

                if (deferredEvents != null) {
                    user.addDeferredEvents(deferredEvents);
                }

                completableEmitter.onComplete();

            } catch (RuntimeException e) {
                e.printStackTrace();
                completableEmitter.onError(e);
            }
        });
    }

    public Completable apply() {
        return new Completable() {
            @Override
            protected void subscribeActual(CompletableObserver completableObserver) {
                try {
                    User user = User.getInstance().blockingGet();
                    user.setAge(user.getAge() + deltaAge);
                    user.setCash(user.getCash() + deltaCash);
                    user.setCredit(user.getCredit() + deltaCredit);
                    user.setMoneyFlow(user.getMoneyFlow() + deltaMoneyFlow);

                    completableObserver.onComplete();

                } catch (RuntimeException e) {
                    e.printStackTrace();
                    completableObserver.onError(e);
                }
            }
        };
    }

Replace Anonymous With Lambda com.company.prodamgarage.models.user.UserChanges.apply.new Completable with completableEmitter -> {tryUser user=User.getInstance().blockingGet(); in method public apply() : Completable from class com.company.prodamgarage.models.user.UserChanges


    /**
     * 格式化输出所有消息至标准输入输出
     */
    public void printAllMessages() {
        System.out.println("========= Processing Results ========  ");
        this.visit(rootGroup, message -> {
            StringBuilder output = new StringBuilder();
            if (message instanceof TextMessage) {
                output.append(StringUtils.repeat(" ", (message.getLevel() - 1) * 2))
                        .append("|- ")
                        .append(((TextMessage) message).getContent());
            }
            else if (message instanceof MessageGroup) {
                output.append(StringUtils.repeat(" ", (message.getLevel() - 1) * 2))
                        .append("|- ")
                        .append(((MessageGroup) message).getGroupName());
            }
            System.out.println(output);
        });
        System.out.println("========= Processing Results ========  ");
    }

    /**
     * 格式化输出所有消息至标准输入输出
     */
    public void printAllMessages() {
        System.out.println("========= Processing Results ========  ");
        this.visit(rootGroup, new Visitor<Message>() {
            @Override
            public void consume(Message message) {
                StringBuilder output = new StringBuilder();
                if (message instanceof TextMessage) {
                    output.append(StringUtils.repeat(" ", (message.getLevel() - 1) * 2))
                            .append("|- ")
                            .append(((TextMessage) message).getContent());
                }
                else if (message instanceof MessageGroup) {
                    output.append(StringUtils.repeat(" ", (message.getLevel() - 1) * 2))
                            .append("|- ")
                            .append(((MessageGroup) message).getGroupName());
                }
                System.out.println(output.toString());
            }
        });
        System.out.println("========= Processing Results ========  ");
    }

Replace Anonymous With Lambda com.github.swiftech.swiftmarker.ProcessContext.printAllMessages.visit.new Visitor<Message> with message -> {StringBuilder output=new StringBuilder(); in method public printAllMessages() : void from class com.github.swiftech.swiftmarker.ProcessContext


    public Collection<LocaleWarp> getSupportedLocales () {
        SortedSet<LocaleWarp> set = new TreeSet<> ();
        for (Locale locale : softCache.keySet ())
            set.add (new LocaleWarp (locale));
        return set;
    }

    public Collection<LocaleWarp> getSupportedLocales () {
        SortedSet<LocaleWarp> set = new TreeSet<LocaleWarp> ();
        for (Locale locale : softCache.keySet ())
            set.add (new LocaleWarp (locale));
        return set;
    }

Replace Generic With Diamond TreeSet<LocaleWarp> with TreeSet<> in method public getSupportedLocales() : Collection<LocaleWarp> from class org.dreamwork.i18n.AbstractResourceAdapter


    public Collection () {
        indexes = new ArrayList<> ();
    }

    public Collection () {
        indexes = new ArrayList<String> ();
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public Collection() from class org.dreamwork.util.Collection


    public Collection (int cap) {
        super (cap);
        indexes = new ArrayList<> (cap);
    }

    public Collection (int cap) {
        super (cap);
        indexes = new ArrayList<String> (cap);
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public Collection(cap int) from class org.dreamwork.util.Collection


    /**
     * Method add. Добавление заявки.
     * @param item Заявка.
     * @return Заявка
     */
    @Override
    public Item add(Item item) {
        try (PreparedStatement sql = this.connection.prepareStatement("INSERT INTO ITEM(item_name, item_description, created, changed) VALUES(?,?,?,?)")) {
            //sql.setString(1, item.getId());
            sql.setString(1, item.getName());
            sql.setString(2, item.getDescription());
            sql.setTimestamp(3, longToTimestamp(item.getCreated()));
            sql.setTimestamp(4, longToTimestamp(item.getChanged()));
            sql.executeUpdate();
            item.setId(Integer.toString(getCurrentValue()));
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        }
        return item;
    }

    /**
     * Method add. Добавление заявки.
     * @param item Заявка.
     * @return Заявка
     */
    @Override
    public Item add(Item item) {
        try {
            sql = this.connection.prepareStatement("INSERT INTO ITEM VALUES(?,?,?,?,?)");
            sql.setString(1, item.getId());
            sql.setString(2, item.getName());
            sql.setString(3, item.getDescription());
            sql.setTimestamp(4, longToTimestamp(item.getCreated()));
            sql.setTimestamp(5, longToTimestamp(item.getChanged()));
            sql.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        } finally {
            checkClose();
        }
        return item;
    }

Try With Resources try(PreparedStatement sql=this.connection.prepareStatement("INSERT INTO ITEM(item_name, item_description, created, changed) VALUES(?,?,?,?)")) in method public add(item Item) : Item from class ru.job4j.jdbc.TrackerSQL


    /**
     * Method replace. Замена заявки.
     * @param id ID заявки.
     * @param item Заявка.
     * @return Признак найдена ли заявка
     */
    @Override
    public boolean replace(String id, Item item) {
        boolean res = false;
        try (PreparedStatement sql = this.connection.prepareStatement("UPDATE ITEM SET ID = ?, ITEM_NAME = ?, ITEM_DESCRIPTION = ?, CREATED = ?, CHANGED = ? WHERE ID = ?")) {
            sql.setInt(1, Integer.valueOf(item.getId()));
            sql.setString(2, item.getName());
            sql.setString(3, item.getDescription());
            sql.setTimestamp(4, longToTimestamp(item.getCreated()));
            sql.setTimestamp(5, longToTimestamp(item.getChanged()));
            sql.setInt(6, Integer.valueOf(id));
            sql.executeUpdate();
            if (sql.getUpdateCount() > 0) {
                res = true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        }
        return res;
    }

    /**
     * Method replace. Замена заявки.
     * @param id ID заявки.
     * @param item Заявка.
     * @return Признак найдена ли заявка
     */
    @Override
    public boolean replace(String id, Item item) {
        boolean res = false;
        try {
            sql = this.connection.prepareStatement("UPDATE ITEM SET ID = ?, ITEM_NAME = ?, ITEM_DESCRIPTION = ?, CREATED = ?, CHANGED = ? WHERE ID = ?");
            sql.setString(1, item.getId());
            sql.setString(2, item.getName());
            sql.setString(3, item.getDescription());
            sql.setTimestamp(4, longToTimestamp(item.getCreated()));
            sql.setTimestamp(5, longToTimestamp(item.getChanged()));
            sql.setString(6, id);
            sql.executeUpdate();
            if (sql.getUpdateCount() > 0) {
                res = true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        } finally {
            checkClose();
        }
        return res;
    }

Try With Resources try(PreparedStatement sql=this.connection.prepareStatement("UPDATE ITEM SET ID = ?, ITEM_NAME = ?, ITEM_DESCRIPTION = ?, CREATED = ?, CHANGED = ? WHERE ID = ?")) in method public replace(id String, item Item) : boolean from class ru.job4j.jdbc.TrackerSQL


    /**
     * Method delete. Удаление заявки.
     * @param id ID заявки.
     * @return Признак удалена ли заявка
     */
    @Override
    public boolean delete(String id) {
        boolean res = false;
        try (PreparedStatement sql = this.connection.prepareStatement("DELETE FROM ITEM WHERE ID = ?")) {
            sql.setInt(1, Integer.valueOf(id));
            sql.executeUpdate();
            if (sql.getUpdateCount() > 0) {
                res = true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        }
        return res;
    }

    /**
     * Method delete. Удаление заявки.
     * @param id ID заявки.
     * @return Признак удалена ли заявка
     */
    @Override
    public boolean delete(String id) {
        boolean res = false;
        try {
            sql = this.connection.prepareStatement("DELETE FROM ITEM WHERE ID = ?");
            sql.setString(1, id);
            sql.executeUpdate();
            if (sql.getUpdateCount() > 0) {
                res = true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        } finally {
            checkClose();
        }
        return res;
    }

Try With Resources try(PreparedStatement sql=this.connection.prepareStatement("DELETE FROM ITEM WHERE ID = ?")) in method public delete(id String) : boolean from class ru.job4j.jdbc.TrackerSQL


    /**
     * Method findAll. Получение списка текущих заявок.
     * @return Заявки.
     */
    @Override
    public ArrayList<Item> findAll() {
        ArrayList<Item> res = new ArrayList<>();
        try (PreparedStatement sql = this.connection.prepareStatement("SELECT * FROM ITEM")) {
            try (ResultSet rs = sql.executeQuery()) {
                while (rs.next()) {
                    res.add(new Item(rs.getString("id"),
                            rs.getString("item_name"),
                            rs.getString("item_description"),
                            timestampToLong(rs.getTimestamp("created")),
                            timestampToLong(rs.getTimestamp("changed")))
                    );
                }
            }
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        }
        return res;
    }

    /**
     * Method findAll. Получение списка текущих заявок.
     * @return Заявки.
     */
    @Override
    public ArrayList<Item> findAll() {
        ArrayList<Item> res = new ArrayList<>();
        try {
            sql = this.connection.prepareStatement("SELECT * FROM ITEM");
            rs = sql.executeQuery();
            while (rs.next()) {
                res.add(new Item(rs.getString("id"),
                                 rs.getString("item_name"),
                                 rs.getString("item_description"),
                                 timestampToLong(rs.getTimestamp("created")),
                                 timestampToLong(rs.getTimestamp("changed")))
                        );
            }
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        } finally {
            checkClose();
        }
        return res;
    }

Try With Resources try(ResultSet rs=sql.executeQuery()) in method public findAll() : ArrayList<Item> from class ru.job4j.jdbc.TrackerSQL


    /**
     * Method findByName. Поиск заявки по NAME.
     * @param name ID заявки.
     * @return Заявка
     */
    @Override
    public ArrayList<Item> findByName(String name) {
        ArrayList<Item> res = new ArrayList<>();
        try (PreparedStatement sql = this.connection.prepareStatement("SELECT * FROM ITEM WHERE ITEM_NAME = ?")) {
            sql.setString(1, name);
            try (ResultSet rs = sql.executeQuery()) {
                while (rs.next()) {
                    res.add(new Item(rs.getString("id"),
                                    rs.getString("item_name"),
                                    rs.getString("item_description"),
                                    timestampToLong(rs.getTimestamp("created")),
                                    timestampToLong(rs.getTimestamp("changed"))
                            )
                    );
                }
            }
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        }
        return res;
    }

    /**
     * Method findByName. Поиск заявки по NAME.
     * @param name ID заявки.
     * @return Заявка
     */
    @Override
    public ArrayList<Item> findByName(String name) {
        ArrayList<Item> res = new ArrayList<>();
        try {
            sql = this.connection.prepareStatement("SELECT * FROM ITEM WHERE ITEM_NAME = ?");
            sql.setString(1, name);
            rs = sql.executeQuery();
            while (rs.next()) {
                res.add(new Item(rs.getString("id"),
                                 rs.getString("item_name"),
                                 rs.getString("item_description"),
                                 timestampToLong(rs.getTimestamp("created")),
                                 timestampToLong(rs.getTimestamp("changed"))
                        )
                        );
            }
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        } finally {
            checkClose();
        }
        return res;
    }

Try With Resources try(ResultSet rs=sql.executeQuery()) in method public findByName(name String) : ArrayList<Item> from class ru.job4j.jdbc.TrackerSQL


    /**
     * Method findById. Поиск заявки по ID.
     * @param id ID заявки.
     * @return Заявка
     */
    @Override
    public Item findById(String id) {
        Item res = null;
        try (PreparedStatement sql = this.connection.prepareStatement("SELECT * FROM ITEM WHERE ID = ?")) {
            sql.setInt(1, Integer.valueOf(id));
            try (ResultSet rs = sql.executeQuery()) {
                while (rs.next()) {
                    res = new Item(Integer.toString(rs.getInt("id")),
                            rs.getString("item_name"),
                            rs.getString("item_description"),
                            timestampToLong(rs.getTimestamp("created")),
                            timestampToLong(rs.getTimestamp("changed"))
                    );
                }
            }
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        }
        return res;
    }

    /**
     * Method findById. Поиск заявки по ID.
     * @param id ID заявки.
     * @return Заявка
     */
    @Override
    public Item findById(String id) {
        Item res = null;
        try {
            sql = this.connection.prepareStatement("SELECT * FROM ITEM WHERE ID = ?");
            sql.setString(1, id);
            rs = sql.executeQuery();
            while (rs.next()) {
                res = new Item(rs.getString("id"),
                               rs.getString("item_name"),
                               rs.getString("item_description"),
                               timestampToLong(rs.getTimestamp("created")),
                               timestampToLong(rs.getTimestamp("changed"))
                               );
            }
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        } finally {
            checkClose();
        }
        return res;
    }

Try With Resources try(ResultSet rs=sql.executeQuery()) in method public findById(id String) : Item from class ru.job4j.jdbc.TrackerSQL


    /**
     * Method change. Изменение заявки.
     * @param id ID заявки.
     * @param item Заявка.
     * @return Признак найдена ли заявка
     */
    @Override
    public boolean change(String id, Item item) {
        boolean res = false;
        try (PreparedStatement sql = this.connection.prepareStatement("UPDATE ITEM SET ITEM_NAME = ?, ITEM_DESCRIPTION = ?, CREATED = ?, CHANGED = ? WHERE ID = ?")) {
            sql.setString(1, item.getName());
            sql.setString(2, item.getDescription());
            sql.setTimestamp(3, longToTimestamp(item.getCreated()));
            sql.setTimestamp(4, longToTimestamp(item.getChanged()));
            sql.setInt(5, Integer.valueOf(id));
            sql.executeUpdate();
            if (sql.getUpdateCount() > 0) {
                res = true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        }
        return res;
    }

    /**
     * Method change. Изменение заявки.
     * @param id ID заявки.
     * @param item Заявка.
     * @return Признак найдена ли заявка
     */
    @Override
    public boolean change(String id, Item item) {
        boolean res = false;
        try {
            sql = this.connection.prepareStatement("UPDATE ITEM SET ITEM_NAME = ?, ITEM_DESCRIPTION = ?, CREATED = ?, CHANGED = ? WHERE ID = ?");
            sql.setString(1, item.getName());
            sql.setString(2, item.getDescription());
            sql.setTimestamp(3, longToTimestamp(item.getCreated()));
            sql.setTimestamp(4, longToTimestamp(item.getChanged()));
            sql.setString(5, id);
            sql.executeUpdate();
            if (sql.getUpdateCount() > 0) {
                res = true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
            throw new TrackerSQLException(e.getSQLState());
        } finally {
            checkClose();
        }
        return res;
    }

Try With Resources try(PreparedStatement sql=this.connection.prepareStatement("UPDATE ITEM SET ITEM_NAME = ?, ITEM_DESCRIPTION = ?, CREATED = ?, CHANGED = ? WHERE ID = ?")) in method public change(id String, item Item) : boolean from class ru.job4j.jdbc.TrackerSQL


    /**
     * Method zipDir. Метод архивации.
     * @param arguments Аргументы.
     */
    public void zipDir(Args arguments) {
        File in = arguments.directory();
        File out = arguments.output();
        ArrayList<String> exclude = arguments.exclude();
        try (FileOutputStream dest = new FileOutputStream(new File(out, in.getName() + ".zip"));
             ZipOutputStream zipOut = new ZipOutputStream(dest)) {
            zipDirTree(in, in, zipOut, exclude);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Method zipDir. Метод архивации.
     * @param arguments Аргументы.
     */
    public void zipDir(Args arguments) {
        File in = arguments.directory();
        File out = arguments.output();
        ArrayList<String> exclude = arguments.exclude();
        try {
            FileOutputStream dest = new FileOutputStream(new File(out, in.getName() + ".zip"));
            ZipOutputStream zipOut = new ZipOutputStream(dest);
            zipDirTree(in, in, zipOut, exclude);
            zipOut.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

Try With Resources try(FileOutputStream dest=new FileOutputStream(new File(out,in.getName() + ".zip")); ZipOutputStream zipOut=new ZipOutputStream(dest)) in method public zipDir(arguments Args) : void from class ru.job4j.inout.PackZip


    /**
     * Method zipDirTree. Рекурсивный метод архивации.
     * @param root Корневой каталог.
     * @param current Текущий каталог.
     * @param out Выходной поток.
     * @param exclude Список исключаемых расширений.
     */
    private void zipDirTree(File root, File current, ZipOutputStream out, ArrayList<String> exclude) throws Exception {
        byte[] data = new byte[2048];
        File[] files = current.listFiles();
        boolean check = false;
        if (files != null) {
            for (File file : files) {
                if (file.isDirectory()) {
                    for (File f : file.listFiles()) {
                        if (!f.isDirectory() && !exclude.contains(f.getName().substring(f.getName().indexOf(".")))) {
                            check = true;
                            break;
                        }
                    }
                    if (!check) {
                        out.putNextEntry(new ZipEntry(file.getAbsolutePath().replace(root.getAbsolutePath() + "\\", "") + "\\"));
                        out.closeEntry();
                    }
                    zipDirTree(root, file, out, exclude);
                } else {
                    try (FileInputStream fi = new FileInputStream(file);
                         BufferedInputStream origin = new BufferedInputStream(fi, 2048)) {
                        if (!exclude.contains(file.getName().substring(file.getName().indexOf(".")))) {
                            String name = file.getAbsolutePath().replace(root.getAbsolutePath() + "\\", "");
                            ZipEntry entry = new ZipEntry(name);
                            out.putNextEntry(entry);
                            int count;
                            while ((count = origin.read(data, 0, 2048)) != -1) {
                                out.write(data, 0, count);
                            }
                        }
                    } catch (java.lang.StringIndexOutOfBoundsException e) {
                        System.out.println(file.getName());
                    }
                }
            }
        }
    }

    /**
     * Method zipDirTree. Рекурсивный метод архивации.
     * @param root Корневой каталог.
     * @param current Текущий каталог.
     * @param out Выходной поток.
     * @param exclude Список исключаемых расширений.
     */
    private void zipDirTree(File root, File current, ZipOutputStream out, ArrayList<String> exclude) throws Exception {
        byte[] data = new byte[2048];
        File[] files = current.listFiles();
        boolean check = false;
        if (files != null) {
            for (File file : files) {
                if (file.isDirectory()) {
                    for (File f : file.listFiles()) {
                        if (!f.isDirectory() && !exclude.contains(f.getName().substring(f.getName().indexOf(".")))) {
                            check = true;
                            break;
                        }
                    }
                    if (!check) {
                        out.putNextEntry(new ZipEntry(file.getAbsolutePath().replace(root.getAbsolutePath() + "\\", "") + "\\"));
                        out.closeEntry();
                    }
                    zipDirTree(root, file, out, exclude);
                } else {
                    try {
                        if (!exclude.contains(file.getName().substring(file.getName().indexOf(".")))) {
                            FileInputStream fi = new FileInputStream(file);
                            String name = file.getAbsolutePath().replace(root.getAbsolutePath() + "\\", "");
                            ZipEntry entry = new ZipEntry(name);
                            out.putNextEntry(entry);
                            int count;
                            BufferedInputStream origin = new BufferedInputStream(fi, 2048);
                            while ((count = origin.read(data, 0, 2048)) != -1) {
                                out.write(data, 0, count);
                            }
                            origin.close();
                        }
                    } catch (java.lang.StringIndexOutOfBoundsException e) {
                        System.out.println(file.getName());
                    }
                }
            }
        }
    }

Try With Resources try(FileInputStream fi=new FileInputStream(file); BufferedInputStream origin=new BufferedInputStream(fi,2048)) in method private zipDirTree(root File, current File, out ZipOutputStream, exclude ArrayList<String>) : void from class ru.job4j.inout.PackZip


    /**
     * Method move. Ход фигуры.
     * @param source Исходная клетка.
     * @param dest Конечная клетка.
     * @return Возможен ли ход
     */
    public boolean move(Cell source, Cell dest) {
        boolean rst = false;
        int index = this.findBy(source);
        if (dest != null && index != -1 && this.findBy(dest) == -1) {
            try {
                Cell[] steps = this.figures[index].way(source, dest);
                for (int i = 0; i < steps.length; i++) {
                    if (steps[i] != null) {
                        if (!steps[i].equals(source) && this.findBy(steps[i]) != -1) {
                            throw new OccupiedWayException("OccupiedWayException");
                        }
                    }
                    if (steps[i] != null && steps[i].equals(dest)) {
                        rst = true;
                        this.figures[index] = this.figures[index].copy(dest);
                        break;
                    }
                }
            } catch (ImpossibleMoveException | OccupiedWayException ime) {
                rst = false;
            }
        }
        return rst;
    }

    /**
     * Method move. Ход фигуры.
     * @param source Исходная клетка.
     * @param dest Конечная клетка.
     * @return Возможен ли ход
     */
    public boolean move(Cell source, Cell dest) {
        boolean rst = false;
        int index = this.findBy(source);
        if (dest != null && index != -1 && this.findBy(dest) == -1) {
            try {
                Cell[] steps = this.figures[index].way(source, dest);
                for (int i = 0; i < steps.length; i++) {
                    if (steps[i] != null) {
                        if (!steps[i].equals(source) && this.findBy(steps[i]) != -1) {
                            throw new OccupiedWayException("OccupiedWayException");
                        }
                    }
                    if (steps[i] != null && steps[i].equals(dest)) {
                        rst = true;
                        this.figures[index] = this.figures[index].copy(dest);
                        break;
                    }
                }
            } catch (ImpossibleMoveException ime) {
                rst = false;
            } catch (OccupiedWayException owe) {
                rst = false;
            }
        }
        return rst;
    }

Merge Catch [catch(ImpossibleMoveException ime), catch(OccupiedWayException owe)] to catch(ImpossibleMoveException|OccupiedWayException ime) in method public move(source Cell, dest Cell) : boolean from class ru.job4j.chess.Logic


    /**
     * Find by id of the element.
     *
     * @param id - id of the element.
     * @return - user.
     */
    @Override
    public User findById(int id) {
        User resultId = null;
        try (Connection conn = SOURCE.getConnection();
             PreparedStatement st = conn.prepareStatement("SELECT * FROM users WHERE id = ?")) {
            st.setInt(1, id);
            try (ResultSet rs = st.executeQuery()) {
                while (rs.next()) {
                    resultId = new User(rs.getInt("id"), rs.getString("name"), rs.getString("login"), rs.getString("email"), new Date(rs.getTimestamp("createdate").getTime()));
                }
            }
        } catch (SQLException e) {
            LOGGER.error(fatal, "Failed to find by id. Id = {}.", id);
        }
        return resultId;
    }

    /**
     * Find by id of the element.
     *
     * @param id - id of the element.
     * @return - user.
     */
    @Override
    public User findById(int id) {
        User resultId = null;
        if (this.conn == null) {
            connect();
        }
        try {
            this.st = this.conn.prepareStatement("SELECT * FROM users WHERE id = ?");
            this.st.setInt(1, id);
            this.rs = this.st.executeQuery();
            while (this.rs.next()) {
                resultId = new User(this.rs.getInt("id"), this.rs.getString("name"), this.rs.getString("login"), this.rs.getString("email"), new Date(this.rs.getTimestamp("createdate").getTime()));
            }
            this.rs.close();
            this.st.close();
        } catch (SQLException e) {
            LOGGER.error(e.getMessage(), e);
        }
        return resultId;
    }

Try With Resources try(Connection conn=SOURCE.getConnection(); PreparedStatement st=conn.prepareStatement("SELECT * FROM users WHERE id = ?")) in method public findById(id int) : User from class ru.job4j.servlets.DBStore


    private void execute(int size) {
        for (int x = 0; x < size; x++) {
            treads.add(new Thread(() -> {
                Runnable nextTask = null;
                while (running) {
                    try {
                        nextTask = tasks.poll(1000, TimeUnit.MILLISECONDS);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    if (nextTask != null) {
                        nextTask.run();
                    } else {
                        System.out.println(Thread.currentThread().getName() + " - waiting.");
                    }
                }
            }));
        }
        for (Thread thr : this.treads) {
            thr.start();
        }
    }

    private void execute(int size) throws InterruptedException {
        for (int x = 0; x < size; x++) {
            treads.add(new Thread(new Runnable() {
                @Override
                public void run() {
                    Runnable nextTask;
                    while (running) {
                        nextTask = tasks.poll();
                        synchronized (lock) {
                            if (nextTask != null) {
                                nextTask.run();
                            } else {
                                try {
                                    System.out.println(Thread.currentThread().getName() + " - waiting");
                                    lock.wait();
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                    }
                }
            }));
        }
        for (Thread thr : this.treads) {
            thr.start();
        }
    }

Replace Anonymous With Lambda ru.job4j.wait.ThreadPool.execute.add.new Thread.new Runnable with () -> {Runnable nextTask=null; in method private execute(size int) : void from class ru.job4j.wait.ThreadPool


    public int longestConsecutive(int[] nums) {
        Set<Integer> num_set = new HashSet<>();
        for (int num : nums) {
            num_set.add(num);
        }

        int longestStreak = 0;

        for (int num : num_set) {
            if (!num_set.contains(num - 1)) {
                int currentNum = num;
                int currentStreak = 1;

                while (num_set.contains(currentNum + 1)) {
                    currentNum += 1;
                    currentStreak += 1;
                }

                longestStreak = Math.max(longestStreak, currentStreak);
            }
        }

        return longestStreak;
    }

    public int longestConsecutive(int[] nums) {
        Set<Integer> num_set = new HashSet<Integer>();
        for (int num : nums) {
            num_set.add(num);
        }

        int longestStreak = 0;

        for (int num : num_set) {
            if (!num_set.contains(num - 1)) {
                int currentNum = num;
                int currentStreak = 1;

                while (num_set.contains(currentNum + 1)) {
                    currentNum += 1;
                    currentStreak += 1;
                }

                longestStreak = Math.max(longestStreak, currentStreak);
            }
        }

        return longestStreak;
    }

Replace Generic With Diamond HashSet<Integer> with HashSet<> in method public longestConsecutive(nums int[]) : int from class org.example.leetcode.pagethree.LongestConsecutiveSequence128


    private List<Integer> dfsHelper(int l, int r) {
        int idx = l, num = cArr[idx] - '0';
        List<Integer> nArr = new ArrayList<>();

        while ((idx + 1 <= r) && Character.isDigit(cArr[idx + 1])) {
            idx++;
            num = num * 10 + (cArr[idx] - '0');
        }

        if (idx == r) {
            nArr.add(num); return nArr;
        }

        for (int i = idx + 1; i <= r; i++) {
            if (Character.isDigit(cArr[i]))
                continue;
            List<Integer> left = this.dfsHelper(l, i - 1);
            List<Integer> right = this.dfsHelper(i + 1, r);
            for (int val_l : left) {
                for (int val_r : right) {
                    char opt = cArr[i];
                    int output = 0;

                    if (opt == '+')
                        output = val_l + val_r;
                    else if (opt == '-')
                        output = val_l - val_r;
                    else if (opt == '*')
                        output = val_l * val_r;

                    nArr.add(output);
                }
            }
        }
        return nArr;
    }

    private List<Integer> dfsHelper(int l, int r) {
        int idx = l, num = cArr[idx] - '0';
        List<Integer> nArr = new ArrayList<Integer>();

        while ((idx + 1 <= r) && Character.isDigit(cArr[idx + 1])) {
            idx++;
            num = num * 10 + (cArr[idx] - '0');
        }

        if (idx == r) {
            nArr.add(num); return nArr;
        }

        for (int i = idx + 1; i <= r; i++) {
            if (Character.isDigit(cArr[i]))
                continue;
            List<Integer> left = this.dfsHelper(l, i - 1);
            List<Integer> right = this.dfsHelper(i + 1, r);
            for (int val_l : left) {
                for (int val_r : right) {
                    char opt = cArr[i];
                    int output = 0;

                    if (opt == '+')
                        output = val_l + val_r;
                    else if (opt == '-')
                        output = val_l - val_r;
                    else if (opt == '*')
                        output = val_l * val_r;

                    nArr.add(output);
                }
            }
        }
        return nArr;
    }

Replace Generic With Diamond ArrayList<Integer> with ArrayList<> in method private dfsHelper(l int, r int) : List<Integer> from class org.example.leetcode.pagefive.DifferentWaysToAddParentheses241


    public int calculate(String s) {
        Deque<Integer> stack = new LinkedList<>();
        char preSign = '+';
        int num = 0;
        int n = s.length();
        for (int i = 0; i < n; ++i) {
            if (Character.isDigit(s.charAt(i))) {
                num = num * 10 + s.charAt(i) - '0';
            }
            if (!Character.isDigit(s.charAt(i)) && s.charAt(i) != ' ' || i == n - 1) {
                switch (preSign) {
                    case '+':
                        stack.push(num);
                        break;
                    case '-':
                        stack.push(-num);
                        break;
                    case '*':
                        stack.push(stack.pop() * num);
                        break;
                    default:
                        stack.push(stack.pop() / num);
                }
                preSign = s.charAt(i);
                num = 0;
            }
        }
        int ans = 0;
        while (!stack.isEmpty()) {
            ans += stack.pop();
        }
        return ans;
    }

    public int calculate(String s) {
        Deque<Integer> stack = new LinkedList<Integer>();
        char preSign = '+';
        int num = 0;
        int n = s.length();
        for (int i = 0; i < n; ++i) {
            if (Character.isDigit(s.charAt(i))) {
                num = num * 10 + s.charAt(i) - '0';
            }
            if (!Character.isDigit(s.charAt(i)) && s.charAt(i) != ' ' || i == n - 1) {
                switch (preSign) {
                    case '+':
                        stack.push(num);
                        break;
                    case '-':
                        stack.push(-num);
                        break;
                    case '*':
                        stack.push(stack.pop() * num);
                        break;
                    default:
                        stack.push(stack.pop() / num);
                }
                preSign = s.charAt(i);
                num = 0;
            }
        }
        int ans = 0;
        while (!stack.isEmpty()) {
            ans += stack.pop();
        }
        return ans;
    }

Replace Generic With Diamond LinkedList<Integer> with LinkedList<> in method public calculate(s String) : int from class org.example.leetcode.pagefive.BasicCalculatorII227


    public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) {
        int n = nums.length;
        Map<Long, Long> map = new HashMap<>();
        long w = (long) t + 1;
        for (int i = 0; i < n; i++) {
            long id = getID(nums[i], w);
            if (map.containsKey(id)) {
                return true;
            }
            if (map.containsKey(id - 1) && Math.abs(nums[i] - map.get(id - 1)) < w) {
                return true;
            }
            if (map.containsKey(id + 1) && Math.abs(nums[i] - map.get(id + 1)) < w) {
                return true;
            }
            map.put(id, (long) nums[i]);
            if (i >= k) {
                map.remove(getID(nums[i - k], w));
            }
        }
        return false;
    }

    public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) {
        int n = nums.length;
        Map<Long, Long> map = new HashMap<Long, Long>();
        long w = (long) t + 1;
        for (int i = 0; i < n; i++) {
            long id = getID(nums[i], w);
            if (map.containsKey(id)) {
                return true;
            }
            if (map.containsKey(id - 1) && Math.abs(nums[i] - map.get(id - 1)) < w) {
                return true;
            }
            if (map.containsKey(id + 1) && Math.abs(nums[i] - map.get(id + 1)) < w) {
                return true;
            }
            map.put(id, (long) nums[i]);
            if (i >= k) {
                map.remove(getID(nums[i - k], w));
            }
        }
        return false;
    }

Replace Generic With Diamond HashMap<Long,Long> with HashMap<> in method public containsNearbyAlmostDuplicate(nums int[], k int, t int) : boolean from class org.example.leetcode.pagefive.ContainsDuplicateIII220


    public List<String> summaryRanges(int[] nums) {
        List<String> ret = new ArrayList<>();
        int i = 0;
        int n = nums.length;
        while (i < n) {
            int low = i;
            i++;
            while (i < n && nums[i] == nums[i - 1] + 1) {
                i++;
            }
            int high = i - 1;
            StringBuffer temp = new StringBuffer(Integer.toString(nums[low]));
            if (low < high) {
                temp.append("->");
                temp.append(Integer.toString(nums[high]));
            }
            ret.add(temp.toString());
        }
        return ret;
    }

    public List<String> summaryRanges(int[] nums) {
        List<String> ret = new ArrayList<String>();
        int i = 0;
        int n = nums.length;
        while (i < n) {
            int low = i;
            i++;
            while (i < n && nums[i] == nums[i - 1] + 1) {
                i++;
            }
            int high = i - 1;
            StringBuffer temp = new StringBuffer(Integer.toString(nums[low]));
            if (low < high) {
                temp.append("->");
                temp.append(Integer.toString(nums[high]));
            }
            ret.add(temp.toString());
        }
        return ret;
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public summaryRanges(nums int[]) : List<String> from class org.example.leetcode.pagefive.SummaryRanges228


    public List<Integer> spiralOrder(int[][] matrix) {
        List<Integer> order = new ArrayList<>();
        if (matrix == null || matrix.length == 0 || matrix[0].length == 0) {
            return order;
        }
        int rows = matrix.length, columns = matrix[0].length;
        int left = 0, right = columns - 1, top = 0, bottom = rows - 1;
        while (left <= right && top <= bottom) {
            for (int column = left; column <= right; column++) {
                order.add(matrix[top][column]);
            }
            for (int row = top + 1; row <= bottom; row++) {
                order.add(matrix[row][right]);
            }
            if (left < right && top < bottom) {
                for (int column = right - 1; column > left; column--) {
                    order.add(matrix[bottom][column]);
                }
                for (int row = bottom; row > top; row--) {
                    order.add(matrix[row][left]);
                }
            }
            left++;
            right--;
            top++;
            bottom--;
        }
        return order;
    }

    public List<Integer> spiralOrder(int[][] matrix) {
        List<Integer> order = new ArrayList<Integer>();
        if (matrix == null || matrix.length == 0 || matrix[0].length == 0) {
            return order;
        }
        int rows = matrix.length, columns = matrix[0].length;
        int left = 0, right = columns - 1, top = 0, bottom = rows - 1;
        while (left <= right && top <= bottom) {
            for (int column = left; column <= right; column++) {
                order.add(matrix[top][column]);
            }
            for (int row = top + 1; row <= bottom; row++) {
                order.add(matrix[row][right]);
            }
            if (left < right && top < bottom) {
                for (int column = right - 1; column > left; column--) {
                    order.add(matrix[bottom][column]);
                }
                for (int row = bottom; row > top; row--) {
                    order.add(matrix[row][left]);
                }
            }
            left++;
            right--;
            top++;
            bottom--;
        }
        return order;
    }

Replace Generic With Diamond ArrayList<Integer> with ArrayList<> in method public spiralOrder(matrix int[][]) : List<Integer> from class org.example.leetcode.pagetwo.SpiralMatrix54


    public List<List<String>> groupAnagrams(String[] strs) {
        Map<String, List<String>> maps = new HashMap<>();

        for (String str : strs) {
            char[] chars = str.toCharArray();
            Arrays.sort(chars);
            String key = new String(chars);
            List<String> combination = maps.getOrDefault(key, new ArrayList<>());
            combination.add(str);
            maps.put(key, combination);
        }

        return new ArrayList<List<String>>(maps.values());
    }

    public List<List<String>> groupAnagrams(String[] strs) {
        Map<String, List<String>> maps = new HashMap<String, List<String>>();

        for (String str : strs) {
            char[] chars = str.toCharArray();
            Arrays.sort(chars);
            String key = new String(chars);
            List<String> combination = maps.getOrDefault(key, new ArrayList<>());
            combination.add(str);
            maps.put(key, combination);
        }

        return new ArrayList<List<String>>(maps.values());
    }

Replace Generic With Diamond HashMap<String,List<String>> with HashMap<> in method public groupAnagrams(strs String[]) : List<List<String>> from class org.example.leetcode.pageone.GroupAnagrams49


    public List<String> generateParenthesis(int n) {
        List<String> ans = new ArrayList<>();
        backtrack(ans, new StringBuilder(), 0, 0, n);
        return ans;
    }

    public List<String> generateParenthesis(int n) {
        List<String> ans = new ArrayList<String>();
        backtrack(ans, new StringBuilder(), 0, 0, n);
        return ans;
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public generateParenthesis(n int) : List<String> from class org.example.leetcode.pageone.GenerateParentheses22


    public int lengthOfLongestSubstring(String s) {
        // 哈希集合，记录每个字符是否出现过
        Set<Character> occ = new HashSet<>();
        int n = s.length();
        // 右指针，初始值为 -1，相当于我们在字符串的左边界的左侧，还没有开始移动
        int rk = -1, ans = 0;
        for (int i = 0; i < n; ++i) {
            if (i != 0) {
                // 左指针向右移动一格，移除一个字符
                occ.remove(s.charAt(i - 1));
            }
            while (rk + 1 < n && !occ.contains(s.charAt(rk + 1))) {
                // 不断地移动右指针
                occ.add(s.charAt(rk + 1));
                ++rk;
            }
            // 第 i 到 rk 个字符是一个极长的无重复字符子串
            ans = Math.max(ans, rk - i + 1);
        }
        return ans;
    }

    public int lengthOfLongestSubstring(String s) {
        // 哈希集合，记录每个字符是否出现过
        Set<Character> occ = new HashSet<Character>();
        int n = s.length();
        // 右指针，初始值为 -1，相当于我们在字符串的左边界的左侧，还没有开始移动
        int rk = -1, ans = 0;
        for (int i = 0; i < n; ++i) {
            if (i != 0) {
                // 左指针向右移动一格，移除一个字符
                occ.remove(s.charAt(i - 1));
            }
            while (rk + 1 < n && !occ.contains(s.charAt(rk + 1))) {
                // 不断地移动右指针
                occ.add(s.charAt(rk + 1));
                ++rk;
            }
            // 第 i 到 rk 个字符是一个极长的无重复字符子串
            ans = Math.max(ans, rk - i + 1);
        }
        return ans;
    }

Replace Generic With Diamond HashSet<Character> with HashSet<> in method public lengthOfLongestSubstring(s String) : int from class org.example.leetcode.pageone.LongestSubstringWithoutRepeatingCharacters3


    public List<List<Integer>> permute2(int[] nums) {
        this.nums = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            this.nums[i] = nums[i];
        }

        List<List<Integer>> results = new ArrayList<>();

        afs2(results, 0);

        return results;
    }

    public List<List<Integer>> permute2(int[] nums) {
        this.nums = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            this.nums[i] = nums[i];
        }

        List<List<Integer>> results = new ArrayList<List<Integer>>();

        afs2(results, 0);

        return results;
    }

Replace Generic With Diamond ArrayList<List<Integer>> with ArrayList<> in method public permute2(nums int[]) : List<List<Integer>> from class org.example.leetcode.pageone.Permutations46


    private void afs2(List<List<Integer>> results, int level) {
        if (level == nums.length) {
            List<Integer> combination = new ArrayList<>();
            for (int i = 0; i < nums.length; i++) {
                combination.add(nums[i]);
            }
            List<Integer> result = new ArrayList<>(combination);
            results.add(result);
            return;
        }

        for (int i = level; i < nums.length; i++) {
            int temp;
            temp = nums[level];
            nums[level] = nums[i];
            nums[i] = temp;

            afs2(results, level + 1);

            temp = nums[level];
            nums[level] = nums[i];
            nums[i] = temp;
        }
    }

    private void afs2(List<List<Integer>> results, int level) {
        if (level == nums.length) {
            List<Integer> combination = new ArrayList<Integer>();
            for (int i = 0; i < nums.length; i++) {
                combination.add(nums[i]);
            }
            List<Integer> result = new ArrayList<>(combination);
            results.add(result);
            return;
        }

        for (int i = level; i < nums.length; i++) {
            int temp;
            temp = nums[level];
            nums[level] = nums[i];
            nums[i] = temp;

            afs2(results, level + 1);

            temp = nums[level];
            nums[level] = nums[i];
            nums[i] = temp;
        }
    }

Replace Generic With Diamond ArrayList<Integer> with ArrayList<> in method private afs2(results List<List<Integer>>, level int) : void from class org.example.leetcode.pageone.Permutations46


    public void backtrack(int n, List<Integer> output, List<List<Integer>> res, int level) {
        // 所有数都填完了
        if (level == n) {
            res.add(new ArrayList<>(output));

            return;
        }

        for (int i = level; i < n; i++) {
            Collections.swap(output, level, i);
            backtrack(n, output, res, level + 1);
            Collections.swap(output, level, i);
        }
    }

    public void backtrack(int n, List<Integer> output, List<List<Integer>> res, int level) {
        // 所有数都填完了
        if (level == n) {
            res.add(new ArrayList<Integer>(output));

            return;
        }

        for (int i = level; i < n; i++) {
            Collections.swap(output, level, i);
            backtrack(n, output, res, level + 1);
            Collections.swap(output, level, i);
        }
    }

Replace Generic With Diamond ArrayList<Integer> with ArrayList<> in method public backtrack(n int, output List<Integer>, res List<List<Integer>>, level int) : void from class org.example.leetcode.pageone.Permutations46


    public void dfs(int cur, int last, int[] nums) {
        if (cur == nums.length) {
            if (temp.size() >= 2) {
                ans.add(new ArrayList<>(temp));
            }
            return;
        }
        if (nums[cur] >= last) {
            temp.add(nums[cur]);
            dfs(cur + 1, nums[cur], nums);
            temp.remove(temp.size() - 1);
        }
        if (nums[cur] != last) {
            dfs(cur + 1, last, nums);
        }
    }

    public void dfs(int cur, int last, int[] nums) {
        if (cur == nums.length) {
            if (temp.size() >= 2) {
                ans.add(new ArrayList<Integer>(temp));
            }
            return;
        }
        if (nums[cur] >= last) {
            temp.add(nums[cur]);
            dfs(cur + 1, nums[cur], nums);
            temp.remove(temp.size() - 1);
        }
        if (nums[cur] != last) {
            dfs(cur + 1, last, nums);
        }
    }

Replace Generic With Diamond ArrayList<Integer> with ArrayList<> in method public dfs(cur int, last int, nums int[]) : void from class org.example.leetcode.pageten.IncreasingSubsequences491


    public int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> hashtable = new HashMap<>();
        for (int i = 0; i < nums.length; ++i) {
            if (hashtable.containsKey(target - nums[i])) {
                return new int[]{hashtable.get(target - nums[i]), i};
            }
            hashtable.put(nums[i], i);
        }
        return new int[0];
    }

    public int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> hashtable = new HashMap<Integer, Integer>();
        for (int i = 0; i < nums.length; ++i) {
            if (hashtable.containsKey(target - nums[i])) {
                return new int[]{hashtable.get(target - nums[i]), i};
            }
            hashtable.put(nums[i], i);
        }
        return new int[0];
    }

Replace Generic With Diamond HashMap<Integer,Integer> with HashMap<> in method public twoSum(nums int[], target int) : int[] from class org.example.leetcode.pageone.TwoSum1


    @Test
    public void reconstructItinerary332Test() {
        ReconstructItinerary332 reconstructItinerary = new ReconstructItinerary332();
        List<List<String>> tickets = new ArrayList<>();
        List<String> t1 = new ArrayList<>() {
            {
                add("JFK");
                add("SFO");
            }
        };
        List<String> t2 = new ArrayList<>() {
            {
                add("JFK");
                add("ATL");
            }
        };
        List<String> t3 = new ArrayList<>() {
            {
                add("SFO");
                add("ATL");
            }
        };
        List<String> t4 = new ArrayList<>() {
            {
                add("ATL");
                add("JFK");
            }
        };
        List<String> t5 = new ArrayList<>() {
            {
                add("ATL");
                add("SFO");
            }
        };
        tickets.add(t1);
        tickets.add(t2);
        tickets.add(t3);
        tickets.add(t4);
        tickets.add(t5);

        System.out.println(Arrays.toString(reconstructItinerary.findItinerary(tickets).toArray()));

//        List<String> t1 = new ArrayList<>() {
//            {
//                add("MUC");
//                add("LHR");
//            }
//        };
//        List<String> t2 = new ArrayList<>() {
//            {
//                add("JFK");
//                add("MUC");
//            }
//        };
//        List<String> t3 = new ArrayList<String>() {
//            {
//                add("SFO");
//                add("SJC");
//            }
//        };
//        List<String> t4 = new ArrayList<String>() {
//            {
//                add("LHR");
//                add("SFO");
//            }
//        };
//
//        tickets.add(t1);
//        tickets.add(t2);
//        tickets.add(t3);
//        tickets.add(t4);
//
//        System.out.println(Arrays.toString(reconstructItinerary.findItinerary(tickets).toArray()));
    }

    @Test
    public void reconstructItinerary332Test() {
        ReconstructItinerary332 reconstructItinerary = new ReconstructItinerary332();
        List<List<String>> tickets = new ArrayList<>();
        List<String> t1 = new ArrayList<>() {
            {
                add("JFK");
                add("SFO");
            }
        };
        List<String> t2 = new ArrayList<>() {
            {
                add("JFK");
                add("ATL");
            }
        };
        List<String> t3 = new ArrayList<String>() {
            {
                add("SFO");
                add("ATL");
            }
        };
        List<String> t4 = new ArrayList<String>() {
            {
                add("ATL");
                add("JFK");
            }
        };
        List<String> t5 = new ArrayList<String>() {
            {
                add("ATL");
                add("SFO");
            }
        };
        tickets.add(t1);
        tickets.add(t2);
        tickets.add(t3);
        tickets.add(t4);
        tickets.add(t5);

        System.out.println(Arrays.toString(reconstructItinerary.findItinerary(tickets).toArray()));

//        List<String> t1 = new ArrayList<>() {
//            {
//                add("MUC");
//                add("LHR");
//            }
//        };
//        List<String> t2 = new ArrayList<>() {
//            {
//                add("JFK");
//                add("MUC");
//            }
//        };
//        List<String> t3 = new ArrayList<String>() {
//            {
//                add("SFO");
//                add("SJC");
//            }
//        };
//        List<String> t4 = new ArrayList<String>() {
//            {
//                add("LHR");
//                add("SFO");
//            }
//        };
//
//        tickets.add(t1);
//        tickets.add(t2);
//        tickets.add(t3);
//        tickets.add(t4);
//
//        System.out.println(Arrays.toString(reconstructItinerary.findItinerary(tickets).toArray()));
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method public reconstructItinerary332Test() : void from class org.example.PageSevenTest


    public List<String> letterCombine(String digits) {
        List<String> combinations = new ArrayList<>();
        if (digits.length() == 0) {
            return combinations;
        }
        Map<Character, String> phoneMap = new HashMap<>() {{
            put('2', "abc");
            put('3', "def");
            put('4', "ghi");
            put('5', "jkl");
            put('6', "mno");
            put('7', "pqrs");
            put('8', "tuv");
            put('9', "wxyz");
        }};
        backtrack(combinations, phoneMap, digits, 0, new StringBuffer());
        return combinations;
    }

    public List<String> letterCombine(String digits) {
        List<String> combinations = new ArrayList<String>();
        if (digits.length() == 0) {
            return combinations;
        }
        Map<Character, String> phoneMap = new HashMap<Character, String>() {{
            put('2', "abc");
            put('3', "def");
            put('4', "ghi");
            put('5', "jkl");
            put('6', "mno");
            put('7', "pqrs");
            put('8', "tuv");
            put('9', "wxyz");
        }};
        backtrack(combinations, phoneMap, digits, 0, new StringBuffer());
        return combinations;
    }

Replace Generic With Diamond HashMap<Character,String> with HashMap<> in method public letterCombine(digits String) : List<String> from class org.example.leetcode.pageone.LetterCombination17


    public List<List<String>> solveNQueens(int n) {
        List<List<String>> results = new ArrayList<>();
        int[] positions = new int[n];
        for (int i = 0; i < n; i++) {
            positions[i] = -1;
        }

        backTrack(results, n, 0, positions);

        return results;
    }

    public List<List<String>> solveNQueens(int n) {
        List<List<String>> results = new ArrayList<List<String>>();
        int[] positions = new int[n];
        for (int i = 0; i < n; i++) {
            positions[i] = -1;
        }

        backTrack(results, n, 0, positions);

        return results;
    }

Replace Generic With Diamond ArrayList<List<String>> with ArrayList<> in method public solveNQueens(n int) : List<List<String>> from class org.example.leetcode.pagetwo.NQueens


    private void backTrack(List<List<String>> results, int n, int row, int[] positions) {
        if (row == n) {
            List<String> result = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                StringBuffer string = new StringBuffer();
                for (int j = 0; j < n; j++) {
                    if (positions[i] == j) {
                        string.append("Q");
                    }
                    else {
                        string.append(".");
                    }
                }

                result.add(string.toString());
            }

            results.add(result);
            return;
        }

        for (int i = 0; i < n; i++) {
            positions[row] = i;

            if (InPlace(row, positions)) {
                backTrack(results, n, row + 1, positions);
            }

            positions[row] = -1;
        }
    }

    private void backTrack(List<List<String>> results, int n, int row, int[] positions) {
        if (row == n) {
            List<String> result = new ArrayList<String>();
            for (int i = 0; i < n; i++) {
                StringBuffer string = new StringBuffer();
                for (int j = 0; j < n; j++) {
                    if (positions[i] == j) {
                        string.append("Q");
                    }
                    else {
                        string.append(".");
                    }
                }

                result.add(string.toString());
            }

            results.add(result);
            return;
        }

        for (int i = 0; i < n; i++) {
            positions[row] = i;

            if (InPlace(row, positions)) {
                backTrack(results, n, row + 1, positions);
            }

            positions[row] = -1;
        }
    }

Replace Generic With Diamond ArrayList<String> with ArrayList<> in method private backTrack(results List<List<String>>, n int, row int, positions int[]) : void from class org.example.leetcode.pagetwo.NQueens


    public List<List<Integer>> fourSum(int[] nums, int target) {
        List<List<Integer>> results = new ArrayList<>();
        Arrays.sort(nums);

        for (int first = 0; first < nums.length; first++) {

            if (first > 0 && (nums[first] == nums[first - 1])) {
                continue;
            }

            for (int second = first + 1; second < nums.length; second++) {

                if (second > first + 1 && nums[second] == nums[second - 1]) {
                    continue;
                }

                int third = second + 1;
                int forth = nums.length - 1;

                while (third < forth) {
                    int sum = nums[first] + nums[second] + nums[third] + nums[forth];
                    if (sum == target) {
                        results.add(Arrays.asList(nums[first], nums[second], nums[third], nums[forth]));

                        while (third < forth && nums[third] == nums[third + 1]) {
                            third++;
                        }

                        third++;

                        while (third < forth && nums[forth] == nums[forth - 1]) {
                            forth--;
                        }

                        forth--;
                    }
                    else if (sum > target) {
                        forth--;
                    }
                    else {
                        third++;
                    }
                }
            }
        }

        return results;
    }

    public List<List<Integer>> fourSum(int[] nums, int target) {
        List<List<Integer>> results = new ArrayList<List<Integer>>();
        Arrays.sort(nums);

        for (int first = 0; first < nums.length; first++) {

            if (first > 0 && (nums[first] == nums[first - 1])) {
                continue;
            }

            for (int second = first + 1; second < nums.length; second++) {

                if (second > first + 1 && nums[second] == nums[second - 1]) {
                    continue;
                }

                int third = second + 1;
                int forth = nums.length - 1;

                while (third < forth) {
                    int sum = nums[first] + nums[second] + nums[third] + nums[forth];
                    if (sum == target) {
                        results.add(Arrays.asList(nums[first], nums[second], nums[third], nums[forth]));

                        while (third < forth && nums[third] == nums[third + 1]) {
                            third++;
                        }

                        third++;

                        while (third < forth && nums[forth] == nums[forth - 1]) {
                            forth--;
                        }

                        forth--;
                    }
                    else if (sum > target) {
                        forth--;
                    }
                    else {
                        third++;
                    }
                }
            }
        }

        return results;
    }

Replace Generic With Diamond ArrayList<List<Integer>> with ArrayList<> in method public fourSum(nums int[], target int) : List<List<Integer>> from class org.example.leetcode.pageone.FourSum18


    public List<List<Integer>> threeSum(int[] nums) {
        int n = nums.length;
        Arrays.sort(nums);
        List<List<Integer>> ans = new ArrayList<>();
        for (int first = 0; first < n; ++first) {
            if (first > 0 && nums[first] == nums[first - 1]) {
                continue;
            }

            int second = first + 1;
            int third = n - 1;

            while (second < third) {

                int sum = nums[first] + nums[second] + nums[third];

                if (sum == 0) {
                    ans.add(Arrays.asList(nums[first], nums[second], nums[third]));

                    while (second < third && nums[second] == nums[second + 1]) {
                        second++;
                    }

                    second++;

                    while (second < third && nums[third] == nums[third - 1]) {
                        third--;
                    }

                    third--;
                }
                else if (sum > 0) {
                    third--;
                }
                else {
                    second++;
                }
            }
        }
        return ans;
    }

    public List<List<Integer>> threeSum(int[] nums) {
        int n = nums.length;
        Arrays.sort(nums);
        List<List<Integer>> ans = new ArrayList<List<Integer>>();
        for (int first = 0; first < n; ++first) {
            if (first > 0 && nums[first] == nums[first - 1]) {
                continue;
            }

            int second = first + 1;
            int third = n - 1;

            while (second < third) {

                int sum = nums[first] + nums[second] + nums[third];

                if (sum == 0) {
                    ans.add(Arrays.asList(nums[first], nums[second], nums[third]));

                    while (second < third && nums[second] == nums[second + 1]) {
                        second++;
                    }

                    second++;

                    while (second < third && nums[third] == nums[third - 1]) {
                        third--;
                    }

                    third--;
                }
                else if (sum > 0) {
                    third--;
                }
                else {
                    second++;
                }
            }
        }
        return ans;
    }

Replace Generic With Diamond ArrayList<List<Integer>> with ArrayList<> in method public threeSum(nums int[]) : List<List<Integer>> from class org.example.leetcode.pageone.ThreeSum15


    private void init() {
        try {
            FileInputStream fileIn = new FileInputStream(dataFile);
            ObjectInputStream ois = new ObjectInputStream(fileIn);
            pictureList = (ArrayList<Picture>) ois.readObject();
            ois.close();
            fileIn.close();
        } catch (IOException | ClassNotFoundException i){
            System.out.println("No pictures exist or class is not found");
            pictureList = new ArrayList<>();
        }
    }

    private void init() {
        try {
            FileInputStream fileIn = new FileInputStream(dataFile);
            ObjectInputStream ois = new ObjectInputStream(fileIn);
            pictureList = (ArrayList<Picture>) ois.readObject();
            ois.close();
            fileIn.close();
        } catch (IOException | ClassNotFoundException i){
            System.out.println("No pictures exist or class is not found");
            pictureList = new ArrayList<Picture>();
        }
    }

Replace Generic With Diamond ArrayList<Picture> with ArrayList<> in method private init() : void from class com.photos.models.PictureList