org.hibernate.collection.internal.StandardOrderedSetSemantics 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
Hibernate's core ORM functionality
/*
* 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();
}
}