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 /* no qualifier*/class RevisionName extends Tuple<Long, String> 30 { 31 /** 32 * A constructor for the RevisionName class 33 * @param revision The revision 34 * @param name The BTree name 35 */ 36 /* no qualifier*/RevisionName( long revision, String name ) 37 { 38 super( revision, name ); 39 } 40 41 42 /** 43 * @return the revision 44 */ 45 /* no qualifier*/long getRevision() 46 { 47 return getKey(); 48 } 49 50 51 /** 52 * @param revision the revision to set 53 */ 54 /* no qualifier*/void setRevision( long revision ) 55 { 56 setKey( revision ); 57 } 58 59 60 /** 61 * @return the btree name 62 */ 63 /* no qualifier*/String getName() 64 { 65 return getValue(); 66 } 67 68 69 /** 70 * @param name the btree name to set 71 */ 72 /* no qualifier*/void setName( String name ) 73 { 74 setValue( name ); 75 } 76 77 78 /** 79 * @see Object#equals(Object) 80 */ 81 public boolean equals( Object that ) 82 { 83 if ( this == that ) 84 { 85 return true; 86 } 87 88 if ( !( that instanceof RevisionName ) ) 89 { 90 return false; 91 } 92 93 RevisionName revisionName = ( RevisionName ) that; 94 95 if ( getRevision() != revisionName.getRevision() ) 96 { 97 return false; 98 } 99 100 if ( getName() == null ) 101 { 102 return revisionName.getName() == null; 103 } 104 105 return ( getName().equals( revisionName.getName() ) ); 106 107 } 108 109 110 @Override 111 public int hashCode() 112 { 113 final int prime = 31; 114 int result = 1; 115 result = prime * result + ( ( getName() == null ) ? 0 : getName().hashCode() ); 116 result = prime * result + ( int ) ( getRevision() ^ ( getRevision() >>> 32 ) ); 117 return result; 118 } 119 120 121 /** 122 * @see Object#toString() 123 */ 124 public String toString() 125 { 126 return "[" + getRevision() + ":" + getName() + "]"; 127 } 128 }