View Javadoc
1   /*
2    * CSVeed (https://github.com/42BV/CSVeed)
3    *
4    * Copyright 2013-2023 CSVeed.
5    *
6    * All rights reserved. This program and the accompanying materials
7    * are made available under the terms of The Apache Software License,
8    * Version 2.0 which accompanies this distribution, and is available at
9    * https://www.apache.org/licenses/LICENSE-2.0.txt
10   */
11  package org.csveed.common;
12  
13  /**
14   * The Class ColumnIndexKey.
15   */
16  public class ColumnIndexKey extends ColumnKey {
17  
18      /** The column index. */
19      private final Integer columnIndex;
20  
21      /**
22       * Instantiates a new column index key.
23       *
24       * @param columnIndex
25       *            the column index
26       */
27      public ColumnIndexKey(int columnIndex) {
28          this.columnIndex = columnIndex;
29      }
30  
31      @Override
32      public int compareTo(ColumnKey columnKey) {
33          if (!sameKeyType(columnKey)) {
34              return keyTypeCompare(columnKey);
35          }
36          return this.columnIndex.compareTo(((ColumnIndexKey) columnKey).columnIndex);
37      }
38  
39      @Override
40      public boolean equals(Object obj) {
41          if (!(obj instanceof ColumnIndexKey)) {
42              return false;
43          }
44          return compareTo((ColumnIndexKey) obj) == 0;
45      }
46  
47      @Override
48      public int hashCode() {
49          return columnIndex.hashCode();
50      }
51  
52      @Override
53      public String toString() {
54          return "Column Index: " + columnIndex;
55      }
56  
57      @Override
58      public Integer getPriority() {
59          return 1;
60      }
61  }