001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.server.core.partition.impl.btree; 021 022 023import java.io.Serializable; 024 025import org.apache.directory.api.ldap.model.schema.comparators.SerializableComparator; 026 027 028/** 029 * Used to compare the sorting order of binary data. 030 * 031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 032 */ 033public interface TupleComparator<K, V> extends Serializable 034{ 035 /** 036 * Gets the comparator used to compare keys. May be null in which 037 * case the compareKey method will throw an UnsupportedOperationException. 038 * 039 * @return the comparator for comparing keys. 040 */ 041 SerializableComparator<K> getKeyComparator(); 042 043 044 /** 045 * Gets the binary comparator used to compare valuess. May be null in which 046 * case the compareValue method will throw an UnsupportedOperationException. 047 * 048 * @return the binary comparator for comparing values. 049 */ 050 SerializableComparator<V> getValueComparator(); 051 052 053 /** 054 * Compares key Object to determine their sorting order returning a 055 * value = to, < or > than 0. 056 * 057 * @param key1 the first key to compare 058 * @param key2 the other key to compare to the first 059 * @return 0 if both are equal, a negative value less than 0 if the first 060 * is less than the second, or a postive value if the first is greater than 061 * the second byte array. 062 */ 063 int compareKey( K key1, K key2 ); 064 065 066 /** 067 * Comparse value Objects to determine their sorting order returning a 068 * value = to, < or > than 0. 069 * 070 * @param value1 the first value to compare 071 * @param value2 the other value to compare to the first 072 * @return 0 if both are equal, a negative value less than 0 if the first 073 * is less than the second, or a postive value if the first is greater than 074 * the second Object. 075 */ 076 int compareValue( V value1, V value2 ); 077}