package com.its.api.utils;

import java.util.concurrent.atomic.AtomicLong;

public class Counter {
    private AtomicLong counter = new AtomicLong(0L);

    public Counter() {
    }

    public long reset() {
        return this.counter.getAndSet(0L);
    }

    public long reset(long value) {
        return this.counter.getAndSet(0L);
    }

    public long increment() {
        return this.counter.incrementAndGet();
    }

    public long add(long value) {
        return this.counter.addAndGet(value);
    }

    public long decrement() {
        return this.counter.decrementAndGet();
    }

    public long get() {
        return this.counter.get();
    }

    public String toString() {
        return Converter.getSize(this.counter.doubleValue());
    }

}
