HHH-13651 Applying hibernate codestyle to PersistentBag
(cherry picked from commit a5c8a812f5
)
This commit is contained in:
parent
bdf0a89f82
commit
3e1663a66e
|
@ -67,6 +67,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
public PersistentBag(SessionImplementor session) {
|
||||
this( (SharedSessionContractImplementor) session );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a PersistentBag
|
||||
*
|
||||
|
@ -97,7 +98,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
* @param coll The base elements.
|
||||
*
|
||||
* @deprecated {@link #PersistentBag(SharedSessionContractImplementor, Collection)}
|
||||
* should be used instead.
|
||||
* should be used instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public PersistentBag(SessionImplementor session, Collection coll) {
|
||||
|
@ -130,7 +131,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
throws HibernateException, SQLException {
|
||||
// note that if we load this collection from a cartesian product
|
||||
// the multiplicity would be broken ... so use an idbag instead
|
||||
final Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() ) ;
|
||||
final Object element = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
|
||||
if ( element != null ) {
|
||||
bag.add( element );
|
||||
}
|
||||
|
@ -143,7 +144,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
|
||||
final Type elementType = persister.getElementType();
|
||||
final List<Object> sn = (List<Object>) getSnapshot();
|
||||
|
@ -183,7 +184,8 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
instance,
|
||||
instancesBag,
|
||||
elementType,
|
||||
countOccurrences( instance, instancesSn, elementType ) ) ) {
|
||||
countOccurrences( instance, instancesSn, elementType )
|
||||
) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -201,8 +203,8 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
return Collections.emptyMap();
|
||||
}
|
||||
Map<Integer, List<Object>> map = new HashMap<>();
|
||||
for (Object o : searchedBag) {
|
||||
map.computeIfAbsent( nullableHashCode(o , elementType), k -> new ArrayList<>() ).add( o );
|
||||
for ( Object o : searchedBag ) {
|
||||
map.computeIfAbsent( nullableHashCode( o, elementType ), k -> new ArrayList<>() ).add( o );
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
@ -270,7 +272,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
throws HibernateException {
|
||||
final int length = bag.size();
|
||||
final Serializable[] result = new Serializable[length];
|
||||
for ( int i=0; i<length; i++ ) {
|
||||
for ( int i = 0; i < length; i++ ) {
|
||||
result[i] = persister.getElementType().disassemble( bag.get( i ), getSession(), null );
|
||||
}
|
||||
return result;
|
||||
|
@ -312,13 +314,13 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
final ArrayList deletes = new ArrayList();
|
||||
final List sn = (List) getSnapshot();
|
||||
final Iterator olditer = sn.iterator();
|
||||
int i=0;
|
||||
int i = 0;
|
||||
while ( olditer.hasNext() ) {
|
||||
final Object old = olditer.next();
|
||||
final Iterator newiter = bag.iterator();
|
||||
boolean found = false;
|
||||
if ( bag.size()>i && elementType.isSame( old, bag.get( i++ ) ) ) {
|
||||
//a shortcut if its location didn't change!
|
||||
if ( bag.size() > i && elementType.isSame( old, bag.get( i++ ) ) ) {
|
||||
//a shortcut if its location didn't change!
|
||||
found = true;
|
||||
}
|
||||
else {
|
||||
|
@ -374,7 +376,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return readSize() ? getCachedSize()==0 : bag.isEmpty();
|
||||
return readSize() ? getCachedSize() == 0 : bag.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -437,7 +439,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean addAll(Collection values) {
|
||||
if ( values.size()==0 ) {
|
||||
if ( values.size() == 0 ) {
|
||||
return false;
|
||||
}
|
||||
if ( !isOperationQueueEnabled() ) {
|
||||
|
@ -448,14 +450,14 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
for ( Object value : values ) {
|
||||
queueOperation( new SimpleAdd( value ) );
|
||||
}
|
||||
return values.size()>0;
|
||||
return values.size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean removeAll(Collection c) {
|
||||
if ( c.size()>0 ) {
|
||||
if ( c.size() > 0 ) {
|
||||
initialize( true );
|
||||
if ( bag.removeAll( c ) ) {
|
||||
elementRemoved = true;
|
||||
|
@ -492,7 +494,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
}
|
||||
else {
|
||||
initialize( true );
|
||||
if ( ! bag.isEmpty() ) {
|
||||
if ( !bag.isEmpty() ) {
|
||||
bag.clear();
|
||||
dirty();
|
||||
}
|
||||
|
@ -501,7 +503,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
|
||||
@Override
|
||||
public Object getIndex(Object entry, int i, CollectionPersister persister) {
|
||||
throw new UnsupportedOperationException("Bags don't have indexes");
|
||||
throw new UnsupportedOperationException( "Bags don't have indexes" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -614,7 +616,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
|
||||
@Override
|
||||
public boolean entryExists(Object entry, int i) {
|
||||
return entry!=null;
|
||||
return entry != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -628,8 +630,9 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
* JVM instance comparison to do the equals.
|
||||
* The semantic is broken not to have to initialize a
|
||||
* collection for a simple equals() operation.
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
* <p>
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
|
@ -655,7 +658,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
|
||||
@Override
|
||||
public Object getOrphan() {
|
||||
throw new UnsupportedOperationException("queued clear cannot be used with orphan delete");
|
||||
throw new UnsupportedOperationException( "queued clear cannot be used with orphan delete" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue