View Javadoc

1   package org.musicontroller.core;
2   
3   /**
4    * This object models a relation between an artist
5    * and an instrument (This is a "plays" relation). This object contains
6    * the id's of the instrument and the artist.
7    * 
8    * @author Varienaja
9    * @version $Id: AIRelation.java,v 1.1 2010/03/16 18:55:42 varienaja Exp $
10   */
11  public class AIRelation {
12  	private long instrument_id;
13  	private long artist_id;
14  	
15  	/**
16  	 * Getter for the artist id.
17  	 * @return The artist id.
18  	 */
19  	public long getArtist_id() {
20  		return artist_id;
21  	}
22  	
23  	/**
24  	 * Setter for the artist id.
25  	 * @param artist_id The artist id.
26  	 */
27  	public void setArtist_id(long artist_id) {
28  		this.artist_id = artist_id;
29  	}
30  	
31  	/**
32  	 * Getter for the instrument id.
33  	 * @return The instrument id.
34  	 */
35  	public long getInstrument_id() {
36  		return instrument_id;
37  	}
38  	
39  	/**
40  	 * Setter for the instrument id.
41  	 * @param instrument_id The instrument id.
42  	 */
43  	public void setInstrument_id(long instrument_id) {
44  		this.instrument_id = instrument_id;
45  	}
46  	
47  	/**
48  	 * Two AIRelations are the same if both the instrument id
49  	 * and the artist id are equal.
50  	 * @param o The AIRelation to compare.
51  	 * @return True if the AIRelations are equal.
52  	 */
53  	public boolean equals(Object o) {
54  		if (o==null) return false;
55  		
56  		if (o instanceof AIRelation) {
57  			AIRelation check = (AIRelation) o;
58  			return check.getArtist_id()==artist_id && check.getInstrument_id()==instrument_id;
59  		} else {
60  			return false;
61  		}
62  	}
63  	
64  	public int hashCode() {
65  		return Long.valueOf(artist_id + 17 * instrument_id).hashCode();
66  	}
67  	
68  	public String toString() {
69  		return "Artist - Instrument relation between artist id:"+artist_id+" and instrument id:"+instrument_id+".";
70  	}
71  }