Package io.reacted.patterns
Class ObjectUtils
java.lang.Object
io.reacted.patterns.ObjectUtils
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic DurationcheckNonNullPositiveTimeInterval(Duration interval) Checks if the provided interval is non null and bigger thanDuration.ZEROstatic DurationcheckNonNullPositiveTimeIntervalWithLimit(Duration interval, long limitAmount, TimeUnit limitUnit) Checks if the provided interval is non null, bigger thanDuration.ZEROand smaller thanlimitAmountlimitUnitstatic PropertiesfromBytes(byte[] data) static <InputT,OutputT>
OutputTstatic <ReturnT,OnErrorT extends RuntimeException>
ReturnTrequiredCondition(ReturnT element, Predicate<ReturnT> controlPredicate, Supplier<OnErrorT> onControlPredicateFailure) static <ElementT extends Comparable<ElementT>,ExceptionT extends RuntimeException>
ElementTrequiredInRange(ElementT element, ElementT inclusiveRangeStart, ElementT inclusiveRangeEnd, Supplier<ExceptionT> onError) static <InputT> voidrunIfNotNull(InputT input, Consumer<InputT> ifNotNull) static byte[]toBytes(Properties properties)
-
Field Details
-
VOID
-
-
Method Details
-
ifNotNull
@Nullable public static <InputT,OutputT> OutputT ifNotNull(@Nullable InputT input, Function<InputT, OutputT> ifNotNull) -
runIfNotNull
-
checkNonNullPositiveTimeIntervalWithLimit
public static Duration checkNonNullPositiveTimeIntervalWithLimit(@Nullable Duration interval, long limitAmount, TimeUnit limitUnit) Checks if the provided interval is non null, bigger thanDuration.ZEROand smaller thanlimitAmountlimitUnit- Parameters:
interval- aDurationlimitAmount- inclusive upperbound of the allowed durationlimitUnit-TimeUnitof thelimitAmount- Returns:
- the argument provided
- Throws:
NullPointerException- if the provided argument is nullIllegalArgumentException- if the provided interval is not positive
-
checkNonNullPositiveTimeInterval
Checks if the provided interval is non null and bigger thanDuration.ZERO- Parameters:
interval- aDuration- Returns:
- the argument provided
- Throws:
NullPointerException- if the provided argument is nullIllegalArgumentException- if the provided interval is not positive
-
requiredInRange
public static <ElementT extends Comparable<ElementT>,ExceptionT extends RuntimeException> ElementT requiredInRange(ElementT element, ElementT inclusiveRangeStart, ElementT inclusiveRangeEnd, Supplier<ExceptionT> onError) -
requiredCondition
public static <ReturnT,OnErrorT extends RuntimeException> ReturnT requiredCondition(ReturnT element, Predicate<ReturnT> controlPredicate, Supplier<OnErrorT> onControlPredicateFailure) -
toBytes
- Throws:
IOException
-
fromBytes
- Throws:
IOException
-