HHH-13651 Applying hibernate codestyle to PersistentBag
This commit is contained in:
parent
2808a75d5c
commit
a5c8a812f5
|
@ -67,6 +67,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
public PersistentBag(SessionImplementor session) {
|
||||
this( (SharedSessionContractImplementor) session );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a PersistentBag
|
||||
*
|
||||
|
@ -94,7 +95,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) {
|
||||
|
@ -127,7 +128,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 );
|
||||
}
|
||||
|
@ -140,7 +141,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();
|
||||
|
@ -180,7 +181,8 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
instance,
|
||||
instancesBag,
|
||||
elementType,
|
||||
countOccurrences( instance, instancesSn, elementType ) ) ) {
|
||||
countOccurrences( instance, instancesSn, elementType )
|
||||
) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -198,8 +200,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;
|
||||
}
|
||||
|
@ -267,7 +269,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;
|
||||
|
@ -309,13 +311,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 {
|
||||
|
@ -371,7 +373,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
|
||||
|
@ -434,7 +436,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() ) {
|
||||
|
@ -445,14 +447,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;
|
||||
|
@ -489,7 +491,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
}
|
||||
else {
|
||||
initialize( true );
|
||||
if ( ! bag.isEmpty() ) {
|
||||
if ( !bag.isEmpty() ) {
|
||||
bag.clear();
|
||||
dirty();
|
||||
}
|
||||
|
@ -498,7 +500,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
|
||||
|
@ -611,7 +613,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
|||
|
||||
@Override
|
||||
public boolean entryExists(Object entry, int i) {
|
||||
return entry!=null;
|
||||
return entry != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -625,8 +627,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
|
||||
|
@ -652,7 +655,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