Skip to content

Commit

Permalink
Use configured prefix
Browse files Browse the repository at this point in the history
Needed on cachedHashCode and propertyChangeSupport
Fixes #115
  • Loading branch information
jodastephen committed Sep 1, 2015
1 parent 0d7108f commit ec3157d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/changes/changes.xml
Expand Up @@ -9,6 +9,10 @@

<!-- types are add, fix, remove, update -->
<release version="1.6.1" date="SNAPSHOT" description="v1.6.1">
<action dev="jodastephen" type="fix">
Use configured prefix for cachedHashCode and propertyChangeSupport.
Fixes #115.
</action>
<action dev="jodastephen" type="fix">
Avoid null check in array clone getters where possible.
Fixes #114.
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/joda/beans/gen/BeanGen.java
Expand Up @@ -438,7 +438,7 @@ private void generatePropertyChangeSupportField() {
insertRegion.add("\t/**");
insertRegion.add("\t * The property change support field.");
insertRegion.add("\t */");
insertRegion.add("\tprivate PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);");
insertRegion.add("\tprivate PropertyChangeSupport " + config.getPrefix() + "propertyChangeSupport = new PropertyChangeSupport(this);");
insertRegion.add("");
}
}
Expand All @@ -448,7 +448,7 @@ private void generateHashCodeField() {
insertRegion.add("\t/**");
insertRegion.add("\t * The cached hash code, using the racy single-check idiom.");
insertRegion.add("\t */");
insertRegion.add("\tprivate int cachedHashCode;");
insertRegion.add("\tprivate int " + config.getPrefix() + "cachedHashCode;");
insertRegion.add("");
}
}
Expand Down Expand Up @@ -606,7 +606,7 @@ private void generateHashCode() {
insertRegion.add("\t@Override");
insertRegion.add("\tpublic int hashCode() {");
if (data.isCacheHashCode()) {
insertRegion.add("\t\tint hash = cachedHashCode;");
insertRegion.add("\t\tint hash = " + config.getPrefix() + "cachedHashCode;");
insertRegion.add("\t\tif (hash == 0) {");
if (data.isSubClass()) {
insertRegion.add("\t\t\thash = 7;");
Expand All @@ -617,7 +617,7 @@ private void generateHashCode() {
if (data.isSubClass()) {
insertRegion.add("\t\t\thash = hash ^ super.hashCode();");
}
insertRegion.add("\t\t\tcachedHashCode = hash;");
insertRegion.add("\t\t\t" + config.getPrefix() + "cachedHashCode = hash;");
insertRegion.add("\t\t}");
insertRegion.add("\t\treturn hash;");
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/joda/beans/gen/SetterGen.java
Expand Up @@ -208,7 +208,7 @@ List<String> generateSetter(String indent, PropertyData prop) {
String old = "old" + prop.getUpperName();
list.add("\t\t" + prop.getFieldType() + " " + old + " = this." + prop.getFieldName() + ";");
list.add("\t\tthis." + prop.getFieldName() + " = " + prop.getPropertyName() + ";");
list.add("\t\tthis.propertyChangeSupport.firePropertyChange(\"" +
list.add("\t\tthis." + prop.getConfig().getPrefix() + "propertyChangeSupport.firePropertyChange(\"" +
prop.getPropertyName() + "\", " + old + ", " + prop.getPropertyName() + ");");
list.add("\t}");
list.add("");
Expand Down

0 comments on commit ec3157d

Please sign in to comment.