瀏覽代碼

Reverted ab538cd21573de70aa7d100382a8a70c25eeccaf

JaniruTEC 4 年之前
父節點
當前提交
6b6867b826
共有 1 個文件被更改,包括 3 次插入24 次删除
  1. 3 24
      main/commons/src/main/java/org/cryptomator/common/mountpoint/MountPointChooser.java

+ 3 - 24
main/commons/src/main/java/org/cryptomator/common/mountpoint/MountPointChooser.java

@@ -1,6 +1,5 @@
 package org.cryptomator.common.mountpoint;
 
-import com.google.common.base.Preconditions;
 import org.cryptomator.common.vaults.Volume;
 
 import java.nio.file.Path;
@@ -155,31 +154,11 @@ public interface MountPointChooser extends Comparable<MountPointChooser> {
 	 * <p>{@inheritDoc}
 	 *
 	 * @implNote This default implementation sorts the MPCs in ascending order
-	 * of their {@link #getPriority() priority.} It depends on a correct implementation
-	 * of {@link #hashCode()} and {@link #equals(Object)} for the compared objects.
-	 * For this implementation "the least required correct implementation" maps
-	 * the following relationship correctly:<br>
-	 * If the objects {@code a} and {@code b} are {@code equal} as determined by
-	 * {@code #equals(Object)} then the {@code hashCodes} as determined by {@code #hashCode()}
-	 * of {@code a} and {@code b} must be equal. If the objects are {@code not equal}
-	 * then the {@code hashCodes} must be different.<br>
-	 * The default implementations of those two methods are sufficient.
-	 * @see Object#hashCode()
-	 * @see Object#equals(Object)
+	 * of their {@link #getPriority() priority.}
 	 */
 	@Override
 	default int compareTo(MountPointChooser other) {
-		Preconditions.checkNotNull(other, "Other must not be null!");
-
-		//Try to compare by priority and sort in ascending order.
-		//1) Compare the priorities.
-		//2) If the result of the comparison is 0 because the priorities are equal,
-		//   we consider this a failure. In this case sort by hashCode (step 3).
-		//   Else return the result of the comparison.
-		//3) Return the result of the comparison of the hashCodes:
-		//   Either 0 (because they are equal and that's why they had the same priority)
-		//   or a non-null int (because they only share the priority).
-		int compResult = /* 1 */ Integer.compare(this.getPriority(), other.getPriority());
-		return compResult != 0 ? /* 2 */ compResult : /* 3 */ Integer.compare(this.hashCode(), other.hashCode());
+		//Sort by priority (ascending order)
+		return Integer.compare(this.getPriority(), other.getPriority());
 	}
 }