Skip to content

Commit ff545e6

Browse files
committed
Mark unsupported platforms
1 parent dd4f893 commit ff545e6

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
base.archivesName = "PlatformTools"
8-
version = "1.0.2"
8+
version = "1.0.3"
99
group = "org.redlance"
1010

1111
repositories {

src/main/java/org/redlance/platformtools/impl/PlatformFileRefererImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.jetbrains.annotations.Nullable;
55
import org.redlance.platformtools.PlatformFileReferer;
66
import org.redlance.platformtools.impl.macos.MacFileReferer;
7+
import org.redlance.platformtools.impl.unsupported.UnsupportedPlatform;
78
import org.redlance.platformtools.impl.windows.WindowsFileReferer;
89

910
import java.io.IOException;
@@ -12,7 +13,7 @@ public class PlatformFileRefererImpl implements PlatformFileReferer {
1213
private final PlatformFileReferer nativePlatformReferer = switch (Platform.getOSType()) {
1314
case Platform.WINDOWS -> new WindowsFileReferer();
1415
case Platform.MAC -> new MacFileReferer();
15-
default -> null;
16+
default -> UnsupportedPlatform.INSTANCE;
1617
};
1718

1819
@Override

src/main/java/org/redlance/platformtools/impl/TestingApp.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ private void onChooseFile(ActionEvent e) {
5353
try {
5454
String referrer = PlatformFileReferer.INSTANCE.getFileReferer(fileChooser.getSelectedFile());
5555
this.referrerLabel.setText("Referrer: " + referrer);
56+
System.out.println(referrer);
5657
} catch (IOException ex) {
5758
throw new RuntimeException(ex);
5859
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.redlance.platformtools.impl.unsupported;
2+
3+
import com.sun.jna.Platform;
4+
import org.redlance.platformtools.PlatformFileReferer;
5+
6+
public final class UnsupportedPlatform implements PlatformFileReferer {
7+
private static final String UNSUPPORTED_STRING = String.format("Unsupported platform: %s", Platform.getOSType());
8+
public static final UnsupportedPlatform INSTANCE = new UnsupportedPlatform();
9+
10+
private UnsupportedPlatform() {}
11+
12+
@Override
13+
public String getFileReferer(String path) {
14+
return UNSUPPORTED_STRING;
15+
}
16+
}

0 commit comments

Comments
 (0)