Class ObjectUtils

java.lang.Object
io.reacted.patterns.ObjectUtils

public final class ObjectUtils extends Object
  • Field Details

    • VOID

      @Nullable public static final Void VOID
  • Method Details

    • ifNotNull

      @Nullable public static <InputT, OutputT> OutputT ifNotNull(@Nullable InputT input, Function<InputT,OutputT> ifNotNull)
    • runIfNotNull

      public static <InputT> void runIfNotNull(@Nullable InputT input, Consumer<InputT> ifNotNull)
    • checkNonNullPositiveTimeIntervalWithLimit

      public static Duration checkNonNullPositiveTimeIntervalWithLimit(@Nullable Duration interval, long limitAmount, TimeUnit limitUnit)
      Checks if the provided interval is non null, bigger than Duration.ZERO and smaller than limitAmount limitUnit
      Parameters:
      interval - a Duration
      limitAmount - inclusive upperbound of the allowed duration
      limitUnit - TimeUnit of the limitAmount
      Returns:
      the argument provided
      Throws:
      NullPointerException - if the provided argument is null
      IllegalArgumentException - if the provided interval is not positive
    • checkNonNullPositiveTimeInterval

      public static Duration checkNonNullPositiveTimeInterval(@Nullable Duration interval)
      Checks if the provided interval is non null and bigger than Duration.ZERO
      Parameters:
      interval - a Duration
      Returns:
      the argument provided
      Throws:
      NullPointerException - if the provided argument is null
      IllegalArgumentException - 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

      public static byte[] toBytes(Properties properties) throws IOException
      Throws:
      IOException
    • fromBytes

      public static Properties fromBytes(byte[] data) throws IOException
      Throws:
      IOException