You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2018/03/18 13:57:11 UTC
[2/3] mina-sshd git commit: [SSHD-805] Using NavigableSet/Map return
types instead of SortedSet/Map where applicable
[SSHD-805] Using NavigableSet/Map return types instead of SortedSet/Map where applicable
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/404b9b00
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/404b9b00
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/404b9b00
Branch: refs/heads/master
Commit: 404b9b00d543b6ea18a864105cfe92c29b36a163
Parents: 54f2d7a
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Sun Mar 18 15:33:36 2018 +0200
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Sun Mar 18 15:33:36 2018 +0200
----------------------------------------------------------------------
.../java/org/apache/sshd/client/SshKeyScan.java | 7 +++---
.../sshd/common/cipher/BuiltinCiphers.java | 7 +++---
.../common/compression/BuiltinCompressions.java | 7 +++---
.../loader/PrivateKeyEncryptionContext.java | 4 ++--
.../sshd/common/kex/BuiltinDHFactories.java | 10 ++++----
.../org/apache/sshd/common/mac/BuiltinMacs.java | 10 ++++----
.../common/signature/BuiltinSignatures.java | 10 ++++----
.../apache/sshd/common/util/GenericUtils.java | 25 ++++++++++----------
8 files changed, 40 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/404b9b00/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java b/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java
index 5ded6bf..6aa7dbb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/SshKeyScan.java
@@ -48,9 +48,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.SortedSet;
+import java.util.SortedMap;
import java.util.TreeMap;
-import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
@@ -182,8 +181,8 @@ public class SshKeyScan implements Channel, Callable<Void>, ServerKeyVerifier, S
* key, so pre-create the factories map according to the selected
* key types
*/
- Map<String, List<NamedFactory<Signature>>> sigFactories = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
- SortedSet<String> sigTypes = new TreeSet<>(pairsMap.keySet());
+ SortedMap<String, List<NamedFactory<Signature>>> sigFactories = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ Collection<String> sigTypes = GenericUtils.asSortedSet(sigFactories.comparator(), pairsMap.keySet());
for (String kt : sigTypes) {
List<NamedFactory<Signature>> factories = resolveSignatureFactories(kt);
if (GenericUtils.isEmpty(factories)) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/404b9b00/sshd-core/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java b/sshd-core/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java
index fd0a59c..9bdc134 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java
@@ -26,6 +26,7 @@ import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
+import java.util.NavigableSet;
import java.util.Objects;
import java.util.Set;
import java.util.SortedSet;
@@ -160,8 +161,8 @@ public enum BuiltinCiphers implements CipherFactory {
*
* @param extension The factory to register
* @throws IllegalArgumentException if factory instance is {@code null},
- * or overrides a built-in one or overrides another registered factory
- * with the same name (case <U>insensitive</U>).
+ * or overrides a built-in one or overrides another registered factory
+ * with the same name (case <U>insensitive</U>).
*/
public static void registerExtension(CipherFactory extension) {
String name = Objects.requireNonNull(extension, "No extension provided").getName();
@@ -177,7 +178,7 @@ public enum BuiltinCiphers implements CipherFactory {
* @return A {@link SortedSet} of the currently registered extensions, sorted
* according to the factory name (case <U>insensitive</U>)
*/
- public static SortedSet<CipherFactory> getRegisteredExtensions() {
+ public static NavigableSet<CipherFactory> getRegisteredExtensions() {
synchronized (EXTENSIONS) {
return GenericUtils.asSortedSet(NamedResource.BY_NAME_COMPARATOR, EXTENSIONS.values());
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/404b9b00/sshd-core/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java b/sshd-core/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java
index c7bc541..f0eac3e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java
@@ -26,6 +26,7 @@ import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
+import java.util.NavigableSet;
import java.util.Objects;
import java.util.Set;
import java.util.SortedSet;
@@ -112,8 +113,8 @@ public enum BuiltinCompressions implements CompressionFactory {
*
* @param extension The factory to register
* @throws IllegalArgumentException if factory instance is {@code null},
- * or overrides a built-in one or overrides another registered factory
- * with the same name (case <U>insensitive</U>).
+ * or overrides a built-in one or overrides another registered factory
+ * with the same name (case <U>insensitive</U>).
*/
public static void registerExtension(CompressionFactory extension) {
String name = Objects.requireNonNull(extension, "No extension provided").getName();
@@ -129,7 +130,7 @@ public enum BuiltinCompressions implements CompressionFactory {
* @return A {@link SortedSet} of the currently registered extensions, sorted
* according to the factory name (case <U>insensitive</U>)
*/
- public static SortedSet<CompressionFactory> getRegisteredExtensions() {
+ public static NavigableSet<CompressionFactory> getRegisteredExtensions() {
synchronized (EXTENSIONS) {
return GenericUtils.asSortedSet(NamedResource.BY_NAME_COMPARATOR, EXTENSIONS.values());
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/404b9b00/sshd-core/src/main/java/org/apache/sshd/common/config/keys/loader/PrivateKeyEncryptionContext.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/loader/PrivateKeyEncryptionContext.java b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/loader/PrivateKeyEncryptionContext.java
index 4c7b50e..f4f4cda 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/config/keys/loader/PrivateKeyEncryptionContext.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/config/keys/loader/PrivateKeyEncryptionContext.java
@@ -24,8 +24,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.NavigableMap;
+import java.util.NavigableSet;
import java.util.Objects;
-import java.util.SortedSet;
import java.util.TreeMap;
import org.apache.sshd.common.util.GenericUtils;
@@ -170,7 +170,7 @@ public class PrivateKeyEncryptionContext implements Cloneable {
}
}
- public static final SortedSet<String> getRegisteredPrivateKeyObfuscatorCiphers() {
+ public static final NavigableSet<String> getRegisteredPrivateKeyObfuscatorCiphers() {
synchronized (OBFUSCATORS) {
Collection<String> names = OBFUSCATORS.keySet();
return GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER, names);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/404b9b00/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java
index e919e6b..89c5a1b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java
@@ -27,9 +27,9 @@ import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
+import java.util.NavigableSet;
import java.util.Objects;
import java.util.Set;
-import java.util.SortedSet;
import java.util.TreeMap;
import org.apache.sshd.common.NamedResource;
@@ -260,8 +260,8 @@ public enum BuiltinDHFactories implements DHFactory {
*
* @param extension The factory to register
* @throws IllegalArgumentException if factory instance is {@code null},
- * or overrides a built-in one or overrides another registered factory
- * with the same name (case <U>insensitive</U>).
+ * or overrides a built-in one or overrides another registered factory
+ * with the same name (case <U>insensitive</U>).
*/
public static void registerExtension(DHFactory extension) {
String name = Objects.requireNonNull(extension, "No extension provided").getName();
@@ -274,10 +274,10 @@ public enum BuiltinDHFactories implements DHFactory {
}
/**
- * @return A {@link SortedSet} of the currently registered extensions, sorted
+ * @return A {@link NavigableSet} of the currently registered extensions, sorted
* according to the factory name (case <U>insensitive</U>)
*/
- public static SortedSet<DHFactory> getRegisteredExtensions() {
+ public static NavigableSet<DHFactory> getRegisteredExtensions() {
synchronized (EXTENSIONS) {
return GenericUtils.asSortedSet(NamedResource.BY_NAME_COMPARATOR, EXTENSIONS.values());
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/404b9b00/sshd-core/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java b/sshd-core/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java
index 0c8b034..80350b7 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java
@@ -26,9 +26,9 @@ import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
+import java.util.NavigableSet;
import java.util.Objects;
import java.util.Set;
-import java.util.SortedSet;
import java.util.TreeMap;
import org.apache.sshd.common.NamedFactory;
@@ -111,8 +111,8 @@ public enum BuiltinMacs implements MacFactory {
*
* @param extension The factory to register
* @throws IllegalArgumentException if factory instance is {@code null},
- * or overrides a built-in one or overrides another registered factory
- * with the same name (case <U>insensitive</U>).
+ * or overrides a built-in one or overrides another registered factory
+ * with the same name (case <U>insensitive</U>).
*/
public static void registerExtension(MacFactory extension) {
String name = Objects.requireNonNull(extension, "No extension provided").getName();
@@ -125,10 +125,10 @@ public enum BuiltinMacs implements MacFactory {
}
/**
- * @return A {@link SortedSet} of the currently registered extensions, sorted
+ * @return A {@link NavigableSet} of the currently registered extensions, sorted
* according to the factory name (case <U>insensitive</U>)
*/
- public static SortedSet<MacFactory> getRegisteredExtensions() {
+ public static NavigableSet<MacFactory> getRegisteredExtensions() {
synchronized (EXTENSIONS) {
return GenericUtils.asSortedSet(NamedResource.BY_NAME_COMPARATOR, EXTENSIONS.values());
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/404b9b00/sshd-core/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java b/sshd-core/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java
index d6b2bac..7d4e1e2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java
@@ -27,9 +27,9 @@ import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
+import java.util.NavigableSet;
import java.util.Objects;
import java.util.Set;
-import java.util.SortedSet;
import java.util.TreeMap;
import org.apache.sshd.common.NamedFactory;
@@ -148,8 +148,8 @@ public enum BuiltinSignatures implements SignatureFactory {
*
* @param extension The factory to register
* @throws IllegalArgumentException if factory instance is {@code null},
- * or overrides a built-in one or overrides another registered factory
- * with the same name (case <U>insensitive</U>).
+ * or overrides a built-in one or overrides another registered factory
+ * with the same name (case <U>insensitive</U>).
*/
public static void registerExtension(SignatureFactory extension) {
String name = Objects.requireNonNull(extension, "No extension provided").getName();
@@ -162,10 +162,10 @@ public enum BuiltinSignatures implements SignatureFactory {
}
/**
- * @return A {@link SortedSet} of the currently registered extensions, sorted
+ * @return A {@link NavigableSet} of the currently registered extensions, sorted
* according to the factory name (case <U>insensitive</U>)
*/
- public static SortedSet<SignatureFactory> getRegisteredExtensions() {
+ public static NavigableSet<SignatureFactory> getRegisteredExtensions() {
synchronized (EXTENSIONS) {
return GenericUtils.asSortedSet(NamedResource.BY_NAME_COMPARATOR, EXTENSIONS.values());
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/404b9b00/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java b/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
index 99a0768..4646e5c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/GenericUtils.java
@@ -34,11 +34,10 @@ import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.Objects;
import java.util.Set;
-import java.util.SortedMap;
-import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.ExecutionException;
@@ -432,12 +431,12 @@ public final class GenericUtils {
return stream(values).map(mapper).collect(toSortedSet(comparator));
}
- public static <T, K, U> SortedMap<K, U> toSortedMap(
+ public static <T, K, U> NavigableMap<K, U> toSortedMap(
Iterable<T> values, Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper, Comparator<K> comparator) {
return stream(values).collect(toSortedMap(keyMapper, valueMapper, comparator));
}
- public static <T, K, U> Collector<T, ?, SortedMap<K, U>> toSortedMap(
+ public static <T, K, U> Collector<T, ?, NavigableMap<K, U>> toSortedMap(
Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper, Comparator<K> comparator) {
return Collectors.toMap(keyMapper, valueMapper, throwingMerger(), () -> new TreeMap<>(comparator));
}
@@ -490,11 +489,11 @@ public final class GenericUtils {
}
@SafeVarargs
- public static <V extends Comparable<V>> SortedSet<V> asSortedSet(V... values) {
+ public static <V extends Comparable<V>> NavigableSet<V> asSortedSet(V... values) {
return asSortedSet(Comparator.naturalOrder(), values);
}
- public static <V extends Comparable<V>> SortedSet<V> asSortedSet(Collection<? extends V> values) {
+ public static <V extends Comparable<V>> NavigableSet<V> asSortedSet(Collection<? extends V> values) {
return asSortedSet(Comparator.naturalOrder(), values);
}
@@ -502,11 +501,11 @@ public final class GenericUtils {
* @param <V> The element type
* @param comp The (non-{@code null}) {@link Comparator} to use
* @param values The values to be added (ignored if {@code null})
- * @return A {@link SortedSet} containing the values (if any) sorted
+ * @return A {@link NavigableSet} containing the values (if any) sorted
* using the provided comparator
*/
@SafeVarargs
- public static <V> SortedSet<V> asSortedSet(Comparator<? super V> comp, V... values) {
+ public static <V> NavigableSet<V> asSortedSet(Comparator<? super V> comp, V... values) {
return asSortedSet(comp, isEmpty(values) ? Collections.emptyList() : Arrays.asList(values));
}
@@ -514,11 +513,11 @@ public final class GenericUtils {
* @param <V> The element type
* @param comp The (non-{@code null}) {@link Comparator} to use
* @param values The values to be added (ignored if {@code null}/empty)
- * @return A {@link SortedSet} containing the values (if any) sorted
+ * @return A {@link NavigableSet} containing the values (if any) sorted
* using the provided comparator
*/
- public static <V> SortedSet<V> asSortedSet(Comparator<? super V> comp, Collection<? extends V> values) {
- SortedSet<V> set = new TreeSet<>(Objects.requireNonNull(comp, "No comparator"));
+ public static <V> NavigableSet<V> asSortedSet(Comparator<? super V> comp, Collection<? extends V> values) {
+ NavigableSet<V> set = new TreeSet<>(Objects.requireNonNull(comp, "No comparator"));
if (size(values) > 0) {
set.addAll(values);
}
@@ -527,11 +526,11 @@ public final class GenericUtils {
/**
* @param <V> Type of mapped value
- * @return A {@link Supplier} that returns a <U>new</U> {@link SortedMap}
+ * @return A {@link Supplier} that returns a <U>new</U> {@link NavigableMap}
* whenever its {@code get()} method is invoked
*/
@SuppressWarnings("unchecked")
- public static <V> Supplier<SortedMap<String, V>> caseInsensitiveMap() {
+ public static <V> Supplier<NavigableMap<String, V>> caseInsensitiveMap() {
return CASE_INSENSITIVE_MAP_FACTORY;
}