Skip to content

Commit

Permalink
Issue highsource#11. Unit tests now passing for Lists
Browse files Browse the repository at this point in the history
  • Loading branch information
ja6a authored and ja6a committed Dec 1, 2014
1 parent 14ebccd commit 0c2d698
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ protected void generate(JBlock block, JVar currentHashCode, JType exposedType,
getCodeModel().ref(Iterator.class).narrow(elementType), value.name() + "Iterator",
value.invoke("iterator"));

final JVar listHashCode = block.decl(JMod.NONE,
getCodeModel().INT, "listHashCode",
JExpr.lit(1));

final JBlock elementBlock = block._while(iterator.invoke("hasNext"))
.body();
final JVar elementValue = elementBlock.decl(JMod.FINAL, elementType,
Expand All @@ -48,8 +52,10 @@ protected void generate(JBlock block, JVar currentHashCode, JType exposedType,
final JExpression hasSetValue = isAlwaysSet ? JExpr.TRUE : elementValue
.ne(JExpr._null());
getFactory().getCodeGenerator(elementType).generate(elementBlock,
currentHashCode, elementType, possibleTypes, elementValue,
listHashCode, elementType, possibleTypes, elementValue,
hasSetValue, isAlwaysSet);

block.assign(currentHashCode,
currentHashCode.mul(JExpr.lit(getFactory().getMultiplier()))
.plus(listHashCode));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.11.30 at 10:33:12 PM GMT
// Generated on: 2014.12.01 at 12:03:43 AM GMT
//


Expand Down Expand Up @@ -291,10 +291,12 @@ public int hashCode2() {
theMiddleInitials = (this.isSetMiddleInitials()?this.getMiddleInitials():null);
if (this.isSetMiddleInitials()) {
final Iterator<String> theMiddleInitialsIterator = theMiddleInitials.iterator();
int listHashCode = 1;
while (theMiddleInitialsIterator.hasNext()) {
final String theMiddleInitialsElement = theMiddleInitialsIterator.next();
currentHashCode = ((currentHashCode* 31)+((theMiddleInitialsElement!= null)?theMiddleInitialsElement.hashCode(): 0));
listHashCode = ((listHashCode* 31)+((theMiddleInitialsElement!= null)?theMiddleInitialsElement.hashCode(): 0));
}
currentHashCode = ((currentHashCode* 31)+ listHashCode);
} else {
currentHashCode = (currentHashCode* 31);
}
Expand Down Expand Up @@ -339,7 +341,7 @@ public boolean equals(Object obj) {
return false;
if (getClass() != obj.getClass())
return false;
Customer other = (Customer) obj;
Customer2 other = (Customer2) obj;
if (address == null) {
if (other.address != null)
return false;
Expand Down

0 comments on commit 0c2d698

Please sign in to comment.