Pass sorted collection comparator as ctor argument
This commit is contained in:
parent
5cf052775b
commit
c2569bde4c
|
@ -41,20 +41,22 @@ public class PersistentSortedMap<K,E> extends PersistentMap<K,E> implements Sort
|
|||
* Constructs a PersistentSortedMap.
|
||||
*
|
||||
* @param session The session
|
||||
* @param comparator The sort comparator
|
||||
*/
|
||||
public PersistentSortedMap(SharedSessionContractImplementor session) {
|
||||
public PersistentSortedMap(SharedSessionContractImplementor session, Comparator<K> comparator) {
|
||||
super( session );
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a PersistentSortedMap.
|
||||
*
|
||||
* @param session The session
|
||||
* @deprecated {@link #PersistentSortedMap(SharedSessionContractImplementor)} should be used instead.
|
||||
* @deprecated {@link #PersistentSortedMap(SharedSessionContractImplementor, Comparator)} should be used instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public PersistentSortedMap(SessionImplementor session) {
|
||||
this( (SharedSessionContractImplementor) session );
|
||||
this( (SharedSessionContractImplementor) session, (Comparator<K>) null );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,20 +38,22 @@ public class PersistentSortedSet<E> extends PersistentSet<E> implements SortedSe
|
|||
* Constructs a PersistentSortedSet
|
||||
*
|
||||
* @param session The session
|
||||
* @param comparator The sort comparator
|
||||
*/
|
||||
public PersistentSortedSet(SharedSessionContractImplementor session) {
|
||||
public PersistentSortedSet(SharedSessionContractImplementor session, Comparator<E> comparator) {
|
||||
super( session );
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a PersistentSortedSet
|
||||
*
|
||||
* @param session The session
|
||||
* @deprecated {@link #PersistentSortedSet(SharedSessionContractImplementor)} should be used instead.
|
||||
* @deprecated {@link #PersistentSortedSet(SharedSessionContractImplementor, Comparator)} should be used instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public PersistentSortedSet(SessionImplementor session) {
|
||||
this( (SharedSessionContractImplementor) session );
|
||||
this( (SharedSessionContractImplementor) session, (Comparator<E>) null );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,9 +49,8 @@ public class StandardSortedMapSemantics<K,V> extends AbstractMapSemantics<Sorted
|
|||
Object key,
|
||||
CollectionPersister collectionDescriptor,
|
||||
SharedSessionContractImplementor session) {
|
||||
final PersistentSortedMap<K,V> result = new PersistentSortedMap<>( session );
|
||||
result.setComparator( (Comparator<K>) collectionDescriptor.getSortingComparator() );
|
||||
return result;
|
||||
//noinspection unchecked
|
||||
return new PersistentSortedMap<>( session, (Comparator<K>) collectionDescriptor.getSortingComparator() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -50,9 +50,8 @@ public class StandardSortedSetSemantics<E> extends AbstractSetSemantics<SortedSe
|
|||
Object key,
|
||||
CollectionPersister collectionDescriptor,
|
||||
SharedSessionContractImplementor session) {
|
||||
final PersistentSortedSet<E> result = new PersistentSortedSet<>( session );
|
||||
result.setComparator( (Comparator<E>) collectionDescriptor.getSortingComparator() );
|
||||
return result;
|
||||
//noinspection unchecked
|
||||
return new PersistentSortedSet<>( session, (Comparator<E>) collectionDescriptor.getSortingComparator() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,9 +27,7 @@ public class SortedMapType extends MapType {
|
|||
|
||||
@Override
|
||||
public PersistentCollection instantiate(SharedSessionContractImplementor session, CollectionPersister persister, Object key) {
|
||||
PersistentSortedMap map = new PersistentSortedMap(session);
|
||||
map.setComparator(comparator);
|
||||
return map;
|
||||
return new PersistentSortedMap( session, comparator );
|
||||
}
|
||||
|
||||
public Class getReturnedClass() {
|
||||
|
|
|
@ -26,9 +26,7 @@ public class SortedSetType extends SetType {
|
|||
|
||||
@Override
|
||||
public PersistentCollection instantiate(SharedSessionContractImplementor session, CollectionPersister persister, Object key) {
|
||||
PersistentSortedSet set = new PersistentSortedSet(session);
|
||||
set.setComparator(comparator);
|
||||
return set;
|
||||
return new PersistentSortedSet( session, comparator );
|
||||
}
|
||||
|
||||
public Class getReturnedClass() {
|
||||
|
|
Loading…
Reference in New Issue