mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-15 09:00:36 +00:00
fixed NPE
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@948 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
5c59db2c55
commit
30bdca2a29
1 changed files with 20 additions and 2 deletions
|
@ -123,9 +123,9 @@ public final class Location implements Serializable
|
||||||
return false;
|
return false;
|
||||||
if (this.id != other.id)
|
if (this.id != other.id)
|
||||||
return false;
|
return false;
|
||||||
if (this.id != 0)
|
if (this.id != 0) // TODO needed?
|
||||||
return true;
|
return true;
|
||||||
return this.name.equals(other.name);
|
return nullSafeEquals(this.name, other.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -135,6 +135,24 @@ public final class Location implements Serializable
|
||||||
hashCode += type.hashCode();
|
hashCode += type.hashCode();
|
||||||
hashCode *= 29;
|
hashCode *= 29;
|
||||||
hashCode += id;
|
hashCode += id;
|
||||||
|
hashCode *= 29;
|
||||||
|
hashCode += nullSafeHashCode(name);
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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