Java AtomicInteger getAndResetInvocationCount()

Here you can find the source of getAndResetInvocationCount()

Description

get And Reset Invocation Count

License

LGPL

Declaration

public static int getAndResetInvocationCount() 

Method Source Code

//package com.java2s;
/*//from   w w  w.j  a v a 2s  . c  om
 * Hibernate OGM, Domain model persistence for NoSQL datastores
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import java.util.concurrent.atomic.AtomicInteger;

public class Main {
    private static final String DEFAULT_COUNTER = "__DEFAULT_COUNTER_";
    private static final Map<String, AtomicInteger> counters = new ConcurrentHashMap<>();

    public static int getAndResetInvocationCount() {
        return getAndResetInvocationCount(DEFAULT_COUNTER);
    }

    public static int getAndResetInvocationCount(String counter) {
        if (!counters.containsKey(counter)) {
            return 0;
        }
        return counters.get(counter).getAndSet(0);
    }
}

Related

  1. deleteIndexedFields(Set fieldsToDelete, List fields, Map fieldIndexLookupMap)
  2. encodeMap(Map map)
  3. generateUniqueId()
  4. getAllocationFailureCount()
  5. getAndResetInvocationCount()
  6. getCriticalExceptionCount()
  7. getExceptionCountMap()
  8. getFailedMiddlePartNumbers(PartListing partListing)
  9. getGetPendingWrTransaction()