Skip to content
This repository has been archived by the owner on May 1, 2021. It is now read-only.

Commit

Permalink
make methods static.
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbowdashlabs committed Jul 10, 2020
1 parent 3474913 commit a301867
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.eldoria</groupId>
<artifactId>eldo-utilities</artifactId>
<version>1.0.8</version>
<version>1.0.9</version>
<packaging>jar</packaging>
<name>Eldo Utilities</name>
<url>https://github.com/eldoriarpg/EldoUtilities/wiki</url>
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/de/eldoria/eldoutilities/utils/ArgumentUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import java.util.Optional;
import java.util.function.Function;

public class ArgumentUtils {
public final class ArgumentUtils {
private ArgumentUtils() {
throw new UnsupportedOperationException("This is a utility class!");
}

/**
* Get a string value or a default value when the index does not exists.
*
Expand All @@ -12,7 +16,7 @@ public class ArgumentUtils {
* @param defaultValue default value which will be returned when the index does not exists.
* @return string at index or default value if the index does not exists.
*/
public String getOrDefault(String[] arguments, int index, String defaultValue) {
public static String getOrDefault(String[] arguments, int index, String defaultValue) {
String arg = get(arguments, index);
return arg == null ? defaultValue : arg;
}
Expand All @@ -24,7 +28,7 @@ public String getOrDefault(String[] arguments, int index, String defaultValue) {
* @param index index of the requested parameter
* @return string or null if the index does not exists
*/
public String get(String[] arguments, int index) {
public static String get(String[] arguments, int index) {
if (arguments.length > index) return arguments[index];
return null;
}
Expand All @@ -39,7 +43,7 @@ public String get(String[] arguments, int index) {
* @param <T> type of optional return value
* @return the string of the index after the parse function was applied or a empty optional when the index was not found.
*/
public <T> Optional<T> get(String[] arguments, int index, Function<String, T> parse) {
public static <T> Optional<T> get(String[] arguments, int index, Function<String, T> parse) {
if (arguments.length > index) {
parse.apply(arguments[index]);
}
Expand All @@ -57,7 +61,7 @@ public <T> Optional<T> get(String[] arguments, int index, Function<String, T> pa
* @param <T> type of the returned parameter.
* @return parsed string value at index or default value if the index does not exists
*/
public <T> T getOptionalParameter(String[] arguments, int index, T defaultValue, Function<String, T> parse) {
public static <T> T getOptionalParameter(String[] arguments, int index, T defaultValue, Function<String, T> parse) {
String arg = get(arguments, index);
if (arg == null) return defaultValue;
return parse.apply(arg);
Expand Down

0 comments on commit a301867

Please sign in to comment.