Use equals() for object equality checks

This commit is contained in:
Tim Donohue
2020-07-27 17:05:56 -05:00
parent 645a1800bb
commit 78f837c052
8 changed files with 19 additions and 19 deletions

View File

@@ -153,7 +153,7 @@ public class BitstreamFormatServiceImpl implements BitstreamFormatService {
// If the exception was thrown, unknown will == null so goahead and // If the exception was thrown, unknown will == null so goahead and
// load s. If not, check that the unknown's registry's name is not // load s. If not, check that the unknown's registry's name is not
// being reset. // being reset.
if (unknown == null || unknown.getID() != bitstreamFormat.getID()) { if (unknown == null || !unknown.getID().equals(bitstreamFormat.getID())) {
bitstreamFormat.setShortDescriptionInternal(shortDescription); bitstreamFormat.setShortDescriptionInternal(shortDescription);
} }
} }
@@ -208,7 +208,7 @@ public class BitstreamFormatServiceImpl implements BitstreamFormatService {
// Find "unknown" type // Find "unknown" type
BitstreamFormat unknown = findUnknown(context); BitstreamFormat unknown = findUnknown(context);
if (unknown.getID() == bitstreamFormat.getID()) { if (unknown.getID().equals(bitstreamFormat.getID())) {
throw new IllegalArgumentException("The Unknown bitstream format may not be deleted."); throw new IllegalArgumentException("The Unknown bitstream format may not be deleted.");
} }
@@ -270,4 +270,4 @@ public class BitstreamFormatServiceImpl implements BitstreamFormatService {
} }
return null; return null;
} }
} }

View File

@@ -168,11 +168,11 @@ public class MetadataField implements ReloadableEntity<Integer> {
return false; return false;
} }
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj); Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
if (getClass() != objClass) { if (!getClass().equals(objClass)) {
return false; return false;
} }
final MetadataField other = (MetadataField) obj; final MetadataField other = (MetadataField) obj;
if (this.getID() != other.getID()) { if (!this.getID().equals(other.getID())) {
return false; return false;
} }
if (!getMetadataSchema().equals(other.getMetadataSchema())) { if (!getMetadataSchema().equals(other.getMetadataSchema())) {

View File

@@ -67,11 +67,11 @@ public class MetadataSchema implements ReloadableEntity<Integer> {
return false; return false;
} }
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj); Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
if (getClass() != objClass) { if (!getClass().equals(objClass)) {
return false; return false;
} }
final MetadataSchema other = (MetadataSchema) obj; final MetadataSchema other = (MetadataSchema) obj;
if (this.id != other.id) { if (!this.id.equals(other.id)) {
return false; return false;
} }
if ((this.namespace == null) ? (other.namespace != null) : !this.namespace.equals(other.namespace)) { if ((this.namespace == null) ? (other.namespace != null) : !this.namespace.equals(other.namespace)) {

View File

@@ -239,17 +239,17 @@ public class MetadataValue implements ReloadableEntity<Integer> {
return false; return false;
} }
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj); Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
if (getClass() != objClass) { if (!getClass().equals(objClass)) {
return false; return false;
} }
final MetadataValue other = (MetadataValue) obj; final MetadataValue other = (MetadataValue) obj;
if (this.id != other.id) { if (!this.id.equals(other.id)) {
return false; return false;
} }
if (this.getID() != other.getID()) { if (!this.getID().equals(other.getID())) {
return false; return false;
} }
if (this.getDSpaceObject().getID() != other.getDSpaceObject().getID()) { if (!this.getDSpaceObject().getID().equals(other.getDSpaceObject().getID())) {
return false; return false;
} }
return true; return true;

View File

@@ -156,11 +156,11 @@ public class WorkspaceItem
return true; return true;
} }
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(o); Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(o);
if (getClass() != objClass) { if (!getClass().equals(objClass)) {
return false; return false;
} }
final WorkspaceItem that = (WorkspaceItem) o; final WorkspaceItem that = (WorkspaceItem) o;
if (this.getID() != that.getID()) { if (!this.getID().equals(that.getID())) {
return false; return false;
} }

View File

@@ -135,12 +135,12 @@ public class Version implements ReloadableEntity<Integer> {
return true; return true;
} }
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(o); Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(o);
if (getClass() != objClass) { if (!getClass().equals(objClass)) {
return false; return false;
} }
final Version that = (Version) o; final Version that = (Version) o;
if (this.getID() != that.getID()) { if (!this.getID().equals(that.getID())) {
return false; return false;
} }

View File

@@ -93,12 +93,12 @@ public class VersionHistory implements ReloadableEntity<Integer> {
return true; return true;
} }
Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(o); Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(o);
if (getClass() != objClass) { if (!getClass().equals(objClass)) {
return false; return false;
} }
final VersionHistory that = (VersionHistory) o; final VersionHistory that = (VersionHistory) o;
if (this.getID() != that.getID()) { if (!this.getID().equals(that.getID())) {
return false; return false;
} }

View File

@@ -31,7 +31,7 @@ import org.springframework.stereotype.Component;
/** /**
* An authenticated user is allowed to interact with a pool task only if it is in his list. * An authenticated user is allowed to interact with a pool task only if it is in his list.
* *
* @author Andrea Bollini (andrea.bollini at 4science.it) * @author Andrea Bollini (andrea.bollini at 4science.it)
*/ */
@Component @Component
@@ -75,7 +75,7 @@ public class PoolTaskRestPermissionEvaluatorPlugin extends RestObjectPermissionE
XmlWorkflowItem workflowItem = poolTask.getWorkflowItem(); XmlWorkflowItem workflowItem = poolTask.getWorkflowItem();
PoolTask poolTask2 = poolTaskService.findByWorkflowIdAndEPerson(context, workflowItem, ePerson); PoolTask poolTask2 = poolTaskService.findByWorkflowIdAndEPerson(context, workflowItem, ePerson);
if (poolTask2 != null && poolTask2.getID() == poolTask.getID()) { if (poolTask2 != null && poolTask2.getID().equals(poolTask.getID())) {
return true; return true;
} }
} catch (SQLException | AuthorizeException | IOException e) { } catch (SQLException | AuthorizeException | IOException e) {