Commit 9e7b9bc6 authored by cdanger's avatar cdanger

- Implemented hashcode and equals in TestXacmlPolicyAttributeValue

parent 4fd10f4d
...@@ -54,6 +54,8 @@ public final class TestXacmlPolicyAttributeValue implements AttributeValue ...@@ -54,6 +54,8 @@ public final class TestXacmlPolicyAttributeValue implements AttributeValue
private transient volatile List<Serializable> content = null; private transient volatile List<Serializable> content = null;
private transient volatile int hashCode = 0;
private TestXacmlPolicyAttributeValue(final List<Serializable> content) throws IllegalArgumentException private TestXacmlPolicyAttributeValue(final List<Serializable> content) throws IllegalArgumentException
{ {
/* /*
...@@ -81,7 +83,8 @@ public final class TestXacmlPolicyAttributeValue implements AttributeValue ...@@ -81,7 +83,8 @@ public final class TestXacmlPolicyAttributeValue implements AttributeValue
if (content0 instanceof Policy) if (content0 instanceof Policy)
{ {
policy = (Policy) content0; policy = (Policy) content0;
} else if (content0 instanceof String) }
else if (content0 instanceof String)
{ {
if (!contentIterator.hasNext()) if (!contentIterator.hasNext())
{ {
...@@ -92,11 +95,13 @@ public final class TestXacmlPolicyAttributeValue implements AttributeValue ...@@ -92,11 +95,13 @@ public final class TestXacmlPolicyAttributeValue implements AttributeValue
if (content1 instanceof Policy) if (content1 instanceof Policy)
{ {
policy = (Policy) content1; policy = (Policy) content1;
} else }
else
{ {
throw new IllegalArgumentException("Invalid content for datatype '" + DATATYPE + "': second item (after text) is not a XACML <Policy>, but: " + content1.getClass()); throw new IllegalArgumentException("Invalid content for datatype '" + DATATYPE + "': second item (after text) is not a XACML <Policy>, but: " + content1.getClass());
} }
} else }
else
{ {
throw new IllegalArgumentException("Invalid content for datatype '" + DATATYPE + "': first item is neither text nor a XACML <Policy>, but: " + content0.getClass()); throw new IllegalArgumentException("Invalid content for datatype '" + DATATYPE + "': first item is neither text nor a XACML <Policy>, but: " + content0.getClass());
} }
...@@ -129,6 +134,34 @@ public final class TestXacmlPolicyAttributeValue implements AttributeValue ...@@ -129,6 +134,34 @@ public final class TestXacmlPolicyAttributeValue implements AttributeValue
return Collections.emptyMap(); return Collections.emptyMap();
} }
@Override
public int hashCode()
{
if (hashCode == 0)
{
hashCode = this.policy.hashCode();
}
return hashCode;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (!(obj instanceof TestXacmlPolicyAttributeValue))
{
return false;
}
final TestXacmlPolicyAttributeValue other = (TestXacmlPolicyAttributeValue) obj;
return this.policy.equals(other.policy);
}
/** /**
* {@link TestXacmlPolicyAttributeValue} factory * {@link TestXacmlPolicyAttributeValue} factory
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment