mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-14 08:40:29 +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))
|
if (!(o instanceof Line))
|
||||||
return false;
|
return false;
|
||||||
final Line other = (Line) o;
|
final Line other = (Line) o;
|
||||||
return (this.label.equals(other.label));
|
return nullSafeEquals(this.label, other.label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
return label.hashCode();
|
return nullSafeHashCode(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(final Line other)
|
public int compareTo(final Line other)
|
||||||
|
@ -96,6 +96,22 @@ public final class Line implements Serializable, Comparable<Line>
|
||||||
if (compareProduct != 0)
|
if (compareProduct != 0)
|
||||||
return compareProduct;
|
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