View Javadoc

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.mitosis.service.protocol.message;
21  
22  
23  import org.apache.directory.shared.ldap.util.EqualsBuilder;
24  import org.apache.directory.shared.ldap.util.HashCodeBuilder;
25  import org.apache.directory.mitosis.service.protocol.Constants;
26  
27  
28  public class LoginMessage extends BaseMessage
29  {
30      private final String replicaId;
31  
32  
33      public LoginMessage( int sequence, String replicaId )
34      {
35          super( sequence );
36  
37          this.replicaId = replicaId;
38      }
39  
40  
41      public int getType()
42      {
43          return Constants.LOGIN;
44      }
45  
46  
47      public String getReplicaId()
48      {
49          return replicaId;
50      }
51  
52  
53      /**
54       * @see java.lang.Object#equals(Object)
55       */
56      public boolean equals( Object object )
57      {
58          if ( !( object instanceof LoginMessage ) )
59          {
60              return false;
61          }
62  
63          LoginMessage rhs = ( LoginMessage ) object;
64  
65          return new EqualsBuilder().appendSuper( super.equals( object ) ).append( this.replicaId, rhs.replicaId )
66              .isEquals();
67      }
68  
69  
70      /**
71       * @see java.lang.Object#hashCode()
72       * @return the instance's hashcode 
73       */
74      public int hashCode()
75      {
76          return new HashCodeBuilder( 1520317245, 1630850531 ).appendSuper( super.hashCode() ).append( this.replicaId )
77              .toHashCode();
78      }
79  
80  
81      public String toString()
82      {
83          return "[Login] " + super.toString() + ", " + replicaId;
84      }
85  }