View Javadoc
1   /*
2    * REPOWEB, repository manager.
3    *
4    * Terms of license - http://opensource.org/licenses/apachepl.php
5    */
6   package org.repoweb.model.file;
7   import org.repoweb.model.Group;
8   import org.repoweb.model.GroupList;
9   
10  import java.util.Arrays;
11  import java.util.Comparator;
12  import java.util.List;
13  /***
14   * Represente la liste des groupes.
15   */
16  class FGroupList implements GroupList {
17      private final Group[] _groups;
18  
19      FGroupList(Group[] groups) {
20          Arrays.sort(groups, new ByGroupIdComparator());
21          _groups = groups;
22      }
23  
24      public List getGroups() {
25          return Arrays.asList(_groups);
26      }
27  
28  
29      public Group getGroup(int idx) {
30          return _groups[idx];
31      }
32  
33  
34      public int getGroupCount() {
35          return _groups.length;
36      }
37  
38      private static class ByGroupIdComparator implements Comparator {
39          public int compare(Object o1, Object o2) {
40              return ((Group)o1).getGroupId().compareToIgnoreCase(((Group)o2).getGroupId());
41          }
42      }
43  }