Implement missing equals or add warning to classes that have a natural ordering
FEA: ItEr74S04BugFixing
This commit is contained in:
parent
b40a5eed12
commit
9f11338947
16 changed files with 72 additions and 2 deletions
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||
import java.util.ListIterator;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
|
|
@ -303,6 +304,21 @@ public class AvailabilityTimeLine {
|
|||
- this.end.compareTo(other.end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Interval) {
|
||||
Interval other = (Interval) obj;
|
||||
return start.equals(other.getStart())
|
||||
&& end.equals(other.getEnd());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append(start).append(end).toHashCode();
|
||||
}
|
||||
|
||||
public boolean includes(LocalDate date) {
|
||||
return includes(new FixedPoint(date));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ public class ProportionalDistributor {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*
|
||||
*/
|
||||
private static class FractionWithPosition implements
|
||||
Comparable<FractionWithPosition> {
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ import org.navalplanner.business.labels.daos.ILabelTypeDAO;
|
|||
|
||||
/**
|
||||
* LabeType entity
|
||||
*
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*
|
||||
* @author Diego Pino Garcia<dpino@igalia.com>
|
||||
*/
|
||||
public class LabelType extends IntegrationEntity implements Comparable {
|
||||
|
|
|
|||
|
|
@ -29,8 +29,12 @@ import org.navalplanner.business.common.IntegrationEntity;
|
|||
import org.navalplanner.business.common.Registry;
|
||||
import org.navalplanner.business.materials.bootstrap.UnitTypeBootstrap;
|
||||
import org.navalplanner.business.materials.daos.IMaterialDAO;
|
||||
|
||||
/**
|
||||
* Material entity
|
||||
*
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*
|
||||
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
|
||||
*
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ import org.navalplanner.business.orders.entities.OrderElement;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author Diego Pino Garcia <dpino@igalia.com>
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*
|
||||
* @author Diego Pino Garcia <dpino@igalia.com>
|
||||
*/
|
||||
public class MaterialAssignment extends BaseEntity implements Comparable {
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@ import org.navalplanner.business.orders.entities.OrderElement;
|
|||
import org.navalplanner.business.templates.entities.OrderElementTemplate;
|
||||
|
||||
/**
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public class MaterialAssignmentTemplate extends BaseEntity implements
|
||||
Comparable<MaterialAssignmentTemplate> {
|
||||
|
|
|
|||
|
|
@ -240,6 +240,9 @@ public class EffortDistributor {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*/
|
||||
private static class ResourceWithAvailableCapacity implements
|
||||
Comparable<ResourceWithAvailableCapacity> {
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ import java.util.Iterator;
|
|||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.workingday.EffortDuration;
|
||||
|
|
@ -89,6 +91,21 @@ public class DateAndHour implements Comparable<DateAndHour> {
|
|||
.getHour());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof DateAndHour) {
|
||||
DateAndHour other = (DateAndHour) obj;
|
||||
return new EqualsBuilder().append(date, other.date)
|
||||
.append(hour, other.hour).isEquals();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append(date).append(hour).toHashCode();
|
||||
}
|
||||
|
||||
private LocalDate getDate(DateAndHour dateAndHour) {
|
||||
return (dateAndHour != null) ? dateAndHour.getDate() : null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ import org.navalplanner.business.workingday.IntraDayDate;
|
|||
import org.navalplanner.business.workingday.IntraDayDate.PartialDay;
|
||||
|
||||
/**
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*
|
||||
* @author Diego Pino Garcia <dpino@igalia.com>
|
||||
*
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ import org.navalplanner.business.resources.entities.Worker;
|
|||
import org.navalplanner.business.workreports.entities.WorkReportLine;
|
||||
import org.navalplanner.business.workreports.valueobjects.DescriptionValue;
|
||||
|
||||
|
||||
/**
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*/
|
||||
public class OrderCostsPerResourceDTO implements
|
||||
Comparable<OrderCostsPerResourceDTO> {
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
|||
|
||||
/**
|
||||
* This class models a worker.
|
||||
*
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*
|
||||
* @author Fernando Bellas Permuy <fbellas@udc.es>
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ import org.navalplanner.business.labels.entities.Label;
|
|||
import org.navalplanner.business.labels.entities.LabelType;
|
||||
|
||||
/**
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
public class WorkReportLabelTypeAssigment extends BaseEntity implements
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ import org.navalplanner.business.workreports.valueobjects.DescriptionField;
|
|||
import org.navalplanner.business.workreports.valueobjects.DescriptionValue;
|
||||
|
||||
/**
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*
|
||||
* @author Diego Pino García <dpino@igalia.com>
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ public class GapsMergeSort {
|
|||
private GapsMergeSort() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*
|
||||
*/
|
||||
private static class CurrentGap implements Comparable<CurrentGap> {
|
||||
|
||||
static List<CurrentGap> convert(
|
||||
|
|
|
|||
|
|
@ -257,6 +257,8 @@ public class LimitingResourcesController extends GenericForwardComposer {
|
|||
/**
|
||||
* DTO for list of unassigned {@link LimitingResourceQueueElement}
|
||||
*
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*
|
||||
* @author Diego Pino Garcia <dpino@igalia.com>
|
||||
*
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ import org.navalplanner.business.templates.entities.OrderLineGroupTemplate;
|
|||
/**
|
||||
* Wrapper represents the handled data in the form of assigning criterion
|
||||
* requirement.
|
||||
*
|
||||
* Note: this class has a natural ordering that is inconsistent with equals.
|
||||
*
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
public class HoursGroupWrapper implements INewObject,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue