Class PortablePreconditions


  • public class PortablePreconditions
    extends java.lang.Object
    Created by tonirikkola on 7.8.2018.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected PortablePreconditions()
      Should not be instantiated
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkCondition​(java.lang.String name, boolean condition)
      Assert that this parameter is marked as valid by the condition passed as parameter.
      static <T> void checkEachParameterNotNull​(java.lang.String name, T... parameters)
      Assert that this parameter is not null, as also each item of the array is not null.
      static java.lang.String checkNotEmpty​(java.lang.String name, java.lang.String parameter)
      Assert that this parameter is not empty.
      static void checkNotEmpty​(java.lang.String name, java.util.Map<?,​?> parameter)
      Assert that this parameter is not empty.
      static <T extends java.util.Collection<?>>
      T
      checkNotEmpty​(java.lang.String name, T parameter)
      Assert that this parameter is not empty.
      static <T> T[] checkNotEmpty​(java.lang.String name, T[] parameter)
      Assert that this parameter is not empty.
      static <T> T checkNotNull​(java.lang.String name, T parameter)
      Assert that this parameter is not null.
      static void checkNullMandatory​(java.lang.String name, java.lang.Object parameter)
      Assert that this parameter is null.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PortablePreconditions

        protected PortablePreconditions()
        Should not be instantiated
    • Method Detail

      • checkCondition

        public static void checkCondition​(java.lang.String name,
                                          boolean condition)
        Assert that this parameter is marked as valid by the condition passed as parameter.
        Parameters:
        name - of parameter
        condition - itself
      • checkEachParameterNotNull

        public static <T> void checkEachParameterNotNull​(java.lang.String name,
                                                         T... parameters)
        Assert that this parameter is not null, as also each item of the array is not null.
        Type Parameters:
        T - parameter type
        Parameters:
        name - of parameter
        parameters - itself
      • checkNotEmpty

        public static <T extends java.util.Collection<?>> T checkNotEmpty​(java.lang.String name,
                                                                          T parameter)
        Assert that this parameter is not empty. It will test for null and also the size of this array.
        Parameters:
        name - of parameter
        parameter - itself
      • checkNotEmpty

        public static void checkNotEmpty​(java.lang.String name,
                                         java.util.Map<?,​?> parameter)
        Assert that this parameter is not empty. It will test for null and also the size of this array.
        Parameters:
        name - of parameter
        parameter - itself
      • checkNotEmpty

        public static java.lang.String checkNotEmpty​(java.lang.String name,
                                                     java.lang.String parameter)
        Assert that this parameter is not empty. It trims the parameter to see if have any valid data on that.
        Parameters:
        name - of parameter
        parameter - itself
      • checkNotEmpty

        public static <T> T[] checkNotEmpty​(java.lang.String name,
                                            T[] parameter)
        Assert that this parameter is not empty. It will test for null and also the size of this array.
        Type Parameters:
        T - type of the array
        Parameters:
        name - of parameter
        parameter - itself
      • checkNotNull

        public static <T> T checkNotNull​(java.lang.String name,
                                         T parameter)
        Assert that this parameter is not null.
        Parameters:
        name - of parameter
        parameter - itself
      • checkNullMandatory

        public static void checkNullMandatory​(java.lang.String name,
                                              java.lang.Object parameter)
        Assert that this parameter is null.
        Parameters:
        name - of parameter
        parameter - itself