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