View Javadoc

1   /*
2    * Copyright (c) 2003 by Atlassian Software Systems Pty. Ltd.
3    * All rights reserved.
4    */
5   package com.atlassian.core.util;
6   
7   import java.io.Serializable;
8   
9   
10  /**
11   * A simple type to represent a pair of objects.
12   */
13  public class PairType implements Serializable
14  {
15      //~ Instance variables ---------------------------------------------------------------------------------------------
16  
17      private Serializable key;
18      private Serializable  value;
19  
20      //~ Constructors ---------------------------------------------------------------------------------------------------
21  
22      public PairType()
23      {
24      }
25  
26      public PairType(Serializable key, Serializable  value)
27      {
28          this.key = key;
29          this.value = value;
30      }
31  
32      //~ Methods --------------------------------------------------------------------------------------------------------
33  
34      public Serializable  getKey()
35      {
36          return key;
37      }
38  
39      public void setKey(Serializable key)
40      {
41          this.key = key;
42      }
43  
44      public Serializable getValue()
45      {
46          return value;
47      }
48  
49      public void setValue(Serializable value)
50      {
51          this.value = value;
52      }
53  
54      public String toString()
55      {
56          return key+"/"+value;
57      }
58  
59      public boolean equals(Object o)
60      {
61          if (this == o) return true;
62          if (!(o instanceof PairType)) return false;
63  
64          final PairType pairType = (PairType) o;
65  
66          if (!key.equals(pairType.key)) return false;
67          if (!value.equals(pairType.value)) return false;
68  
69          return true;
70      }
71  
72      public int hashCode()
73      {
74          int result;
75          result = key.hashCode();
76          result = 29 * result + value.hashCode();
77          return result;
78      }
79  }