org.hibernate.internal.util.collections.LockModeEnumMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
JPMS Module-Info's for a few of the Jakarta Libraries just until they add them in themselves
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.internal.util.collections;
import java.util.function.Function;
import org.hibernate.LockMode;
/**
* A concurrent safe EnumMap<LockMode>, suitable to
* lazily associate values to the enum keys.
* This implementation favours fast read operations
* and low memory consumption over other metrics.
*
* Specifically designed with specific use cases in mind:
* do not overly reuse without good reasons.
*
* @param the value type to be associated with each key
*/
public final class LockModeEnumMap extends LazyIndexedMap {
private static final int ENUM_DIMENSION = LockMode.values().length;
public LockModeEnumMap() {
super( ENUM_DIMENSION );
}
public V computeIfAbsent(LockMode key, Function valueGenerator) {
return super.computeIfAbsent( key.ordinal(), key, valueGenerator );
}
}