// Path: ddth-id-core/src/main/java/com/github/ddth/id/utils/IdException.java
// public class IdException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public IdException() {
//     }
// 
//     public IdException(String message) {
//         super(message);
//     }
// 
//     public IdException(Throwable cause) {
//         super(cause);
//     }
// 
//     public IdException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     /**
//      * Thrown to indicate that the operation is not supported/implemented.
//      * 
//      * @author Thanh Nguyen <btnguyen2k@gmail.com>
//      * @since 0.5.0
//      */
//     public static class OperationNotSupportedException extends IdException {
//         private static final long serialVersionUID = 1L;
// 
//         public OperationNotSupportedException() {
//         }
// 
//         public OperationNotSupportedException(String message) {
//             super(message);
//         }
//     }
// 
//     /**
//      * Thrown to indicate that the operation has failed due to timeout.
//      * 
//      * @author Thanh Nguyen <btnguyen2k@gmail.com>
//      * @since 0.5.0
//      */
//     public static class OperationTimeoutException extends IdException {
// 
//         private static final long serialVersionUID = 1L;
// 
//         public OperationTimeoutException() {
//         }
// 
//         public OperationTimeoutException(String message) {
//             super(message);
//         }
// 
//         public OperationTimeoutException(Throwable cause) {
//             super(cause);
//         }
// 
//         public OperationTimeoutException(String message, Throwable cause) {
//             super(message, cause);
//         }
//     }
// 
// }


import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicLong;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.ddth.id.utils.IdException;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
     */
    @Override
    public long nextId(String namespace) {
        try {
            return counters.get(namespace).incrementAndGet();
        } catch (ExecutionException e) {
            LOGGER.warn(e.getMessage(), e);
            return -1;
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public long currentId(String namespace) {
        try {
            return counters.get(namespace).get();
        } catch (ExecutionException e) {
            LOGGER.warn(e.getMessage(), e);
            return -1;
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean setValue(String namespace, long value) {
        if (value < 0) {
// Path: ddth-id-core/src/main/java/com/github/ddth/id/utils/IdException.java
// public class IdException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public IdException() {
//     }
// 
//     public IdException(String message) {
//         super(message);
//     }
// 
//     public IdException(Throwable cause) {
//         super(cause);
//     }
// 
//     public IdException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     /**
//      * Thrown to indicate that the operation is not supported/implemented.
//      * 
//      * @author Thanh Nguyen <btnguyen2k@gmail.com>
//      * @since 0.5.0
//      */
//     public static class OperationNotSupportedException extends IdException {
//         private static final long serialVersionUID = 1L;
// 
//         public OperationNotSupportedException() {
//         }
// 
//         public OperationNotSupportedException(String message) {
//             super(message);
//         }
//     }
// 
//     /**
//      * Thrown to indicate that the operation has failed due to timeout.
//      * 
//      * @author Thanh Nguyen <btnguyen2k@gmail.com>
//      * @since 0.5.0
//      */
//     public static class OperationTimeoutException extends IdException {
// 
//         private static final long serialVersionUID = 1L;
// 
//         public OperationTimeoutException() {
//         }
// 
//         public OperationTimeoutException(String message) {
//             super(message);
//         }
// 
//         public OperationTimeoutException(Throwable cause) {
//             super(cause);
//         }
// 
//         public OperationTimeoutException(String message, Throwable cause) {
//             super(message, cause);
//         }
//     }
// 
// }


// Path: ddth-id-core/src/main/java/com/github/ddth/id/InmemIdGenerator.java
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicLong;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.ddth.id.utils.IdException;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;

     */
    @Override
    public long nextId(String namespace) {
        try {
            return counters.get(namespace).incrementAndGet();
        } catch (ExecutionException e) {
            LOGGER.warn(e.getMessage(), e);
            return -1;
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public long currentId(String namespace) {
        try {
            return counters.get(namespace).get();
        } catch (ExecutionException e) {
            LOGGER.warn(e.getMessage(), e);
            return -1;
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean setValue(String namespace, long value) {
        if (value < 0) {
            throw new IdException("Id value must be greater or equal to 0!");