View Javadoc
1   /*
2    * Copyright 2017 Andrew Rucker Jones.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.opencsv.bean.util;
17  
18  /**
19   * A simple class for ordering objects.
20   *
21   * @param <E> Type of the element to be ordered
22   * @author Andrew Rucker Jones
23   * @since 4.0
24   */
25  public class OrderedObject<E> {
26      private final long ordinal;
27      private final E element;
28      
29      /**
30       * Creates an object with an order.
31       * @param ordinal The position in a sequence of objects
32       * @param element The object being sequenced
33       */
34      public OrderedObject(long ordinal, E element) {
35          this.ordinal = ordinal;
36          this.element = element;
37      }
38      
39      /**
40       * @return The position in a sequence of objects
41       */
42      public long getOrdinal() {
43          return ordinal;
44      }
45      
46      /**
47       * @return The object being sequenced
48       */
49      public E getElement() {
50          return element;
51      }
52  }