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

org.hibernate.internal.util.collections.LockModeEnumMap Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
Show newest version
/*
 * 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 );
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy