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.schema.AttributeType;
29
30
31
32
33
34 public abstract class AbstractAttributeTypeProtectedItem extends ProtectedItem
35 {
36
37 protected final Set<AttributeType> attributeTypes;
38
39
40
41
42
43
44
45 protected AbstractAttributeTypeProtectedItem( Set<AttributeType> attributeTypes )
46 {
47 this.attributeTypes = Collections.unmodifiableSet( attributeTypes );
48 }
49
50
51
52
53
54
55
56 public Iterator<AttributeType> iterator()
57 {
58 return attributeTypes.iterator();
59 }
60
61
62
63
64
65 @Override
66 public int hashCode()
67 {
68 int hash = 37;
69 hash = hash * 17 + attributeTypes.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 ( getClass().isAssignableFrom( o.getClass() ) )
91 {
92 AbstractAttributeTypeProtectedItem that = ( AbstractAttributeTypeProtectedItem ) o;
93 return this.attributeTypes.equals( that.attributeTypes );
94 }
95
96 return false;
97 }
98
99
100
101
102
103 @Override
104 public String toString()
105 {
106 StringBuilder buf = new StringBuilder();
107
108 buf.append( "{ " );
109 boolean isFirst = true;
110
111 for ( AttributeType attributeType : attributeTypes )
112 {
113 if ( isFirst )
114 {
115 isFirst = false;
116 }
117 else
118 {
119 buf.append( ", " );
120 }
121
122 buf.append( attributeType.getName() );
123 }
124
125 buf.append( " }" );
126
127 return buf.toString();
128 }
129 }