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