~ubuntu-branches/ubuntu/quantal/netbeans/quantal

« back to all changes in this revision

Viewing changes to logger/uihandlerserver/src/java/org/netbeans/server/componentsmatch/Package.java

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
package org.netbeans.server.componentsmatch;
 
3
 
 
4
import java.util.Map;
 
5
import java.util.Set;
 
6
import java.util.TreeMap;
 
7
 
 
8
/**
 
9
 * Package with assigned components. 
 
10
 * @author pzajac
 
11
 */
 
12
public final class Package {
 
13
    Map<Component,Component> components = new TreeMap<Component,Component>();
 
14
    String name;
 
15
    
 
16
    Component firstComponent;
 
17
    /** Creates a new instance of Package */
 
18
    
 
19
    public Package(String name) {
 
20
        this.name = name;
 
21
    }
 
22
    
 
23
    public void addComponent(Component comp) {
 
24
        Component oldComp = components.get(comp);
 
25
        if (oldComp == null) {
 
26
            components.put(comp,comp);
 
27
        } else {
 
28
            oldComp.add(comp);
 
29
        }
 
30
        firstComponent = null;
 
31
    }
 
32
    
 
33
    /** @return component with bigger issues count
 
34
     */
 
35
    public Component getFirstComponent() {
 
36
        if (firstComponent == null) {
 
37
            for (Component c : components.keySet()) {
 
38
              if (firstComponent == null) {
 
39
                  firstComponent = c;
 
40
              } else if (c.getIssues() > firstComponent.getIssues()) {
 
41
                  firstComponent = c;
 
42
              }
 
43
            }
 
44
        }
 
45
        return firstComponent;
 
46
    }
 
47
    
 
48
    public String getName() {
 
49
        return name;
 
50
    }
 
51
    
 
52
    public Set<Component> getComponents() {
 
53
        return components.keySet();
 
54
    }
 
55
}