1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.aci.protectedItem;
21
22
23 import java.util.Collections;
24 import java.util.Iterator;
25 import java.util.Set;
26
27 import org.apache.directory.api.ldap.aci.ProtectedItem;
28 import org.apache.directory.api.ldap.model.entry.Attribute;
29
30
31
32
33
34 public class AttributeValueItem extends ProtectedItem
35 {
36
37 private final Set<Attribute> attributes;
38
39
40
41
42
43
44
45 public AttributeValueItem( Set<Attribute> attributes )
46 {
47 this.attributes = Collections.unmodifiableSet( attributes );
48 }
49
50
51
52
53
54
55
56 public Iterator<Attribute> iterator()
57 {
58 return attributes.iterator();
59 }
60
61
62
63
64
65 @Override
66 public int hashCode()
67 {
68 int hash = 37;
69 hash = hash * 17 + attributes.hashCode();
70 return hash;
71 }
72
73
74
75
76
77 @Override
78 public boolean equals( Object o )
79 {
80 if ( this == o )
81 {
82 return true;
83 }
84
85 if ( o == null )
86 {
87 return false;
88 }
89
90 if ( o instanceof AttributeValueItem )
91 {
92 AttributeValueItem that = ( AttributeValueItem ) o;
93
94 return this.attributes.equals( that.attributes );
95 }
96
97 return false;
98 }
99
100
101
102
103
104 public String toString()
105 {
106 StringBuilder buf = new StringBuilder();
107
108 buf.append( "attributeValue {" );
109
110 boolean isFirst = true;
111
112 for ( Attribute attribute : attributes )
113 {
114 if ( isFirst )
115 {
116 isFirst = false;
117 }
118 else
119 {
120 buf.append( ", " );
121 }
122
123 buf.append( attribute.getId() );
124 buf.append( '=' );
125 buf.append( attribute.get() );
126 }
127
128 buf.append( " }" );
129
130 return buf.toString();
131 }
132 }