io.ebeaninternal.server.persist.BatchDepthOrder Maven / Gradle / Ivy
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