1   /*
2    * Copyright 2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16   
17  
18  package org.apache.commons.betwixt.strategy;
19  
20  import java.util.ArrayList;
21  import java.util.Collection;
22  import java.util.Iterator;
23  
24  
25  /***
26   * @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a>
27   * @version $Revision: 1.2.2.1 $
28   */
29  public class TuneBean {
30  
31      private ArrayList composers = new ArrayList();
32      private String name;
33      private String artist;
34      private int recorded;
35      
36      public TuneBean() {}
37      public TuneBean(String name, String artist, int recorded) {
38          setName(name);
39          setArtist(artist);
40          setRecorded(recorded);
41      }
42   
43      public String getArtist() {
44          return artist;
45      }
46  
47      public Iterator getComposers() {
48          return composers.iterator();
49      }
50  
51      public String getName() {
52          return name;
53      }
54  
55      public int getRecorded() {
56          return recorded;
57      }
58  
59      public void setArtist(String string) {
60          artist = string;
61      }
62  
63      public void addComposer(ComposerBean composer) {
64          composers.add(composer);
65      }
66      
67      public void setName(String string) {
68          name = string;
69      }
70  
71      public void setRecorded(int i) {
72          recorded = i;
73      }
74  
75      public boolean sameComposers(Collection otherComposers) {
76                  // doesn't check cardinality but should be ok
77          if (otherComposers.size() != composers.size()) {
78              return false;
79          }
80          for (Iterator it=composers.iterator();it.hasNext();) {
81              Object object = it.next();
82              if (!otherComposers.contains(object)) {
83                  return false;
84              }
85          }
86          return true;
87      }
88  }