Skip to content

Commit 72ae4b3

Browse files
- DEFAULT_MOUNT_POINT
+ MOUNT_TO_SYSTEM_CHOSEN_PATH + VOLUME_ID
1 parent 19048c4 commit 72ae4b3

File tree

3 files changed

+47
-32
lines changed

3 files changed

+47
-32
lines changed

src/main/java/org/cryptomator/integrations/mount/MountBuilder.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ public interface MountBuilder {
1515

1616
/**
1717
* Sets the mount point.
18+
* <p>
19+
* Unless the mount provide supports {@link MountFeature#MOUNT_TO_SYSTEM_CHOSEN_PATH}, setting a mount point is required.
1820
*
1921
* @param mountPoint Where to mount the volume
2022
* @return <code>this</code>
21-
* @see MountProvider#getDefaultMountPoint(String)
2223
*/
2324
@Contract("_ -> this")
24-
MountBuilder setMountpoint(Path mountPoint);
25+
default MountBuilder setMountpoint(Path mountPoint) {
26+
throw new UnsupportedOperationException();
27+
}
2528

2629
/**
2730
* Sets mount flags.
@@ -36,6 +39,18 @@ default MountBuilder setMountFlags(String mountFlags) {
3639
throw new UnsupportedOperationException();
3740
}
3841

42+
/**
43+
* Use the given TCP port.
44+
*
45+
* @param port Fixed TCP port or 0 to use a system-assigned port
46+
* @return <code>this</code>
47+
* @throws UnsupportedOperationException If {@link MountFeature#PORT} is not supported
48+
*/
49+
@Contract("_ -> this")
50+
default MountBuilder setPort(@Range(from = 0, to = Short.MAX_VALUE) int port) {
51+
throw new UnsupportedOperationException();
52+
}
53+
3954
/**
4055
* Instructs the mount to be read-only.
4156
*
@@ -49,18 +64,17 @@ default MountBuilder setReadOnly(boolean mountReadOnly) {
4964
}
5065

5166
/**
52-
* Use the given TCP port.
67+
* Sets a unique volume id.
5368
*
54-
* @param port fixed TCP port or 0 to use a system-assigned port
69+
* @param volumeId Volume id
5570
* @return <code>this</code>
56-
* @throws UnsupportedOperationException If {@link MountFeature#PORT} is not supported
71+
* @throws UnsupportedOperationException If {@link MountFeature#VOLUME_ID} is not supported
5772
*/
5873
@Contract("_ -> this")
59-
default MountBuilder setPort(@Range(from = 0, to = Short.MAX_VALUE) int port) {
74+
default MountBuilder setVolumeId(String volumeId) {
6075
throw new UnsupportedOperationException();
6176
}
6277

63-
6478
/**
6579
* Mounts the file system.
6680
*

src/main/java/org/cryptomator/integrations/mount/MountFeature.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.cryptomator.integrations.mount;
22

3+
import java.nio.file.Path;
4+
35
/**
46
* Describes what aspects of the mount implementation can or should be used.
57
* <p>
@@ -17,7 +19,7 @@ public enum MountFeature {
1719
* <p>
1820
* This option is mutually exclusive with {@link #MOUNT_WITHIN_EXISTING_PARENT}.
1921
*
20-
* @see #DEFAULT_MOUNT_POINT
22+
* @see #MOUNT_TO_SYSTEM_CHOSEN_PATH
2123
*/
2224
MOUNT_TO_EXISTING_DIR,
2325

@@ -27,7 +29,7 @@ public enum MountFeature {
2729
* <p>
2830
* This option is mutually exclusive with {@link #MOUNT_TO_EXISTING_DIR}.
2931
*
30-
* @see #DEFAULT_MOUNT_POINT
32+
* @see #MOUNT_TO_SYSTEM_CHOSEN_PATH
3133
*/
3234
MOUNT_WITHIN_EXISTING_PARENT,
3335

@@ -36,18 +38,23 @@ public enum MountFeature {
3638
*
3739
* @see #MOUNT_TO_EXISTING_DIR
3840
* @see #MOUNT_WITHIN_EXISTING_PARENT
41+
* @see #MOUNT_TO_SYSTEM_CHOSEN_PATH
3942
*/
4043
MOUNT_AS_DRIVE_LETTER,
4144

4245
/**
43-
* The provider supports suggesting a default mount point via {@link MountProvider#getDefaultMountPoint(String)}.
44-
* <p>
45-
* The default mount point is guaranteed to be supported by the mount builder, regardless of its normal restrictions.
46+
* The provider supports suggesting a default mount point, if no mount point is set via {@link MountBuilder#setMountpoint(Path)}.
4647
*/
47-
DEFAULT_MOUNT_POINT,
48+
MOUNT_TO_SYSTEM_CHOSEN_PATH,
4849

4950
/**
50-
* The builder supports {@link MountBuilder#setReadOnly(boolean)}
51+
* The provider supports {@link MountProvider#getDefaultPort()}
52+
* and the builder requires {@link MountBuilder#setPort(int)}.
53+
*/
54+
PORT,
55+
56+
/**
57+
* The builder supports {@link MountBuilder#setReadOnly(boolean)}.
5158
*/
5259
READ_ONLY,
5360

@@ -57,8 +64,7 @@ public enum MountFeature {
5764
UNMOUNT_FORCED,
5865

5966
/**
60-
* The provider supports {@link MountProvider#getDefaultPort()}
61-
* and the builder requires {@link MountBuilder#setPort(int)}.
67+
* The builder requires {@link MountBuilder#setVolumeId(String)}.
6268
*/
63-
PORT
69+
VOLUME_ID
6470
}

src/main/java/org/cryptomator/integrations/mount/MountProvider.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,6 @@ static Stream<MountProvider> get() {
4040
*/
4141
boolean isSupported();
4242

43-
/**
44-
* A suitable mount point suggested by this provider.
45-
* <p>
46-
* Other than caller-provided mount points, the mount point suggested by this method can be
47-
* passed to {@link MountBuilder#setMountpoint(Path)} and is guaranteed to fulfill the builder's requirements
48-
* without further ado.
49-
*
50-
* @param mountPointSuffix String used in the generation of a mount point.
51-
* @return A path to a possible mount point.
52-
* @throws UnsupportedOperationException If {@link MountFeature#DEFAULT_MOUNT_POINT} is not supported
53-
*/
54-
default Path getDefaultMountPoint(String mountPointSuffix) {
55-
throw new UnsupportedOperationException();
56-
}
57-
5843
/**
5944
* Default mount flags. May be empty.
6045
*
@@ -84,6 +69,16 @@ default int getDefaultPort() {
8469
*/
8570
Set<MountFeature> supportedFeatures();
8671

72+
/**
73+
* Tests whether this provider supports the given feature.
74+
*
75+
* @param feature The feature
76+
* @return {@code true} if supported
77+
*/
78+
default boolean supportsFeature(MountFeature feature) {
79+
return supportedFeatures().contains(feature);
80+
}
81+
8782

8883
/**
8984
* Creates a new mount builder.

0 commit comments

Comments
 (0)