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) {
|
public PersistentBag(SessionImplementor session) {
|
||||||
this( (SharedSessionContractImplementor) session );
|
this( (SharedSessionContractImplementor) session );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a PersistentBag
|
* Constructs a PersistentBag
|
||||||
*
|
*
|
||||||
|
@ -127,7 +128,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
// note that if we load this collection from a cartesian product
|
// note that if we load this collection from a cartesian product
|
||||||
// the multiplicity would be broken ... so use an idbag instead
|
// 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 ) {
|
if ( element != null ) {
|
||||||
bag.add( element );
|
bag.add( element );
|
||||||
}
|
}
|
||||||
|
@ -140,7 +141,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings("unchecked")
|
||||||
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
|
public boolean equalsSnapshot(CollectionPersister persister) throws HibernateException {
|
||||||
final Type elementType = persister.getElementType();
|
final Type elementType = persister.getElementType();
|
||||||
final List<Object> sn = (List<Object>) getSnapshot();
|
final List<Object> sn = (List<Object>) getSnapshot();
|
||||||
|
@ -180,7 +181,8 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
instance,
|
instance,
|
||||||
instancesBag,
|
instancesBag,
|
||||||
elementType,
|
elementType,
|
||||||
countOccurrences( instance, instancesSn, elementType ) ) ) {
|
countOccurrences( instance, instancesSn, elementType )
|
||||||
|
) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,8 +200,8 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
Map<Integer, List<Object>> map = new HashMap<>();
|
Map<Integer, List<Object>> map = new HashMap<>();
|
||||||
for (Object o : searchedBag) {
|
for ( Object o : searchedBag ) {
|
||||||
map.computeIfAbsent( nullableHashCode(o , elementType), k -> new ArrayList<>() ).add( o );
|
map.computeIfAbsent( nullableHashCode( o, elementType ), k -> new ArrayList<>() ).add( o );
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +269,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
final int length = bag.size();
|
final int length = bag.size();
|
||||||
final Serializable[] result = new Serializable[length];
|
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 );
|
result[i] = persister.getElementType().disassemble( bag.get( i ), getSession(), null );
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -309,12 +311,12 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
final ArrayList deletes = new ArrayList();
|
final ArrayList deletes = new ArrayList();
|
||||||
final List sn = (List) getSnapshot();
|
final List sn = (List) getSnapshot();
|
||||||
final Iterator olditer = sn.iterator();
|
final Iterator olditer = sn.iterator();
|
||||||
int i=0;
|
int i = 0;
|
||||||
while ( olditer.hasNext() ) {
|
while ( olditer.hasNext() ) {
|
||||||
final Object old = olditer.next();
|
final Object old = olditer.next();
|
||||||
final Iterator newiter = bag.iterator();
|
final Iterator newiter = bag.iterator();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
if ( bag.size()>i && elementType.isSame( old, bag.get( i++ ) ) ) {
|
if ( bag.size() > i && elementType.isSame( old, bag.get( i++ ) ) ) {
|
||||||
//a shortcut if its location didn't change!
|
//a shortcut if its location didn't change!
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
@ -371,7 +373,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return readSize() ? getCachedSize()==0 : bag.isEmpty();
|
return readSize() ? getCachedSize() == 0 : bag.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -434,7 +436,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public boolean addAll(Collection values) {
|
public boolean addAll(Collection values) {
|
||||||
if ( values.size()==0 ) {
|
if ( values.size() == 0 ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( !isOperationQueueEnabled() ) {
|
if ( !isOperationQueueEnabled() ) {
|
||||||
|
@ -445,14 +447,14 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
for ( Object value : values ) {
|
for ( Object value : values ) {
|
||||||
queueOperation( new SimpleAdd( value ) );
|
queueOperation( new SimpleAdd( value ) );
|
||||||
}
|
}
|
||||||
return values.size()>0;
|
return values.size() > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public boolean removeAll(Collection c) {
|
public boolean removeAll(Collection c) {
|
||||||
if ( c.size()>0 ) {
|
if ( c.size() > 0 ) {
|
||||||
initialize( true );
|
initialize( true );
|
||||||
if ( bag.removeAll( c ) ) {
|
if ( bag.removeAll( c ) ) {
|
||||||
elementRemoved = true;
|
elementRemoved = true;
|
||||||
|
@ -489,7 +491,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
initialize( true );
|
initialize( true );
|
||||||
if ( ! bag.isEmpty() ) {
|
if ( !bag.isEmpty() ) {
|
||||||
bag.clear();
|
bag.clear();
|
||||||
dirty();
|
dirty();
|
||||||
}
|
}
|
||||||
|
@ -498,7 +500,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getIndex(Object entry, int i, CollectionPersister persister) {
|
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
|
@Override
|
||||||
|
@ -611,7 +613,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean entryExists(Object entry, int i) {
|
public boolean entryExists(Object entry, int i) {
|
||||||
return entry!=null;
|
return entry != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -625,8 +627,9 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
* JVM instance comparison to do the equals.
|
* JVM instance comparison to do the equals.
|
||||||
* The semantic is broken not to have to initialize a
|
* The semantic is broken not to have to initialize a
|
||||||
* collection for a simple equals() operation.
|
* collection for a simple equals() operation.
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
|
||||||
*
|
*
|
||||||
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
* <p>
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -652,7 +655,7 @@ public class PersistentBag extends AbstractPersistentCollection implements List
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getOrphan() {
|
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