|
|
@@ -19,9 +19,9 @@ import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
19
|
19
|
public abstract class ValueObjectSupport<T extends ValueObject> implements ValueObject<T> {
|
|
20
|
20
|
|
|
21
|
21
|
@SuppressWarnings("UnusedDeclaration")
|
|
22
|
|
- private final Long id = null;
|
|
23
|
|
- private transient int cachedHashCode = 0;
|
|
24
|
|
- private final static String[] EXCLUDED_FIELDS = {"id", "cachedHashCode"};
|
|
|
22
|
+ private final Long _primaryKey = null;
|
|
|
23
|
+ private transient int _cachedHashCode = 0;
|
|
|
24
|
+ private final static String[] EXCLUDED_FIELDS = {"_primaryKey", "_cachedHashCode"};
|
|
25
|
25
|
|
|
26
|
26
|
/**
|
|
27
|
27
|
* @param other The other value object.
|
|
|
@@ -38,18 +38,18 @@ public abstract class ValueObjectSupport<T extends ValueObject> implements Value
|
|
38
|
38
|
@Override
|
|
39
|
39
|
public final int hashCode() {
|
|
40
|
40
|
// Using a local variable to ensure that we only do a single read
|
|
41
|
|
- // of the cachedHashCode field, to avoid race conditions.
|
|
|
41
|
+ // of the _cachedHashCode field, to avoid race conditions.
|
|
42
|
42
|
// It doesn't matter if several threads compute the hash code and overwrite
|
|
43
|
43
|
// each other, but it's important that we never return 0, which could happen
|
|
44
|
|
- // with multiple reads of the cachedHashCode field.
|
|
|
44
|
+ // with multiple reads of the _cachedHashCode field.
|
|
45
|
45
|
//
|
|
46
|
46
|
// See java.lang.String.hashCode()
|
|
47
|
|
- int h = cachedHashCode;
|
|
|
47
|
+ int h = _cachedHashCode;
|
|
48
|
48
|
if (h == 0) {
|
|
49
|
49
|
// Lazy initialization of hash code.
|
|
50
|
50
|
// Value objects are immutable, so the hash code never changes.
|
|
51
|
51
|
h = HashCodeBuilder.reflectionHashCode(this, false);
|
|
52
|
|
- cachedHashCode = h;
|
|
|
52
|
+ _cachedHashCode = h;
|
|
53
|
53
|
}
|
|
54
|
54
|
|
|
55
|
55
|
return h;
|