Skip to content

Commit

Permalink
WBRI-364, and fix annotation literal to support array member values
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@3516 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Aug 16, 2009
1 parent 9e5bd26 commit 263ccc3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions api/src/main/java/javax/enterprise/inject/AnnotationLiteral.java
Expand Up @@ -22,6 +22,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;


/**
Expand Down Expand Up @@ -124,7 +125,14 @@ public boolean equals(Object other)
{
Object thisValue = invoke(member, this);
Object thatValue = invoke(member, that);
if (!thisValue.equals(thatValue))
if (thisValue.getClass().isArray() && thatValue.getClass().isArray())
{
if (!Arrays.equals(Object[].class.cast(thisValue), Object[].class.cast(thatValue)))
{
return false;
}
}
else if (!thisValue.equals(thatValue))
{
return false;
}
Expand All @@ -142,7 +150,8 @@ public int hashCode()
for (Method member : members)
{
int memberNameHashCode = 127 * member.getName().hashCode();
int memberValueHashCode = invoke(member, this).hashCode();
Object value = invoke(member, this);
int memberValueHashCode = value.getClass().isArray() ? Arrays.hashCode(Object[].class.cast(value)) : value.hashCode();
hashCode += memberNameHashCode ^ memberValueHashCode;
}
return hashCode;
Expand Down

0 comments on commit 263ccc3

Please sign in to comment.