mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-14 00:30:31 +00:00
fixed NPE
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@812 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
4eebf50007
commit
7db1140624
1 changed files with 19 additions and 3 deletions
|
@ -77,13 +77,13 @@ public final class Line implements Serializable, Comparable<Line>
|
|||
if (!(o instanceof Line))
|
||||
return false;
|
||||
final Line other = (Line) o;
|
||||
return (this.label.equals(other.label));
|
||||
return nullSafeEquals(this.label, other.label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return label.hashCode();
|
||||
return nullSafeHashCode(label);
|
||||
}
|
||||
|
||||
public int compareTo(final Line other)
|
||||
|
@ -96,6 +96,22 @@ public final class Line implements Serializable, Comparable<Line>
|
|||
if (compareProduct != 0)
|
||||
return compareProduct;
|
||||
|
||||
return label.compareTo(other.label);
|
||||
return this.label.compareTo(other.label);
|
||||
}
|
||||
|
||||
private boolean nullSafeEquals(final Object o1, final Object o2)
|
||||
{
|
||||
if (o1 == null && o2 == null)
|
||||
return true;
|
||||
if (o1 != null && o1.equals(o2))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private int nullSafeHashCode(final Object o)
|
||||
{
|
||||
if (o == null)
|
||||
return 0;
|
||||
return o.hashCode();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue