mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
[DS-2763] Continue cleaning up serialization bugs found by Findbugs
This commit is contained in:

committed by
Mark H. Wood

parent
e61352ef29
commit
3b123a05e0
@@ -7,9 +7,15 @@
|
||||
*/
|
||||
package org.dspace.content;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class CollectionNameComparator implements Comparator<Collection> {
|
||||
/**
|
||||
* Compares the names of two {@link Collection}s.
|
||||
*/
|
||||
public class CollectionNameComparator
|
||||
implements Comparator<Collection>, Serializable
|
||||
{
|
||||
@Override
|
||||
public int compare(Collection collection1, Collection collection2) {
|
||||
return collection1.getName().compareTo(collection2.getName());
|
||||
|
@@ -40,7 +40,8 @@ public class ItemComparator implements Comparator, Serializable
|
||||
/** Whether maximum or minimum value will be used */
|
||||
protected boolean max;
|
||||
|
||||
protected ItemService itemService;
|
||||
protected transient ItemService itemService
|
||||
= ContentServiceFactory.getInstance().getItemService();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -63,7 +64,6 @@ public class ItemComparator implements Comparator, Serializable
|
||||
this.qualifier = qualifier;
|
||||
this.language = language;
|
||||
this.max = max;
|
||||
this.itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,6 +127,7 @@ public class ItemComparator implements Comparator, Serializable
|
||||
* The object to compare to.
|
||||
* @return True if the other object is equal to this one, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof ItemComparator))
|
||||
@@ -141,13 +142,16 @@ public class ItemComparator implements Comparator, Serializable
|
||||
&& equalsWithNull(language, other.language) && (max == other.max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return new HashCodeBuilder().append(element).append(qualifier).append(language).append(max).toHashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the first string is equal to the second. Either or both
|
||||
* @param first
|
||||
* @param second
|
||||
* @return true if the first string is equal to the second. Either or both
|
||||
* may be null.
|
||||
*/
|
||||
protected boolean equalsWithNull(String first, String second)
|
||||
@@ -180,7 +184,7 @@ public class ItemComparator implements Comparator, Serializable
|
||||
// The overall array and each element are guaranteed non-null
|
||||
List<MetadataValue> dcvalues = itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, element, qualifier, language);
|
||||
|
||||
if (dcvalues.size() == 0)
|
||||
if (dcvalues.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -192,7 +196,7 @@ public class ItemComparator implements Comparator, Serializable
|
||||
|
||||
// We want to sort using Strings, but also keep track of
|
||||
// which Metadatum the value came from.
|
||||
Map<String, Integer> values = new HashMap<String, Integer>();
|
||||
Map<String, Integer> values = new HashMap<>();
|
||||
|
||||
for (int i = 0; i < dcvalues.size(); i++)
|
||||
{
|
||||
@@ -204,7 +208,7 @@ public class ItemComparator implements Comparator, Serializable
|
||||
}
|
||||
}
|
||||
|
||||
if (values.size() == 0)
|
||||
if (values.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -220,6 +224,8 @@ public class ItemComparator implements Comparator, Serializable
|
||||
|
||||
/**
|
||||
* Normalize the title of a Metadatum.
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
protected String normalizeTitle(MetadataValue value)
|
||||
{
|
||||
|
@@ -15,6 +15,7 @@ import org.dspace.core.GenericDAO;
|
||||
* All DSpaceObject DAO classes should implement this class since it ensures that the T object is of type DSpaceObject
|
||||
*
|
||||
* @author kevinvandevelde at atmire.com
|
||||
* @param <T>
|
||||
*/
|
||||
public interface DSpaceObjectDAO<T extends DSpaceObject> extends GenericDAO<T> {
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ import java.sql.SQLException;
|
||||
* to identify DSpaceObjects prior to DSpace 6.0
|
||||
*
|
||||
* @author kevinvandevelde at atmire.com
|
||||
* @param <T>
|
||||
*/
|
||||
public interface DSpaceObjectLegacySupportDAO<T extends DSpaceObject> extends DSpaceObjectDAO<T> {
|
||||
|
||||
|
Reference in New Issue
Block a user