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.mavibot.btree;
21  
22  import java.io.Serializable;
23  
24  
25  /**
26   * A data structure that stores a revision associated to a BTree name. We use
27   * it to allow the access to old revisions.
28   *
29   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
30   */
31  /* no qualifier*/class RevisionName extends Tuple<Long, String> implements Serializable
32  {
33      /**
34       * for serialization purpose
35       */
36      protected RevisionName()
37      {
38      }
39      
40      
41      /**
42       * A constructor for the RevisionName class
43       * @param revision The revision
44       * @param name The BTree name
45       */
46      /* no qualifier*/RevisionName( long revision, String name )
47      {
48          super( revision, name );
49      }
50  
51  
52      /**
53       * @return the revision
54       */
55      /* no qualifier*/long getRevision()
56      {
57          return getKey();
58      }
59  
60  
61      /**
62       * @param revision the revision to set
63       */
64      /* no qualifier*/void setRevision( long revision )
65      {
66          setKey( revision );
67      }
68  
69  
70      /**
71       * @return the btree name
72       */
73      /* no qualifier*/String getName()
74      {
75          return getValue();
76      }
77  
78  
79      /**
80       * @param name the btree name to set
81       */
82      /* no qualifier*/void setName( String name )
83      {
84          setValue( name );
85      }
86  
87  
88      /**
89       * @see Object#equals(Object)
90       */
91      public boolean equals( Object that )
92      {
93          if ( this == that )
94          {
95              return true;
96          }
97  
98          if ( !( that instanceof RevisionName ) )
99          {
100             return false;
101         }
102 
103         RevisionName revisionName = ( RevisionName ) that;
104 
105         if ( getRevision() != revisionName.getRevision() )
106         {
107             return false;
108         }
109 
110         if ( getName() == null )
111         {
112             return revisionName.getName() == null;
113         }
114 
115         return ( getName().equals( revisionName.getName() ) );
116 
117     }
118 
119 
120     @Override
121     public int hashCode()
122     {
123         final int prime = 31;
124         int result = 1;
125         result = prime * result + ( ( getName() == null ) ? 0 : getName().hashCode() );
126         result = prime * result + ( int ) ( getRevision() ^ ( getRevision() >>> 32 ) );
127         return result;
128     }
129 
130 
131     /**
132      * @see Object#toString()
133      */
134     public String toString()
135     {
136         return "[" + getRevision() + ":" + getName() + "]";
137     }
138 }