Skip to content

Commit 8cc3cfc

Browse files
committed
LibraryInfo: introduced DirectoryPath API for the rest of paths
1 parent 6e1d2eb commit 8cc3cfc

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

snaploader/src/main/java/electrostatic4j/snaploader/LibraryInfo.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
*/
6161
public final class LibraryInfo {
6262

63-
private String jarPath;
64-
private String directory;
63+
private DirectoryPath jarPath;
64+
private DirectoryPath directory;
6565
private String baseName;
6666
private DirectoryPath directoryPath;
6767

@@ -71,25 +71,29 @@ public final class LibraryInfo {
7171
* @param directory the platform-independent directory inside the compression used for locating the native dynamic library,
7272
* this is used as a backup directory path
7373
* in case the {@link NativeDynamicLibrary#getPlatformDirectory()} is not valid.
74-
* @param baseName the library basename, for example, 'lib-basename.so'.
75-
* @param directoryPath the extraction destination in absolute string format, "null" if the current [user.dir] is
76-
* specified as the extraction directory
74+
* @param baseName the library basename, for example, 'lib-basename.so' (not null).
75+
* @param directoryPath the extraction destination path, {@link DirectoryPath#USER_DIR} for
76+
* a user working directory extraction path,
77+
* and {@link DirectoryPath#USER_HOME} for the user home (not null).
7778
*/
78-
public LibraryInfo(String directory, String baseName, DirectoryPath directoryPath) {
79-
this(null, directory, baseName, directoryPath);
79+
public LibraryInfo(DirectoryPath directory, String baseName, DirectoryPath directoryPath) {
80+
this(DirectoryPath.CLASS_PATH, directory, baseName, directoryPath);
8081
}
8182

8283
/**
8384
* Instantiates a library info data structure pointing to a library in an external jar with jarPath.
8485
*
85-
* @param jarPath a path to an external jar to locate the library inside, "null" to use the project jar (classpath).
86+
* @param jarPath a path to an external jar to locate the library inside, {@link DirectoryPath#CLASS_PATH} to assign the classpath routine
87+
* to the {@link electrostatic4j.snaploader.filesystem.FileLocator} API (not null).
8688
* @param directory the platform-independent directory inside the compression used for locating the native dynamic library,
8789
* this is used as a backup directory path
8890
* in case the {@link NativeDynamicLibrary#getPlatformDirectory()} is not valid.
89-
* @param baseName the library basename, for example, 'lib-basename.so'.
90-
* @param directoryPath the extraction destination in absolute string format
91+
* @param baseName the library basename, for example, 'lib-basename.so' (not null).
92+
* @param directoryPath the extraction destination path, {@link DirectoryPath#USER_DIR} for
93+
* a user working directory extraction path,
94+
* and {@link DirectoryPath#USER_HOME} for the user home (not null).
9195
*/
92-
public LibraryInfo(String jarPath, String directory, String baseName, DirectoryPath directoryPath) {
96+
public LibraryInfo(DirectoryPath jarPath, DirectoryPath directory, String baseName, DirectoryPath directoryPath) {
9397
this.jarPath = jarPath;
9498
this.directory = directory;
9599
this.baseName = baseName;
@@ -109,27 +113,25 @@ public String getBaseName() {
109113
* Retrieves the jar filesystem path, the jar is the compression used to locate the native dynamic library to
110114
* be extracted and loaded by {@link NativeBinaryLoader}.
111115
*
112-
* @return the jar absolute filesystem path in a string format, "null" if the classpath is specified instead of
113-
* an external jar compression
116+
* @return the jar absolute filesystem path object.
114117
*/
115-
public String getJarPath() {
118+
public DirectoryPath getJarPath() {
116119
return jarPath;
117120
}
118121

119122
/**
120123
* Retrieves the directory inside the compression used for locating the native dynamic library.
121124
*
122-
* @return the path to the dynamic library filesystem inside the compression, "null" if the
123-
* default variant-based directories are set to be used
125+
* @return the path to the dynamic library filesystem inside the compression.
124126
*/
125-
public String getDirectory() {
127+
public DirectoryPath getDirectory() {
126128
return directory;
127129
}
128130

129131
/**
130132
* Retrieves the extraction absolute directory.
131133
*
132-
* @return the extraction destination in absolute string format
134+
* @return the extraction destination path object.
133135
*/
134136
public DirectoryPath getExtractionDirectory() {
135137
return directoryPath;
@@ -139,21 +141,20 @@ public DirectoryPath getExtractionDirectory() {
139141
* Sets the absolute path to the jar filesystem to locate the native dynamic library to be
140142
* extracted and loaded, "null" to use the "classpath (the stock jar)"" to load the library filesystem.
141143
*
142-
* @param jarPath the absolute path to the jar filesystem to locate the library to be extracted, "null" to
143-
* use the "classpath" (aka. the stock jar)
144+
* @param jarPath the external jar path object to localize the compression, use {@link DirectoryPath#CLASS_PATH}
145+
* to switch the file locator to the classpath routine.
144146
*/
145-
public void setJarPath(String jarPath) {
147+
public void setJarPath(DirectoryPath jarPath) {
146148
this.jarPath = jarPath;
147149
}
148150

149151
/**
150152
* Sets the directory to the native dynamic library inside the jar compression, "null" to use
151153
* the default directories specified for each variant by {@link NativeBinaryLoader}.
152154
*
153-
* @param directory the location to the native dynamic library inside the jar compression, "null"
154-
* to use the default variant-based directories
155+
* @param directory the location to the native dynamic library inside the jar compression.
155156
*/
156-
public void setDirectory(String directory) {
157+
public void setDirectory(DirectoryPath directory) {
157158
this.directory = directory;
158159
}
159160

@@ -167,11 +168,10 @@ public void setBaseName(final String baseName) {
167168
}
168169

169170
/**
170-
* Sets the extraction directory used for extracting the native dynamic library in the
171-
* form of an absolute directory, "null" to use the current [user.dir].
171+
* Sets the extraction directory used for extracting the native dynamic library.
172172
*
173-
* @param directoryPath the absolute extraction directory to which the located library
174-
* will be extracted to
173+
* @param directoryPath the extraction directory path to which the native-located library
174+
* will be extracted to.
175175
*/
176176
public void setExtractionDirectory(DirectoryPath directoryPath) {
177177
this.directoryPath = directoryPath;

0 commit comments

Comments
 (0)