View Javadoc

1   package org.musicontroller.gui.edit;
2   
3   /**
4    * This bean class is used to show artist - instrument relations
5    * in the SongEdit page. This contains the first name, last name
6    * and a comma separated list of instrument names.
7    * <p>AiRelationBean objects have a natural ordering based on the
8    * artist name.
9    * 
10   * @author Hans Drexler
11   * @version $Id: AiRelationBean.java,v 1.1 2010/03/16 18:55:42 varienaja Exp $
12   */
13  public class AiRelationBean implements Comparable<AiRelationBean> {
14  
15  	private String _firstname;
16  	private String _lastname;
17  	private String _instruments;
18  	private TrackList _tracks;
19  	
20  	public AiRelationBean() {
21  		_tracks = new TrackList();
22  	}
23  	
24  	/**
25  	 * Setter for the artists' first name.
26  	 * @param firstname The first name to set.
27  	 */
28  	public void setFirstName(String firstname) {
29  		_firstname = firstname;
30  	}
31  	
32  	/**
33  	 * Getter for the artists' first name.
34  	 * @return The first name.
35  	 */
36  	public String getFirstName() {
37  		return _firstname;
38  	}
39  
40  	/**
41  	 * Setter for the artists' last name.
42  	 * @param lastname The last name to set.
43  	 */
44  	public void setLastName(String lastname) {
45  		_lastname = lastname;
46  	}
47  
48  	/**
49  	 * Getter for the artists' last name.
50  	 * @return The last name of the artist.
51  	 */
52  	public String getLastName() {
53  		return _lastname;
54  	}
55  	
56  	/**
57  	 * Setter for the instrument list.
58  	 * @param instruments The instrument list to set.
59  	 */
60  	public void setInstruments(String instruments) {
61  		_instruments = instruments;
62  	}
63  	
64  	/**
65  	 * Getter for the instrument list.
66  	 * @return the instrument list.
67  	 */
68  	public String getInstruments() {
69  		return _instruments;
70  	}
71  
72  	/**
73  	 * Getter for the tracklist.
74  	 * @return The tracklist.
75  	 */
76  	public TrackList getTracklist() {
77  		return _tracks;
78  	}
79  
80  	/**
81  	 * Setter for the tracklist.
82  	 * @param tracks The tracklist.
83  	 */
84  	public void setTracklist(TrackList tracks) {
85  		this._tracks = tracks;
86  	}
87  	
88  	/*
89  	 * (non-Javadoc)
90  	 * @see java.lang.Object#equals(java.lang.Object)
91  	 */
92  	public boolean equals(Object o) {
93  		if (o instanceof AiRelationBean) {
94  			AiRelationBean other = (AiRelationBean) o;
95  
96  			return (_firstname==null ? other._firstname==null : _firstname.equals(other._firstname)) &&
97  			(_lastname==null ? other._lastname==null : _lastname.equals(other._lastname)) &&
98  			(_instruments==null ? other._instruments==null : _instruments.equals(other._instruments)) &&
99  			(_tracks==null ? other._tracks==null : _tracks.equals(other._tracks));
100 		} else {
101 			return false;
102 		}
103 	}
104 
105 	/*
106 	 * (non-Javadoc)
107 	 * @see java.lang.Comparable#compareTo(java.lang.Object)
108 	 */
109 	public int compareTo(AiRelationBean o) {
110 		if(getLastName()==null) {
111 			if(o.getLastName()==null) {
112 				return 0;
113 			} else {
114 				return -1;
115 			}
116 		}
117 		if(o.getLastName()==null) {
118 			return 1;
119 		}
120 		int compareLastNames = getLastName().compareTo(o.getLastName()); 
121 		if(compareLastNames==0) {
122 			if(getFirstName()==null) {
123 				if(o.getFirstName()==null) {
124 					return 0;
125 				} else {
126 					return -1;
127 				}
128 			}
129 			if(o.getFirstName()==null) {
130 				return 1;
131 			}
132 			return getFirstName().compareTo(o.getFirstName());
133 		} else {
134 			return compareLastNames;
135 		}
136 	}
137 		
138 }