// Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java
// public class DSyncClientException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public DSyncClientException(final String message) {
//         super(message);
//     }
// 
//     public DSyncClientException(final Throwable cause) {
//         super(cause);
//     }
// 
//     public DSyncClientException(final String message, final Throwable cause) {
//         super(message, cause);
//     }
// 
//     public DSyncClientException(final String message, final Throwable cause,
//                                 final boolean enableSuppression, final boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// 
// }


import com.yet.dsync.exception.DSyncClientException;
import lombok.RequiredArgsConstructor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardWatchEventKinds;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.function.Consumer;

/*
 * Copyright (c) 2017 Yuriy Tkach
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

package com.yet.dsync.util;



//import com.sun.nio.file.SensitivityWatchEventModifier;

@RequiredArgsConstructor
public class WatcherRegisterConsumer implements Consumer<Path> {

    private static final Logger LOG = LogManager.getLogger(WatcherRegisterConsumer.class);

    private final WatchService watchService;
    private final Consumer<WatchKey> watchKeyConsumer;

    @Override
    public void accept(final Path path) {
        if (!path.toFile().exists() || !path.toFile().isDirectory()) {

// Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java
// public class DSyncClientException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public DSyncClientException(final String message) {
//         super(message);
//     }
// 
//     public DSyncClientException(final Throwable cause) {
//         super(cause);
//     }
// 
//     public DSyncClientException(final String message, final Throwable cause) {
//         super(message, cause);
//     }
// 
//     public DSyncClientException(final String message, final Throwable cause,
//                                 final boolean enableSuppression, final boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// 
// }


// Path: src/main/java/com/yet/dsync/util/WatcherRegisterConsumer.java
import com.yet.dsync.exception.DSyncClientException;
import lombok.RequiredArgsConstructor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardWatchEventKinds;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.function.Consumer;

/*
 * Copyright (c) 2017 Yuriy Tkach
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

package com.yet.dsync.util;



//import com.sun.nio.file.SensitivityWatchEventModifier;

@RequiredArgsConstructor
public class WatcherRegisterConsumer implements Consumer<Path> {

    private static final Logger LOG = LogManager.getLogger(WatcherRegisterConsumer.class);

    private final WatchService watchService;
    private final Consumer<WatchKey> watchKeyConsumer;

    @Override
    public void accept(final Path path) {
        if (!path.toFile().exists() || !path.toFile().isDirectory()) {

            throw new DSyncClientException("folder " + path + " does not exist or is not a directory");
