Skip to content

Commit

Permalink
Using Comparator.reverseOrder()
Browse files Browse the repository at this point in the history
  • Loading branch information
tweimer authored and mrotteveel committed Oct 20, 2023
1 parent 9063027 commit 6ba46dc
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions src/main/org/firebirdsql/gds/impl/GDSFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,13 @@
* @author Mark Rotteveel
*/
public final class GDSFactory {

/**
* Class for string comparison in the descendant order. This effectively
* puts the shortest JDBC URLs at the end of the list, so the correct
* default protocol handling can be implemented.
*/
private static final class ReversedStringComparator implements Comparator<String>, Serializable {

@Serial
private static final long serialVersionUID = 8861240319376746440L;

public int compare(String s1, String s2) {
// note, we compare here s2 to s1,
// this causes descending sorting
return s2.compareTo(s1);
}
}

private static final Set<GDSFactoryPlugin> registeredPlugins = new HashSet<>();
private static final Map<GDSType, GDSFactoryPlugin> typeToPluginMap = new HashMap<>();
private static final TreeMap<String, GDSFactoryPlugin> jdbcUrlToPluginMap = new TreeMap<>(new ReversedStringComparator());
/**
* This sorting effectively puts the shortest JDBC URLs at the end of the map,
* so the correct default protocol handling can be implemented.
*/
private static final TreeMap<String, GDSFactoryPlugin> jdbcUrlToPluginMap = new TreeMap<>(Comparator.reverseOrder());

private static GDSType defaultType;

Expand Down

0 comments on commit 6ba46dc

Please sign in to comment.