View Javadoc

1   package org.musicontroller.core;
2   
3   
4   public class Instrument extends LinkableAbs {
5   	
6   	/**
7   	 * Two Instruments are the same if their names are equal (ignoring case).
8   	 * This means it is impossible to have two instruments with the same name
9   	 * but different parents.
10  	 * @return True if the instruments are equal, false otherwise.
11  	 */
12  	@Override
13  	public boolean equals(Object obj) {
14  		boolean result = false;
15  		if (this==obj) {
16  			return true;
17  		}
18  		if (obj instanceof Instrument) {
19  			Instrument other = (Instrument) obj;
20  			if(this.getName()==null) {
21  				result = other.getName()==null;
22  			} else {
23  				result = this.getName().equalsIgnoreCase(other.getName());
24  			}
25  		}
26  		return result;
27  	}
28  	
29  	@Override
30  	public int hashCode() {
31  		int result = 0;
32  		if(getName()!=null) {
33  			result += getName().toLowerCase().hashCode();
34  		}
35  		return result;
36  	}
37  	
38  	/**
39  	 * Returns a string representing the instrument that is suitable
40  	 * for human consumption.
41  	 */
42  	public String toString() {
43  		return getName();
44  	}
45  	
46  	/*
47  	 * (non-Javadoc)
48  	 * @see org.musicontroller.model.Linkable#getType()
49  	 */
50  	public String getType() {
51  		return "I";
52  	}
53  	
54  }