org.hibernate.collection.internal.StandardSetSemantics 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 java.util.HashSet;
import java.util.Set;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.persister.collection.CollectionPersister;
/**
* @author Steve Ebersole
*/
public class StandardSetSemantics extends AbstractSetSemantics> {
/**
* Singleton access
*/
public static final StandardSetSemantics INSTANCE = new StandardSetSemantics();
private StandardSetSemantics() {
}
@Override
public CollectionClassification getCollectionClassification() {
return CollectionClassification.SET;
}
@Override
public Set instantiateRaw(
int anticipatedSize,
CollectionPersister collectionDescriptor) {
return anticipatedSize < 1 ? new HashSet<>() : new HashSet<>( anticipatedSize );
}
@Override
public PersistentSet instantiateWrapper(
Object key,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentSet( session );
}
@Override
public PersistentSet wrap(
Object rawCollection,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentSet( session, (Set) rawCollection );
}
}