properly genericize CollectionSemantics hierarchy

This commit is contained in:
Gavin King 2021-02-22 17:55:50 +01:00 committed by Christian Beikov
parent c44570757d
commit 222837df95
21 changed files with 140 additions and 150 deletions

View File

@ -28,28 +28,26 @@ import org.hibernate.sql.results.graph.FetchParent;
/**
* @author Steve Ebersole
*/
public abstract class AbstractBagSemantics<B extends Collection<?>> implements BagSemantics<B> {
public abstract class AbstractBagSemantics<E> implements BagSemantics<Collection<E>,E> {
@Override
public Class<B> getCollectionJavaType() {
//noinspection unchecked
return (Class) Collection.class;
public Class<Collection> getCollectionJavaType() {
return Collection.class;
}
@Override
@SuppressWarnings("unchecked")
public B instantiateRaw(
public Collection<E> instantiateRaw(
int anticipatedSize,
CollectionPersister collectionDescriptor) {
if ( anticipatedSize < 1 ) {
return (B) new ArrayList();
return new ArrayList<>();
}
else {
return (B) CollectionHelper.arrayList( anticipatedSize );
return CollectionHelper.arrayList( anticipatedSize );
}
}
@Override
public Iterator getElementIterator(B rawCollection) {
public Iterator<E> getElementIterator(Collection<E> rawCollection) {
if ( rawCollection == null ) {
return null;
}
@ -57,8 +55,7 @@ public abstract class AbstractBagSemantics<B extends Collection<?>> implements B
}
@Override
@SuppressWarnings("unchecked")
public void visitElements(B rawCollection, Consumer action) {
public void visitElements(Collection<E> rawCollection, Consumer<? super E> action) {
if ( rawCollection != null ) {
rawCollection.forEach( action );
}

View File

@ -27,15 +27,14 @@ import org.hibernate.sql.results.graph.FetchParent;
/**
* @author Steve Ebersole
*/
public abstract class AbstractMapSemantics<M extends Map<?,?>> implements MapSemantics<M> {
public abstract class AbstractMapSemantics<MKV extends Map<K,V>, K, V> implements MapSemantics<MKV,K,V> {
@Override
public Class<M> getCollectionJavaType() {
//noinspection unchecked
return (Class) Map.class;
public Class<? extends Map> getCollectionJavaType() {
return Map.class;
}
@Override
public Iterator getKeyIterator(M rawMap) {
public Iterator<K> getKeyIterator(MKV rawMap) {
if ( rawMap == null ) {
return null;
}
@ -44,16 +43,14 @@ public abstract class AbstractMapSemantics<M extends Map<?,?>> implements MapSem
}
@Override
@SuppressWarnings("unchecked")
public void visitKeys(M rawMap, Consumer action) {
public void visitKeys(MKV rawMap, Consumer<? super K> action) {
if ( rawMap != null ) {
rawMap.keySet().forEach( action );
}
}
@Override
@SuppressWarnings("unchecked")
public void visitEntries(M rawMap, BiConsumer action) {
public void visitEntries(MKV rawMap, BiConsumer<? super K, ? super V> action) {
if ( rawMap != null ) {
rawMap.forEach( action );
}
@ -61,7 +58,7 @@ public abstract class AbstractMapSemantics<M extends Map<?,?>> implements MapSem
@Override
public Iterator getElementIterator(Map rawMap) {
public Iterator<V> getElementIterator(MKV rawMap) {
if ( rawMap == null ) {
return Collections.emptyIterator();
}
@ -70,8 +67,7 @@ public abstract class AbstractMapSemantics<M extends Map<?,?>> implements MapSem
}
@Override
@SuppressWarnings("unchecked")
public void visitElements(M rawMap, Consumer action) {
public void visitElements(MKV rawMap, Consumer<? super V> action) {
if ( rawMap != null ) {
rawMap.values().forEach( action );
}

View File

@ -25,15 +25,14 @@ import org.hibernate.sql.results.graph.FetchParent;
/**
* @author Steve Ebersole
*/
public abstract class AbstractSetSemantics<S extends Set<?>> implements CollectionSemantics<S> {
public abstract class AbstractSetSemantics<SE extends Set<E>,E> implements CollectionSemantics<SE,E> {
@Override
public Class<S> getCollectionJavaType() {
//noinspection unchecked
return (Class) Set.class;
public Class<? extends Set> getCollectionJavaType() {
return Set.class;
}
@Override
public Iterator getElementIterator(Set rawCollection) {
public Iterator<E> getElementIterator(SE rawCollection) {
if ( rawCollection == null ) {
return null;
}
@ -41,8 +40,7 @@ public abstract class AbstractSetSemantics<S extends Set<?>> implements Collecti
}
@Override
@SuppressWarnings("unchecked")
public void visitElements(S rawCollection, Consumer action) {
public void visitElements(SE rawCollection, Consumer<? super E> action) {
if ( rawCollection != null ) {
rawCollection.forEach( action );
}

View File

@ -31,7 +31,7 @@ import org.jboss.logging.Logger;
*
* @author Gavin King
*/
public class PersistentArrayHolder extends AbstractPersistentCollection {
public class PersistentArrayHolder<E> extends AbstractPersistentCollection<E> {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
PersistentArrayHolder.class.getName()

View File

@ -126,7 +126,7 @@ public class PersistentBag<E> extends AbstractPersistentCollection<E> implements
assert bag == null;
final CollectionPersister collectionDescriptor = attributeMapping.getCollectionDescriptor();
final CollectionSemantics<?> collectionSemantics = collectionDescriptor.getCollectionSemantics();
final CollectionSemantics<?,?> collectionSemantics = collectionDescriptor.getCollectionSemantics();
final int elementCount = loadingState == null ? 0 : loadingState.size();

View File

@ -31,11 +31,11 @@ import org.hibernate.sql.results.graph.FetchParent;
*
* @author Steve Ebersole
*/
public class StandardArraySemantics implements CollectionSemantics<Object[]> {
public class StandardArraySemantics<E> implements CollectionSemantics<E[], E> {
/**
* Singleton access
*/
public static final StandardArraySemantics INSTANCE = new StandardArraySemantics();
public static final StandardArraySemantics<?> INSTANCE = new StandardArraySemantics<>();
private StandardArraySemantics() {
}
@ -51,7 +51,7 @@ public class StandardArraySemantics implements CollectionSemantics<Object[]> {
}
@Override
public Object[] instantiateRaw(
public E[] instantiateRaw(
int anticipatedSize,
CollectionPersister collectionDescriptor) {
// return (Object[]) Array.newInstance(
@ -63,34 +63,33 @@ public class StandardArraySemantics implements CollectionSemantics<Object[]> {
@Override
public PersistentCollection instantiateWrapper(
public PersistentCollection<E> instantiateWrapper(
Object key,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentArrayHolder( session, collectionDescriptor );
return new PersistentArrayHolder<>( session, collectionDescriptor );
}
@Override
public PersistentCollection wrap(
Object rawCollection,
public PersistentCollection<E> wrap(
E[] rawCollection,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentArrayHolder( session, rawCollection );
return new PersistentArrayHolder<>( session, rawCollection );
}
@Override
public Iterator getElementIterator(Object[] rawCollection) {
public Iterator<E> getElementIterator(E[] rawCollection) {
return Arrays.stream( rawCollection ).iterator();
}
@Override
@SuppressWarnings("unchecked")
public void visitElements(Object[] array, Consumer action) {
public void visitElements(E[] array, Consumer<? super E> action) {
if ( array == null ) {
return;
}
for ( Object element : array ) {
for ( E element : array ) {
action.accept( element );
}
}

View File

@ -18,11 +18,11 @@ import org.hibernate.persister.collection.CollectionPersister;
*
* @author Steve Ebersole
*/
public class StandardBagSemantics extends AbstractBagSemantics<Collection<?>> {
public class StandardBagSemantics<E> extends AbstractBagSemantics<E> {
/**
* Singleton access
*/
public static final StandardBagSemantics INSTANCE = new StandardBagSemantics();
public static final StandardBagSemantics<?> INSTANCE = new StandardBagSemantics<>();
private StandardBagSemantics() {
}
@ -33,19 +33,19 @@ public class StandardBagSemantics extends AbstractBagSemantics<Collection<?>> {
}
@Override
public PersistentCollection instantiateWrapper(
public PersistentCollection<E> instantiateWrapper(
Object key,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentBag( session );
return new PersistentBag<>( session );
}
@Override
public PersistentCollection wrap(
Object rawCollection,
public PersistentCollection<E> wrap(
Collection<E> rawCollection,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentBag( session, (Collection) rawCollection );
return new PersistentBag<>( session, rawCollection );
}
}

View File

@ -7,7 +7,6 @@
package org.hibernate.collection.internal;
import org.hibernate.MappingException;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.collection.spi.CollectionSemantics;
import org.hibernate.collection.spi.CollectionSemanticsResolver;
import org.hibernate.mapping.Array;

View File

@ -18,11 +18,11 @@ import org.hibernate.persister.collection.CollectionPersister;
*
* @author Steve Ebersole
*/
public class StandardIdentifierBagSemantics<E> extends AbstractBagSemantics<Collection<?>> {
public class StandardIdentifierBagSemantics<E> extends AbstractBagSemantics<E> {
/**
* Singleton access
*/
public static final StandardIdentifierBagSemantics INSTANCE = new StandardIdentifierBagSemantics();
public static final StandardIdentifierBagSemantics<?> INSTANCE = new StandardIdentifierBagSemantics<>();
private StandardIdentifierBagSemantics() {
}
@ -33,18 +33,18 @@ public class StandardIdentifierBagSemantics<E> extends AbstractBagSemantics<Coll
}
@Override
public PersistentCollection instantiateWrapper(
public PersistentCollection<E> instantiateWrapper(
Object key,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentIdentifierBag( session );
return new PersistentIdentifierBag<>( session );
}
@Override
public PersistentCollection wrap(
Object rawCollection,
public PersistentCollection<E> wrap(
Collection<E> rawCollection,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentIdentifierBag( session, (Collection) rawCollection );
return new PersistentIdentifierBag<>( session, rawCollection );
}
}

View File

@ -32,11 +32,11 @@ import org.hibernate.sql.results.graph.FetchParent;
*
* @author Steve Ebersole
*/
public class StandardListSemantics implements CollectionSemantics<List> {
public class StandardListSemantics<E> implements CollectionSemantics<List<E>, E> {
/**
* Singleton access
*/
public static final StandardListSemantics INSTANCE = new StandardListSemantics();
public static final StandardListSemantics<?> INSTANCE = new StandardListSemantics<>();
private StandardListSemantics() {
}
@ -52,20 +52,19 @@ public class StandardListSemantics implements CollectionSemantics<List> {
}
@Override
public List instantiateRaw(
public List<E> instantiateRaw(
int anticipatedSize,
CollectionPersister collectionDescriptor) {
return CollectionHelper.arrayList( anticipatedSize );
}
@Override
public Iterator getElementIterator(List rawCollection) {
public Iterator<E> getElementIterator(List<E> rawCollection) {
return rawCollection.iterator();
}
@Override
@SuppressWarnings("unchecked")
public void visitElements(List rawCollection, Consumer action) {
public void visitElements(List<E> rawCollection, Consumer<? super E> action) {
rawCollection.forEach( action );
}
@ -142,18 +141,18 @@ public class StandardListSemantics implements CollectionSemantics<List> {
}
@Override
public PersistentCollection instantiateWrapper(
public PersistentCollection<E> instantiateWrapper(
Object key,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentList( session );
return new PersistentList<>( session );
}
@Override
public PersistentCollection wrap(
Object rawCollection,
public PersistentCollection<E> wrap(
List<E> rawCollection,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentList( session, (List) rawCollection );
return new PersistentList<>( session, rawCollection );
}
}

View File

@ -19,11 +19,11 @@ import org.hibernate.persister.collection.CollectionPersister;
*
* @author Steve Ebersole
*/
public class StandardMapSemantics extends AbstractMapSemantics<Map<?,?>> {
public class StandardMapSemantics<K,V> extends AbstractMapSemantics<Map<K,V>,K,V> {
/**
* Singleton access
*/
public static final StandardMapSemantics INSTANCE = new StandardMapSemantics();
public static final StandardMapSemantics<?,?> INSTANCE = new StandardMapSemantics<>();
private StandardMapSemantics() {
}
@ -34,25 +34,25 @@ public class StandardMapSemantics extends AbstractMapSemantics<Map<?,?>> {
}
@Override
public Map<?, ?> instantiateRaw(
public Map<K,V> instantiateRaw(
int anticipatedSize,
CollectionPersister collectionDescriptor) {
return CollectionHelper.mapOfSize( anticipatedSize );
}
@Override
public PersistentCollection instantiateWrapper(
public PersistentCollection<V> instantiateWrapper(
Object key,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentMap( session );
return new PersistentMap<>( session );
}
@Override
public PersistentCollection wrap(
Object rawCollection,
public PersistentCollection<V> wrap(
Map<K,V> rawCollection,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentMap( session, (Map) rawCollection );
return new PersistentMap<>( session, rawCollection );
}
}

View File

@ -19,11 +19,11 @@ import org.hibernate.persister.collection.CollectionPersister;
/**
* @author Steve Ebersole
*/
public class StandardOrderedMapSemantics extends AbstractMapSemantics<LinkedHashMap<?,?>> {
public class StandardOrderedMapSemantics<K,V> extends AbstractMapSemantics<LinkedHashMap<K,V>,K,V> {
/**
* Singleton access
*/
public static final StandardOrderedMapSemantics INSTANCE = new StandardOrderedMapSemantics();
public static final StandardOrderedMapSemantics<?,?> INSTANCE = new StandardOrderedMapSemantics<>();
private StandardOrderedMapSemantics() {
}
@ -34,30 +34,30 @@ public class StandardOrderedMapSemantics extends AbstractMapSemantics<LinkedHash
}
@Override
public LinkedHashMap<?, ?> instantiateRaw(
public LinkedHashMap<K,V> instantiateRaw(
int anticipatedSize,
CollectionPersister collectionDescriptor) {
return anticipatedSize < 1 ? CollectionHelper.linkedMap() : CollectionHelper.linkedMapOfSize( anticipatedSize );
}
@Override
public PersistentCollection instantiateWrapper(
public PersistentCollection<V> instantiateWrapper(
Object key,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentMap( session );
return new PersistentMap<>( session );
}
@Override
public PersistentCollection wrap(
Object rawCollection,
public PersistentCollection<V> wrap(
LinkedHashMap<K,V> rawCollection,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentMap( session, (Map) rawCollection );
return new PersistentMap<>( session, rawCollection );
}
@Override
public Iterator getElementIterator(LinkedHashMap rawCollection) {
public Iterator<V> getElementIterator(LinkedHashMap<K,V> rawCollection) {
return rawCollection.values().iterator();
}
}

View File

@ -6,24 +6,23 @@
*/
package org.hibernate.collection.internal;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
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<LinkedHashSet<?>> {
public class StandardOrderedSetSemantics<E> extends AbstractSetSemantics<LinkedHashSet<E>,E> {
/**
* Singleton access
*/
public static final StandardOrderedSetSemantics INSTANCE = new StandardOrderedSetSemantics();
public static final StandardOrderedSetSemantics<?> INSTANCE = new StandardOrderedSetSemantics<>();
private StandardOrderedSetSemantics() {
}
@ -34,30 +33,30 @@ public class StandardOrderedSetSemantics extends AbstractSetSemantics<LinkedHash
}
@Override
public LinkedHashSet<?> instantiateRaw(
public LinkedHashSet<E> instantiateRaw(
int anticipatedSize,
CollectionPersister collectionDescriptor) {
return anticipatedSize < 1 ? CollectionHelper.linkedSet() : CollectionHelper.linkedSetOfSize( anticipatedSize );
}
@Override
public PersistentCollection instantiateWrapper(
public PersistentCollection<E> instantiateWrapper(
Object key,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentSet( session );
return new PersistentSet<>( session );
}
@Override
public PersistentCollection wrap(
Object rawCollection,
public PersistentCollection<E> wrap(
LinkedHashSet<E> rawCollection,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentSet( session, (Set) rawCollection );
return new PersistentSet<>( session, rawCollection );
}
@Override
public Iterator getElementIterator(LinkedHashSet rawCollection) {
public Iterator<E> getElementIterator(LinkedHashSet<E> rawCollection) {
return rawCollection.iterator();
}
}

View File

@ -17,11 +17,11 @@ import org.hibernate.persister.collection.CollectionPersister;
/**
* @author Steve Ebersole
*/
public class StandardSetSemantics extends AbstractSetSemantics<Set<?>> {
public class StandardSetSemantics<E> extends AbstractSetSemantics<Set<E>,E> {
/**
* Singleton access
*/
public static final StandardSetSemantics INSTANCE = new StandardSetSemantics();
public static final StandardSetSemantics<?> INSTANCE = new StandardSetSemantics<>();
private StandardSetSemantics() {
}
@ -32,26 +32,26 @@ public class StandardSetSemantics extends AbstractSetSemantics<Set<?>> {
}
@Override
public Set<?> instantiateRaw(
public Set<E> instantiateRaw(
int anticipatedSize,
CollectionPersister collectionDescriptor) {
return anticipatedSize < 1 ? new HashSet<>() : CollectionHelper.setOfSize( anticipatedSize );
}
@Override
public PersistentSet instantiateWrapper(
public PersistentSet<E> instantiateWrapper(
Object key,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentSet( session );
return new PersistentSet<>( session );
}
@Override
public PersistentSet wrap(
Object rawCollection,
public PersistentSet<E> wrap(
Set<E> rawCollection,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentSet( session, (Set) rawCollection );
return new PersistentSet<>( session, rawCollection );
}
}

View File

@ -6,6 +6,7 @@
*/
package org.hibernate.collection.internal;
import java.util.Comparator;
import java.util.SortedMap;
import java.util.TreeMap;
@ -17,11 +18,11 @@ import org.hibernate.persister.collection.CollectionPersister;
/**
* @author Steve Ebersole
*/
public class StandardSortedMapSemantics extends AbstractMapSemantics<SortedMap<?,?>> {
public class StandardSortedMapSemantics<K,V> extends AbstractMapSemantics<SortedMap<K,V>,K,V> {
/**
* Singleton access
*/
public static final StandardSortedMapSemantics INSTANCE = new StandardSortedMapSemantics();
public static final StandardSortedMapSemantics<?,?> INSTANCE = new StandardSortedMapSemantics<>();
private StandardSortedMapSemantics() {
}
@ -32,31 +33,30 @@ public class StandardSortedMapSemantics extends AbstractMapSemantics<SortedMap<?
}
@Override
public Class<SortedMap<?, ?>> getCollectionJavaType() {
//noinspection unchecked
return (Class) SortedMap.class;
public Class<SortedMap> getCollectionJavaType() {
return SortedMap.class;
}
@Override
public TreeMap<?, ?> instantiateRaw(
public TreeMap<K,V> instantiateRaw(
int anticipatedSize,
CollectionPersister collectionDescriptor) {
return new TreeMap( collectionDescriptor.getSortingComparator() );
return new TreeMap<K,V>( (Comparator) collectionDescriptor.getSortingComparator() );
}
@Override
public PersistentCollection instantiateWrapper(
public PersistentCollection<V> instantiateWrapper(
Object key,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentSortedMap( session );
return new PersistentSortedMap<>( session );
}
@Override
public PersistentCollection wrap(
Object rawCollection,
public PersistentCollection<V> wrap(
SortedMap<K,V> rawCollection,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentSortedMap( session, (SortedMap) rawCollection );
return new PersistentSortedMap<>( session, rawCollection );
}
}

View File

@ -6,6 +6,7 @@
*/
package org.hibernate.collection.internal;
import java.util.Comparator;
import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;
@ -18,11 +19,11 @@ import org.hibernate.persister.collection.CollectionPersister;
/**
* @author Steve Ebersole
*/
public class StandardSortedSetSemantics extends AbstractSetSemantics<SortedSet<?>> {
public class StandardSortedSetSemantics<E> extends AbstractSetSemantics<SortedSet<E>,E> {
/**
* Singleton access
*/
public static final StandardSortedSetSemantics INSTANCE = new StandardSortedSetSemantics();
public static final StandardSortedSetSemantics<?> INSTANCE = new StandardSortedSetSemantics<>();
private StandardSortedSetSemantics() {
}
@ -33,36 +34,35 @@ public class StandardSortedSetSemantics extends AbstractSetSemantics<SortedSet<?
}
@Override
public Class<SortedSet<?>> getCollectionJavaType() {
//noinspection unchecked
return (Class) SortedSet.class;
public Class<SortedSet> getCollectionJavaType() {
return SortedSet.class;
}
@Override
public SortedSet instantiateRaw(
public SortedSet<E> instantiateRaw(
int anticipatedSize,
CollectionPersister collectionDescriptor) {
return new TreeSet( collectionDescriptor.getSortingComparator() );
return new TreeSet<E>( (Comparator) collectionDescriptor.getSortingComparator() );
}
@Override
public PersistentCollection instantiateWrapper(
public PersistentCollection<E> instantiateWrapper(
Object key,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentSortedSet( session );
return new PersistentSortedSet<>( session );
}
@Override
public PersistentCollection wrap(
Object rawCollection,
public PersistentCollection<E> wrap(
SortedSet<E> rawCollection,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session) {
return new PersistentSortedSet( session, (SortedSet) rawCollection );
return new PersistentSortedSet<>( session, rawCollection );
}
@Override
public Iterator getElementIterator(SortedSet<?> rawCollection) {
public Iterator<E> getElementIterator(SortedSet<E> rawCollection) {
return rawCollection.iterator();
}
}

View File

@ -6,9 +6,11 @@
*/
package org.hibernate.collection.spi;
import java.util.Collection;
/**
* @author Andrea Boriero
*/
public interface BagSemantics<B> extends CollectionSemantics<B> {
public interface BagSemantics<BE extends Collection<E>, E> extends CollectionSemantics<BE,E> {
}

View File

@ -30,31 +30,31 @@ import org.hibernate.sql.results.graph.FetchParent;
* @author Gavin King
*/
@Incubating
public interface CollectionSemantics<C> {
public interface CollectionSemantics<CE, E> {
/**
* Get the classification of collections described by this semantic
*/
CollectionClassification getCollectionClassification();
Class<C> getCollectionJavaType();
Class<?> getCollectionJavaType();
C instantiateRaw(
CE instantiateRaw(
int anticipatedSize,
CollectionPersister collectionDescriptor);
PersistentCollection instantiateWrapper(
PersistentCollection<E> instantiateWrapper(
Object key,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session);
PersistentCollection wrap(
Object rawCollection,
PersistentCollection<E> wrap(
CE rawCollection,
CollectionPersister collectionDescriptor,
SharedSessionContractImplementor session);
Iterator getElementIterator(C rawCollection);
Iterator<E> getElementIterator(CE rawCollection);
void visitElements(C rawCollection, Consumer action);
void visitElements(CE rawCollection, Consumer<? super E> action);
/**
* todo (6.0) : clean this contract up!

View File

@ -7,6 +7,7 @@
package org.hibernate.collection.spi;
import java.util.Iterator;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
@ -15,10 +16,10 @@ import java.util.function.Consumer;
*
* @author Steve Ebersole
*/
public interface MapSemantics<M> extends CollectionSemantics<M> {
Iterator getKeyIterator(M rawMap);
public interface MapSemantics<MKV extends Map<K,V>,K,V> extends CollectionSemantics<MKV,V> {
Iterator<K> getKeyIterator(MKV rawMap);
void visitKeys(M rawMap, Consumer action);
void visitKeys(MKV rawMap, Consumer<? super K> action);
void visitEntries(M rawMap, BiConsumer action);
void visitEntries(MKV rawMap, BiConsumer<? super K,? super V> action);
}

View File

@ -15,5 +15,5 @@ import org.hibernate.collection.spi.CollectionSemantics;
* @author Steve Ebersole
*/
public interface CollectionMappingType<C> extends MappingType {
CollectionSemantics<C> getCollectionSemantics();
CollectionSemantics<C,?> getCollectionSemantics();
}

View File

@ -24,15 +24,15 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators;
* @author Steve Ebersole
*/
public class CollectionJavaTypeDescriptor<C> extends AbstractTypeDescriptor<C> {
private final CollectionSemantics<C> semantics;
private final CollectionSemantics<C,?> semantics;
@SuppressWarnings("unchecked")
public CollectionJavaTypeDescriptor(Class<? extends C> type, CollectionSemantics<C> semantics) {
public CollectionJavaTypeDescriptor(Class<? extends C> type, CollectionSemantics<C,?> semantics) {
super( (Class) type );
this.semantics = semantics;
}
public CollectionSemantics<C> getSemantics() {
public CollectionSemantics<C,?> getSemantics() {
return semantics;
}