org.apache.avro.hadoop.util

## Class AvroCharSequenceComparator<T>

- java.lang.Object
- - org.apache.avro.hadoop.util.AvroCharSequenceComparator<T>

Type Parameters:
  `T` - The type of object to compare.

All Implemented Interfaces:
  Comparator<T>

    public class AvroCharSequenceComparator<T>
    extends Object
    implements Comparator<T>

Compares Avro string data (data with schema "string").

The only case where comparing Avro objects does not work using their natural order is when the schema is "string". The Avro string schema maps to the Java `CharSequence` interface, which does not define `equals`, `hashCode`, or `compareTo`.

Using this comparator enables comparisons between `String` and `Utf8` objects that are both valid when working with Avro strings.

### Field Summary

Fields
`static AvroCharSequenceComparator<CharSequence>` `INSTANCE` A singleton instance.

### Constructor Summary

Constructors
Constructor and Description
`AvroCharSequenceComparator()`

### Method Summary

All Methods Instance Methods Concrete Methods
`int` `compare(T o1, T o2)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.Comparator

`comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

### Field Detail

#### INSTANCE

    public static final AvroCharSequenceComparator<CharSequence> INSTANCE

A singleton instance.

### Constructor Detail

#### AvroCharSequenceComparator

    public AvroCharSequenceComparator()

### Method Detail

#### compare

    public int compare(T o1,
                       T o2)

Specified by:
  `compare` in interface `Comparator<T>`