1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.internet2.middleware.shibboleth.common.attribute.provider;
18
19 import org.opensaml.xml.util.DatatypeHelper;
20
21
22
23
24 public class ScopedAttributeValue {
25
26
27 private String value;
28
29
30 private String scope;
31
32
33
34
35
36
37
38 public ScopedAttributeValue(String attributeValue, String valueScope) {
39 value = DatatypeHelper.safeTrimOrNullString(attributeValue);
40 scope = DatatypeHelper.safeTrimOrNullString(valueScope);
41
42 if (scope == null || value == null) {
43 throw new IllegalArgumentException("Attribute value and scope may not be null");
44 }
45 }
46
47
48
49
50
51
52 public String getValue() {
53 return value;
54 }
55
56
57
58
59
60
61 public String getScope() {
62 return scope;
63 }
64
65
66 public String toString() {
67 return value + ":" + scope;
68 }
69
70
71 public int hashCode() {
72 int hash = 1;
73 hash = hash * 31 + value.hashCode();
74 hash = hash * 31 + scope.hashCode();
75
76 return hash;
77 }
78
79
80 public boolean equals(Object obj) {
81 if (this == obj) {
82 return true;
83 }
84
85 if (!(obj instanceof ScopedAttributeValue)) {
86 return false;
87 }
88
89 ScopedAttributeValue otherValue = (ScopedAttributeValue) obj;
90
91 return DatatypeHelper.safeEquals(getValue(), otherValue.getValue())
92 && DatatypeHelper.safeEquals(getScope(), otherValue.getScope());
93 }
94 }