File tree Expand file tree Collapse file tree
src/main/java/org/redlance/platformtools/impl Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ plugins {
55}
66
77base. archivesName = " PlatformTools"
8- version = " 1.0.2 "
8+ version = " 1.0.3 "
99group = " org.redlance"
1010
1111repositories {
Original file line number Diff line number Diff line change 44import org .jetbrains .annotations .Nullable ;
55import org .redlance .platformtools .PlatformFileReferer ;
66import org .redlance .platformtools .impl .macos .MacFileReferer ;
7+ import org .redlance .platformtools .impl .unsupported .UnsupportedPlatform ;
78import org .redlance .platformtools .impl .windows .WindowsFileReferer ;
89
910import 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
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments