All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebeaninternal.server.persist.BatchDepthOrder Maven / Gradle / Ivy

There is a newer version: 15.8.0
Show newest version
package io.ebeaninternal.server.persist;

import java.util.HashMap;
import java.util.Map;

/**
 * Helper to determine batch execution order for BatchedBeanHolders.
 */
final class BatchDepthOrder {

  private final Map map = new HashMap<>();

  /**
   * Return the batch order for the given depth.
   */
  int orderingFor(int depth) {
    final Counter slot = map.computeIfAbsent(depth, integer -> new Counter());
    return (depth * 100) + slot.increment();
  }

  void clear() {
    map.clear();
  }

  private static final class Counter {

    int count;

    int increment() {
      return count++;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy