-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
107 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.influxdb.impl; | ||
|
||
public final class Preconditions { | ||
|
||
private Preconditions() { | ||
} | ||
|
||
/** | ||
* Enforces that the string is {@linkplain String#isEmpty() not empty}. | ||
* @param string the string to test | ||
* @param name variable name for reporting | ||
* @return {@code string} | ||
* @throws IllegalArgumentException if the string is empty | ||
*/ | ||
public static String checkNonEmptyString(final String string, final String name) throws IllegalArgumentException { | ||
if (string == null || string.isEmpty()) { | ||
throw new IllegalArgumentException("Expecting a non-empty string for " + name); | ||
} | ||
return string; | ||
} | ||
|
||
/** | ||
* Enforces that the number is larger than 0. | ||
* @param number the number to test | ||
* @param name variable name for reporting | ||
* @throws IllegalArgumentException if the number is less or equal to 0 | ||
*/ | ||
public static void checkPositiveNumber(final Number number, final String name) throws IllegalArgumentException { | ||
if (number == null || number.doubleValue() <= 0) { | ||
throw new IllegalArgumentException("Expecting a positive number for " + name); | ||
} | ||
} | ||
} |
Oops, something went wrong.