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

org.hibernate.collection.internal.StandardOrderedSetSemantics Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha2
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 http://www.gnu.org/licenses/lgpl-2.1.html
 */
package org.hibernate.collection.internal;

import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.persister.collection.CollectionPersister;

import java.util.Iterator;
import java.util.LinkedHashSet;

/**
 * @author Steve Ebersole
 */
public class StandardOrderedSetSemantics extends AbstractSetSemantics,E> {
	/**
	 * Singleton access
	 */
	public static final StandardOrderedSetSemantics INSTANCE = new StandardOrderedSetSemantics<>();

	private StandardOrderedSetSemantics() {
	}

	@Override
	public CollectionClassification getCollectionClassification() {
		return CollectionClassification.ORDERED_SET;
	}

	@Override
	public LinkedHashSet instantiateRaw(
			int anticipatedSize,
			CollectionPersister collectionDescriptor) {
		return anticipatedSize < 1 ? CollectionHelper.linkedSet() : CollectionHelper.linkedSetOfSize( anticipatedSize );
	}

	@Override
	public PersistentCollection instantiateWrapper(
			Object key,
			CollectionPersister collectionDescriptor,
			SharedSessionContractImplementor session) {
		return new PersistentSet<>( session );
	}

	@Override
	public PersistentCollection wrap(
			LinkedHashSet rawCollection,
			CollectionPersister collectionDescriptor,
			SharedSessionContractImplementor session) {
		return new PersistentSet<>( session, rawCollection );
	}

	@Override
	public Iterator getElementIterator(LinkedHashSet rawCollection) {
		return rawCollection.iterator();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy