package com.tsi.common.utils;

import java.util.concurrent.atomic.AtomicLong;

public class Counter {

    private final AtomicLong counter = new AtomicLong(0);

    public Counter() {
    }

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

    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();
    }

    @Override
    public String toString() {
        return String.valueOf(counter.get());
        // return Converter.getSize(counter.doubleValue());
    }
}
