From e1ec588fe249e0f4e4309a2d16c71b8b9581328b Mon Sep 17 00:00:00 2001 From: DaCool <8727384-DaCool@users.noreply.gitlab.com> Date: Thu, 19 Oct 2023 10:33:48 +0000 Subject: [PATCH] Add javadoc --- .../com/sheepit/client/Configuration.java | 62 ++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sheepit/client/Configuration.java b/src/main/java/com/sheepit/client/Configuration.java index 67cb389..b07f849 100644 --- a/src/main/java/com/sheepit/client/Configuration.java +++ b/src/main/java/com/sheepit/client/Configuration.java @@ -39,6 +39,9 @@ import com.sheepit.client.os.OS; import lombok.AllArgsConstructor; import lombok.Data; +/** + * Provides facilities regarding the configuration of the SheepIt client + */ @AllArgsConstructor @Data public class Configuration { @@ -115,7 +118,9 @@ import lombok.Data; config.priority, config.computeMethod, config.GPUDevice, config.detectGPUs, config.printLog, config.requestTime, config.shutdownTime, config.shutdownMode, config.extras, config.autoSignIn, config.useSysTray, config.headless, config.UIType, config.hostname, config.theme); } - + /** + * @return string formatted with SheepIt Admin Log Viewer in mind + */ public String toString() { String c = " CFG: ", n ="\n"; return @@ -149,6 +154,11 @@ import lombok.Data; c + "theme: " + theme; } + /** + * Sets the priority that Blender will be started with + * @param priority integer that will be clamped between 19 and -19, + * lowest to highest in terms of priority + */ public void setUsePriority(int priority) { if (priority > 19) priority = 19; @@ -159,10 +169,18 @@ import lombok.Data; } + /** + * Returns ordinal integer of the computeMethod enum + * @return ordinal integer of the computeMethod enum + */ public int computeMethodToInt() { return this.computeMethod.ordinal(); } + /** + * Sets and optionally creates cache directory + * @param cache_dir_ File representing cache directory + */ public void setCacheDir(File cache_dir_) { removeWorkingDirectory(); if (cache_dir_ == null) { @@ -210,6 +228,9 @@ import lombok.Data; } } + /** + * @return the storage directory or the working directory if the former is not defined + */ public File getStorageDir() { if (this.storageDirectory == null) { return this.workingDirectory; @@ -219,6 +240,9 @@ import lombok.Data; } } + /** + * @return the user specified cache directory or null if it hasn't been specified + */ public File getCacheDirForSettings() { if (this.userHasSpecifiedACacheDir == false) { return null; @@ -229,6 +253,9 @@ import lombok.Data; } } + /** + * @return string-representation of the hostname or an empty string if an error was encountered + */ public String getDefaultHostname() { try { return InetAddress.getLocalHost().getHostName(); @@ -238,11 +265,19 @@ import lombok.Data; } } + /** + * Deletes the working and storage directories + */ public void cleanWorkingDirectory() { this.cleanDirectory(this.workingDirectory); this.cleanDirectory(this.storageDirectory); } + /** + * Cleans a directory and removes files in it from the md5 cache + * @param dir representing the directory to be cleaned + * @return false if the dir null, true otherwise + */ public boolean cleanDirectory(File dir) { if (dir == null) { return false; @@ -281,6 +316,9 @@ import lombok.Data; return true; } + /** + * Cleans working directory and also deletes it if the user hasn't specified a cache directory + */ public void removeWorkingDirectory() { if (this.userHasSpecifiedACacheDir) { this.cleanWorkingDirectory(); @@ -290,6 +328,10 @@ import lombok.Data; } } + /** + * @return a list of archives (files with extensions .zip or .wool) in the + * working, storage, and shared downloads directories as long as they are not null + */ public List getLocalCacheFiles() { List files_local = new LinkedList(); List files = new LinkedList(); @@ -337,7 +379,7 @@ import lombok.Data; * Runs through all SheepIt related directories and checks if files and folders are all readable, writeable * and in case of directories, checks if the contents can be listed and if usable space is enough. * Only logs instances where something was detected, otherwise is it will only print "FilesystemHealthCheck started" - * @return an ArrayList of Strings containing all of the logs of the FSHealth check + * @return an ArrayList of Strings containing all logs of the FSHealth check */ public ArrayList filesystemHealthCheck() { ArrayList logs = new ArrayList<>(); @@ -392,6 +434,10 @@ import lombok.Data; return logs; } + /** + * @return a string representing the version of the jar or + * {@code 6.0.0} if on error is encountered or the VERSION file doesn't exist + */ private static String getJarVersion() { String versionPath = "/VERSION"; String version = "6.0.0"; @@ -412,10 +458,22 @@ import lombok.Data; return version; } + /** + * @return true if operating system is in among the supported platforms + * and is running in a compatible configuration + * false otherwise + * @see OS#isSupported() + */ public boolean checkOSisSupported() { return OS.getOS() != null && OS.getOS().isSupported(); } + /** + * @return true if operating system is in among the supported platforms + * and if we have data on the cpu + * false otherwise + * @see CPU#haveData() + */ public boolean checkCPUisSupported() { OS os = OS.getOS(); if (os != null) {