1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19 */
20 package org.apache.directory.api.ldap.aci.protectedItem;
21
22
23 import org.apache.directory.api.ldap.aci.ProtectedItem;
24 import org.apache.directory.api.ldap.model.filter.ExprNode;
25
26
27 /**
28 * The contents of entries (possibly a family member) which are restricted
29 * to those that have object class values that satisfy the predicate defined
30 * by Refinement (see 12.3.5), together (in the case of an ancestor or other
31 * family member) with the entry contents as a whole of each subordinate
32 * family member entry; it does not necessarily include the information in
33 * these entries.
34 *
35 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
36 */
37 public class ClassesItem extends ProtectedItem
38 {
39 /** The classes refinement. */
40 private final ExprNode classes;
41
42 /**
43 * Creates a new instance.
44 *
45 * @param classes refinement
46 */
47 public ClassesItem( ExprNode classes )
48 {
49 this.classes = classes;
50 }
51
52
53 /**
54 * Gets the classes refinement.
55 *
56 * @return the classes refinement
57 */
58 public ExprNode getClasses()
59 {
60 return classes;
61 }
62
63
64 /**
65 * {@inheritDoc}
66 */
67 @Override
68 public int hashCode()
69 {
70 int hash = 37;
71
72 if ( classes != null )
73 {
74 hash = hash * 17 + classes.hashCode();
75 }
76 else
77 {
78 hash = hash * 17 + getClass().getName().hashCode();
79 }
80
81 return hash;
82 }
83
84
85 /**
86 * {@inheritDoc}
87 */
88 @Override
89 public boolean equals( Object o )
90 {
91 if ( this == o )
92 {
93 return true;
94 }
95
96 if ( o instanceof ClassesItem )
97 {
98 ClassesItem that = ( ClassesItem ) o;
99
100 if ( classes == null )
101 {
102 return that.classes == null;
103 }
104
105 return classes.equals( that.classes );
106 }
107
108 return false;
109 }
110
111
112 /**
113 * {@inheritDoc}
114 */
115 @Override
116 public String toString()
117 {
118 StringBuilder buf = new StringBuilder();
119
120 buf.append( "classes " );
121
122 if ( classes != null )
123 {
124 classes.printRefinementToBuffer( buf );
125 }
126
127 return buf.toString();
128 }
129 }