View Javadoc
1   package net.kreatious.pianoleopard.midi.event;
2   
3   /**
4    * Represents a slot that uniquely identifies which interval events within the
5    * same channel belong to. Intended to be used as a key for maps.
6    * <p>
7    * A slot contains a channel and a key.
8    *
9    * @author Jay-R Studer
10   */
11  public class Slot {
12      private final int channel;
13      private final Object key;
14  
15      Slot(int channel, Object key) {
16          this.channel = channel;
17          this.key = key;
18      }
19  
20      @Override
21      public boolean equals(Object obj) {
22          if (obj == this) {
23              return true;
24          }
25          if (!(obj instanceof Slot)) {
26              return false;
27          }
28          final Slot other = (Slot) obj;
29          return channel == other.channel && key.equals(other.key);
30      }
31  
32      @Override
33      public int hashCode() {
34          return 31 * channel + key.hashCode();
35      }
36  
37      @Override
38      public String toString() {
39          return key.toString();
40      }
41  }