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 public class ClassesItem extends ProtectedItem
36 {
37 /** The classes refinement. */
38 private final ExprNode classes;
39
40
41 /**
42 * Creates a new instance.
43 *
44 * @param classes refinement
45 */
46 public ClassesItem( ExprNode classes )
47 {
48 this.classes = classes;
49 }
50
51
52 /**
53 * Gets the classes refinement.
54 *
55 * @return the classes refinement
56 */
57 public ExprNode getClasses()
58 {
59 return classes;
60 }
61
62
63 /**
64 * {@inheritDoc}
65 */
66 @Override
67 public int hashCode()
68 {
69 int hash = 37;
70 hash = hash * 17 + getClass().getName().hashCode();
71 return hash;
72 }
73
74
75 /**
76 * {@inheritDoc}
77 */
78 @Override
79 public boolean equals( Object o )
80 {
81 if ( this == o )
82 {
83 return true;
84 }
85
86 if ( o instanceof ClassesItem )
87 {
88 ClassesItem that = ( ClassesItem ) o;
89 return this.classes.equals( that.classes );
90 }
91
92 return false;
93 }
94
95
96 /**
97 * {@inheritDoc}
98 */
99 @Override
100 public String toString()
101 {
102 StringBuilder buf = new StringBuilder();
103
104 buf.append( "classes " );
105 classes.printRefinementToBuffer( buf );
106
107 return buf.toString();
108 }
109 }