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.model.message;
21
22
23 /**
24 * SearchResponseDone implementation
25 *
26 * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
27 */
28 public class SearchResultDoneImpl extends AbstractResultResponse implements SearchResultDone
29 {
30 static final long serialVersionUID = 8698484213877460215L;
31
32
33 /**
34 * Creates a SearchResponseDone as a reply to an SearchRequest to
35 * indicate the end of a search operation.
36 */
37 public SearchResultDoneImpl()
38 {
39 super( -1, MessageTypeEnum.SEARCH_RESULT_DONE );
40 }
41
42
43 /**
44 * Creates a SearchResponseDone as a reply to an SearchRequest to
45 * indicate the end of a search operation.
46 *
47 * @param id the session unique message id
48 */
49 public SearchResultDoneImpl( final int id )
50 {
51 super( id, MessageTypeEnum.SEARCH_RESULT_DONE );
52 }
53
54
55 /**
56 * {@inheritDoc}
57 */
58 @Override
59 public int hashCode()
60 {
61 int hash = 37;
62 hash = hash * 17 + getLdapResult().hashCode();
63 hash = hash * 17 + super.hashCode();
64
65 return hash;
66 }
67
68
69 /**
70 * Checks for equality by using the underlying LdapResult objects of this
71 * SearchResponseDone stub.
72 *
73 * @param obj
74 * the object to be tested for equality
75 * @return true if obj is equivalent to this SearchResponseDone impl
76 */
77 @Override
78 public boolean equals( Object obj )
79 {
80 // quickly return if the obj is this object
81 if ( obj == this )
82 {
83 return true;
84 }
85
86 if ( !super.equals( obj ) )
87 {
88 return false;
89 }
90
91 LdapResult result = ( ( SearchResultDone ) obj ).getLdapResult();
92
93 return getLdapResult().equals( result );
94 }
95
96
97 /**
98 * Get a String representation of a SearchResultDone
99 *
100 * @return A SearchResultDone String
101 */
102 @Override
103 public String toString()
104 {
105 StringBuilder sb = new StringBuilder();
106
107 sb.append( " Search Result Done\n" );
108 sb.append( super.toString() );
109
110 return super.toString( sb.toString() );
111 }
112 }