Skip to content

Commit

Permalink
Proxies.areEquivalent now supports enums
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Feb 20, 2013
1 parent 4447027 commit 714a215
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions proxy/src/main/java/org/jboss/forge/proxy/Proxies.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,22 @@ else if (proxiedObj == null || anotherProxiedObj == null)

boolean sameClassName = unwrapProxyClassName(unproxiedObj.getClass()).equals(
unwrapProxyClassName(anotherUnproxiedObj.getClass()));
boolean sameHashcode = (unproxiedObj.hashCode() == anotherUnproxiedObj.hashCode());
return sameClassName && sameHashcode;
if (sameClassName)
{
if (unproxiedObj.getClass().isEnum())
{
// Enum hashCode is different if loaded from different classloaders and cannot be overriden.
return unproxiedObj.toString().equals(anotherUnproxiedObj.toString());
}
else
{
return (unproxiedObj.hashCode() == anotherUnproxiedObj.hashCode());
}
}
else
{
return false;
}
}
}

Expand Down

0 comments on commit 714a215

Please sign in to comment.