cleanup: Tag

This commit is contained in:
Hannes Janetzek 2014-03-08 01:22:36 +01:00
parent 31e1b0ec99
commit bd96c018f7

View File

@ -101,36 +101,36 @@ public class Tag {
} }
Tag other = (Tag) obj; Tag other = (Tag) obj;
if (this.key != other.key) if (key != other.key)
return false; return false;
if (this.intern && other.intern) { if (intern && other.intern) {
if (this.value == other.value) if (value == other.value)
return true;
} else {
if (this.value.equals(other.value))
return true; return true;
} else if (!intern && value.equals(other.value)) {
return true;
} }
return false; return false;
} }
@Override @Override
public int hashCode() { public int hashCode() {
if (this.hashCodeValue == 0) if (hashCodeValue == 0)
this.hashCodeValue = calculateHashCode(); hashCodeValue = calculateHashCode();
return this.hashCodeValue; return hashCodeValue;
} }
@Override @Override
public String toString() { public String toString() {
StringBuilder stringBuilder = new StringBuilder(); return new StringBuilder()
stringBuilder.append("Tag [key="); .append("Tag[")
stringBuilder.append(this.key); .append(key)
stringBuilder.append(", value="); .append(',')
stringBuilder.append(this.value); .append(value)
stringBuilder.append("]"); .append(']')
return stringBuilder.toString(); .toString();
} }
/** /**
@ -138,8 +138,8 @@ public class Tag {
*/ */
private int calculateHashCode() { private int calculateHashCode() {
int result = 7; int result = 7;
result = 31 * result + ((this.key == null) ? 0 : this.key.hashCode()); result = 31 * result + ((key == null) ? 0 : key.hashCode());
result = 31 * result + ((this.value == null) ? 0 : this.value.hashCode()); result = 31 * result + ((value == null) ? 0 : value.hashCode());
return result; return result;
} }