Skip to content

Commit

Permalink
[JENKINS-18325] sort files by there name
Browse files Browse the repository at this point in the history
  • Loading branch information
imod committed Jul 21, 2013
1 parent 02fe423 commit 000e7cf
Showing 1 changed file with 15 additions and 2 deletions.
Expand Up @@ -6,9 +6,12 @@

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -29,13 +32,15 @@ public abstract class AbstractConfigProviderImpl extends ConfigProvider {
private static final Logger LOGGER = Logger.getLogger(AbstractConfigProviderImpl.class.getName());

protected Map<String, Config> configs = new HashMap<String, Config>();

public AbstractConfigProviderImpl() {
}

@Override
public Collection<Config> getAllConfigs() {
return Collections.unmodifiableCollection(configs.values());
List<Config> c = new ArrayList<Config>(configs.values());
Collections.sort(c, new NameComparator());
return Collections.unmodifiableCollection(c);
}

@Override
Expand Down Expand Up @@ -106,4 +111,12 @@ protected XmlFile getConfigXml() {
protected String getXmlFileName() {
return getId() + ".xml";
}

private static final class NameComparator implements Comparator<Config> {
public int compare(Config o1, Config o2) {
String a = o1.name != null ? o1.name : "";
String b = o2.name != null ? o2.name : "";
return a.compareTo(b);
}
}
}

0 comments on commit 000e7cf

Please sign in to comment.