Package me.ahoo.cosid.internal
Class Checks
java.lang.Object
me.ahoo.cosid.internal.Checks
Argument, state and null checks, and the small string helpers they need, without Guava. Messages use
%s
placeholders like Guava's Preconditions.
Internal to CosId: not part of the public API.
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckArgument(boolean expression) Checks an argument.static voidcheckArgument(boolean expression, @Nullable String template, long arg) Checks an argument without boxing or allocating when it holds: for hot paths.static voidcheckArgument(boolean expression, @Nullable String template, long arg1, long arg2) Checks an argument without boxing or allocating when it holds: for hot paths.static voidcheckArgument(boolean expression, @Nullable String template, @Nullable Object... args) Checks an argument.static voidcheckArgument(boolean expression, @Nullable String template, @Nullable Object arg1, @Nullable Object arg2) Checks an argument without allocating an array when it holds: for hot paths.static <T> TcheckNotNull(T reference) Checks that a reference is not null.static <T> TcheckNotNull(T reference, @Nullable String template, @Nullable Object... args) Checks that a reference is not null.static voidcheckState(boolean expression, @Nullable String template, @Nullable Object... args) Checks a state.static ThreadFactorydaemonThreadFactory(String name) A factory of daemon threads with the given name.static booleanisNullOrEmpty(@Nullable String string) static StringlenientFormat(@Nullable String template, @Nullable Object... args) Replaces each%sintemplatewith the next argument; arguments left over are appended in square brackets.static StringLeft-padsstringwithpadChartominLength.static StringClassName{name=value, ...}, the format of Guava'sMoreObjects.toStringHelper.
-
Method Details
-
checkArgument
public static void checkArgument(boolean expression, @Nullable String template, @Nullable Object... args) Checks an argument.- Throws:
IllegalArgumentException- with the formatted message ifexpressionis false
-
checkArgument
Checks an argument without boxing or allocating when it holds: for hot paths.- Throws:
IllegalArgumentException- with the formatted message ifexpressionis false
-
checkArgument
public static void checkArgument(boolean expression, @Nullable String template, long arg1, long arg2) Checks an argument without boxing or allocating when it holds: for hot paths.- Throws:
IllegalArgumentException- with the formatted message ifexpressionis false
-
checkArgument
public static void checkArgument(boolean expression, @Nullable String template, @Nullable Object arg1, @Nullable Object arg2) Checks an argument without allocating an array when it holds: for hot paths.- Throws:
IllegalArgumentException- with the formatted message ifexpressionis false
-
checkArgument
public static void checkArgument(boolean expression) Checks an argument.- Throws:
IllegalArgumentException- ifexpressionis false
-
checkState
public static void checkState(boolean expression, @Nullable String template, @Nullable Object... args) Checks a state.- Throws:
IllegalStateException- with the formatted message ifexpressionis false
-
checkNotNull
Checks that a reference is not null.- Returns:
reference- Throws:
NullPointerException- with the formatted message ifreferenceis null
-
checkNotNull
public static <T> T checkNotNull(T reference) Checks that a reference is not null.- Returns:
reference- Throws:
NullPointerException- ifreferenceis null
-
isNullOrEmpty
-
padStart
Left-padsstringwithpadChartominLength. -
lenientFormat
Replaces each%sintemplatewith the next argument; arguments left over are appended in square brackets. The same behavior as Guava'sStrings.lenientFormat. -
toString
ClassName{name=value, ...}, the format of Guava'sMoreObjects.toStringHelper. -
daemonThreadFactory
A factory of daemon threads with the given name. A%din the name is replaced by a counter starting at 0.
-