View Javadoc
1   /*
2    * Copyright 2020-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.util.tuples;
6   
7   import oshi.annotation.concurrent.ThreadSafe;
8   
9   /**
10   * Convenience class for returning multiple objects from methods.
11   *
12   * @param <A> Type of the first element
13   * @param <B> Type of the second element
14   */
15  @ThreadSafe
16  public class Pair<A, B> {
17  
18      private final A a;
19      private final B b;
20  
21      /**
22       * Create a pair and store two objects.
23       *
24       * @param a the first object to store
25       * @param b the second object to store
26       */
27      public Pair(A a, B b) {
28          this.a = a;
29          this.b = b;
30      }
31  
32      /**
33       * Returns the first stored object.
34       *
35       * @return first object stored
36       */
37      public final A getA() {
38          return a;
39      }
40  
41      /**
42       * Returns the second stored object.
43       *
44       * @return second object stored
45       */
46      public final B getB() {
47          return b;
48      }
49  }