package com.tsi.app.common.utils;

import java.util.concurrent.atomic.AtomicLong;

public class Counter {

    private AtomicLong counter;

    public Counter() {
        this.counter = new AtomicLong(0);
    }

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

    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 Converter.getSize(this.counter.doubleValue());
    }
}
