001package net.kreatious.pianoleopard.midi.event;
002
003/**
004 * Represents a slot that uniquely identifies which interval events within the
005 * same channel belong to. Intended to be used as a key for maps.
006 * <p>
007 * A slot contains a channel and a key.
008 *
009 * @author Jay-R Studer
010 */
011public class Slot {
012    private final int channel;
013    private final Object key;
014
015    Slot(int channel, Object key) {
016        this.channel = channel;
017        this.key = key;
018    }
019
020    @Override
021    public boolean equals(Object obj) {
022        if (obj == this) {
023            return true;
024        }
025        if (!(obj instanceof Slot)) {
026            return false;
027        }
028        final Slot other = (Slot) obj;
029        return channel == other.channel && key.equals(other.key);
030    }
031
032    @Override
033    public int hashCode() {
034        return 31 * channel + key.hashCode();
035    }
036
037    @Override
038    public String toString() {
039        return key.toString();
040    }
041}