View Javadoc
1   /**
2    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3    *
4    * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
5    * Portions Copyright 2013-2019 Philip Helger + contributors
6    *
7    * The contents of this file are subject to the terms of either the GNU
8    * General Public License Version 2 only ("GPL") or the Common Development
9    * and Distribution License("CDDL") (collectively, the "License").  You
10   * may not use this file except in compliance with the License.  You can
11   * obtain a copy of the License at
12   * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
13   * or packager/legal/LICENSE.txt.  See the License for the specific
14   * language governing permissions and limitations under the License.
15   *
16   * When distributing the software, include this License Header Notice in each
17   * file and include the License file at packager/legal/LICENSE.txt.
18   *
19   * GPL Classpath Exception:
20   * Oracle designates this particular file as subject to the "Classpath"
21   * exception as provided by Oracle in the GPL Version 2 section of the License
22   * file that accompanied this code.
23   *
24   * Modifications:
25   * If applicable, add the following below the License Header, with the fields
26   * enclosed by brackets [] replaced by your own identifying information:
27   * "Portions Copyright [year] [name of copyright owner]"
28   *
29   * Contributor(s):
30   * If you wish your version of this file to be governed by only the CDDL or
31   * only the GPL Version 2, indicate your decision by adding "[Contributor]
32   * elects to include this software in this distribution under the [CDDL or GPL
33   * Version 2] license."  If you don't indicate a single choice of license, a
34   * recipient has the option to distribute your version of this file under
35   * either the CDDL, the GPL Version 2 or to extend the choice of license to
36   * its licensees as provided above.  However, if you add GPL Version 2 code
37   * and therefore, elected the GPL Version 2 license, then the option applies
38   * only if the new code is made subject to such option by the copyright
39   * holder.
40   */
41  package com.helger.jcodemodel.util;
42  
43  import java.math.BigDecimal;
44  import java.math.BigInteger;
45  import java.util.Collection;
46  import java.util.Map;
47  import java.util.concurrent.atomic.AtomicBoolean;
48  import java.util.function.Supplier;
49  
50  import javax.annotation.Nonnegative;
51  import javax.annotation.Nonnull;
52  import javax.annotation.Nullable;
53  import javax.annotation.concurrent.Immutable;
54  
55  @Immutable
56  public final class JCValueEnforcer
57  {
58    private static final AtomicBoolean s_aEnabled = new AtomicBoolean (true);
59  
60    private JCValueEnforcer ()
61    {}
62  
63    /**
64     * @return <code>true</code> if the assertions are enabled, <code>false</code>
65     *         otherwise. By default the checks are enabled.
66     */
67    public static boolean isEnabled ()
68    {
69      return s_aEnabled.get ();
70    }
71  
72    /**
73     * Enable or disable the checks. By default checks are enabled.
74     *
75     * @param bEnabled
76     *        <code>true</code> to enable it, <code>false</code> otherwise.
77     */
78    public static void setEnabled (final boolean bEnabled)
79    {
80      s_aEnabled.set (bEnabled);
81    }
82  
83    /**
84     * Check that the passed value is <code>true</code>.
85     *
86     * @param bValue
87     *        The value to check.
88     * @param sMsg
89     *        The message to be emitted in case the value is <code>false</code>
90     * @throws IllegalArgumentException
91     *         if the passed value is not <code>null</code>.
92     */
93    public static void isTrue (final boolean bValue, final String sMsg)
94    {
95      isTrue (bValue, () -> sMsg);
96    }
97  
98    /**
99     * Check that the passed value is <code>true</code>.
100    *
101    * @param bValue
102    *        The value to check.
103    * @param aMsg
104    *        The message to be emitted in case the value is <code>false</code>
105    * @throws IllegalArgumentException
106    *         if the passed value is not <code>null</code>.
107    */
108   public static void isTrue (final boolean bValue, @Nonnull final Supplier <? extends String> aMsg)
109   {
110     if (isEnabled ())
111       if (!bValue)
112         throw new IllegalArgumentException ("The expression must be true but it is not: " + aMsg.get ());
113   }
114 
115   /**
116    * Check that the passed value is <code>false</code>.
117    *
118    * @param bValue
119    *        The value to check.
120    * @param sMsg
121    *        The message to be emitted in case the value is <code>true</code>
122    * @throws IllegalArgumentException
123    *         if the passed value is not <code>null</code>.
124    */
125   public static void isFalse (final boolean bValue, final String sMsg)
126   {
127     isFalse (bValue, () -> sMsg);
128   }
129 
130   /**
131    * Check that the passed value is <code>false</code>.
132    *
133    * @param bValue
134    *        The value to check.
135    * @param aMsg
136    *        The message to be emitted in case the value is <code>true</code>
137    * @throws IllegalArgumentException
138    *         if the passed value is not <code>null</code>.
139    */
140   public static void isFalse (final boolean bValue, @Nonnull final Supplier <? extends String> aMsg)
141   {
142     if (isEnabled ())
143       if (bValue)
144         throw new IllegalArgumentException ("The expression must be false but it is not: " + aMsg.get ());
145   }
146 
147   /**
148    * Check that the passed value is an instance of the passed class.
149    *
150    * @param aValue
151    *        The value to check. May be <code>null</code>.
152    * @param aClass
153    *        The class of which the passed value must be an instance. May not be
154    *        <code>null</code>.
155    * @param sMsg
156    *        The message to be emitted in case the value is <code>false</code>
157    * @throws IllegalArgumentException
158    *         if the passed value is not <code>null</code>.
159    * @param <T>
160    *        Type to check.
161    */
162   public static <T> void isInstanceOf (@Nullable final T aValue,
163                                        @Nonnull final Class <? extends T> aClass,
164                                        final String sMsg)
165   {
166     isInstanceOf (aValue, aClass, () -> sMsg);
167   }
168 
169   /**
170    * Check that the passed value is an instance of the passed class.
171    *
172    * @param aValue
173    *        The value to check. May be <code>null</code>.
174    * @param aClass
175    *        The class of which the passed value must be an instance. May not be
176    *        <code>null</code>.
177    * @param aMsg
178    *        The message to be emitted in case the value is <code>false</code>
179    * @throws IllegalArgumentException
180    *         if the passed value is not <code>null</code>.
181    * @param <T>
182    *        Type to check.
183    */
184   public static <T> void isInstanceOf (@Nullable final T aValue,
185                                        @Nonnull final Class <? extends T> aClass,
186                                        @Nonnull final Supplier <? extends String> aMsg)
187   {
188     notNull (aClass, "Class");
189     if (isEnabled ())
190       if (!aClass.isInstance (aValue))
191         throw new IllegalArgumentException (aMsg.get () +
192                                             " must be of class " +
193                                             aClass.getName () +
194                                             " but is of type " +
195                                             aValue.getClass ().getName ());
196   }
197 
198   /**
199    * Check that the passed value is not <code>null</code>.
200    *
201    * @param <T>
202    *        Type to be checked and returned
203    * @param aValue
204    *        The value to check.
205    * @param sName
206    *        The name of the value (e.g. the parameter name)
207    * @return The passed value.
208    * @throws NullPointerException
209    *         if the passed value is <code>null</code>.
210    */
211   public static <T> T notNull (final T aValue, final String sName)
212   {
213     if (isEnabled ())
214       if (aValue == null)
215         throw new NullPointerException ("The value of '" + sName + "' may not be null!");
216     return aValue;
217   }
218 
219   /**
220    * Check that the passed value is not <code>null</code>.
221    *
222    * @param <T>
223    *        Type to be checked and returned
224    * @param aValue
225    *        The value to check.
226    * @param aName
227    *        The name of the value (e.g. the parameter name)
228    * @return The passed value.
229    * @throws NullPointerException
230    *         if the passed value is <code>null</code>.
231    */
232   public static <T> T notNull (final T aValue, @Nonnull final Supplier <? extends String> aName)
233   {
234     if (isEnabled ())
235       if (aValue == null)
236         throw new NullPointerException ("The value of '" + aName.get () + "' may not be null!");
237     return aValue;
238   }
239 
240   /**
241    * Check that the passed value is <code>null</code>.
242    *
243    * @param aValue
244    *        The value to check.
245    * @param sName
246    *        The name of the value (e.g. the parameter name)
247    * @throws IllegalArgumentException
248    *         if the passed value is not <code>null</code>.
249    */
250   public static void isNull (final Object aValue, final String sName)
251   {
252     isNull (aValue, () -> sName);
253   }
254 
255   /**
256    * Check that the passed value is <code>null</code>.
257    *
258    * @param aValue
259    *        The value to check.
260    * @param aName
261    *        The name of the value (e.g. the parameter name)
262    * @throws IllegalArgumentException
263    *         if the passed value is not <code>null</code>.
264    */
265   public static void isNull (final Object aValue, @Nonnull final Supplier <? extends String> aName)
266   {
267     if (isEnabled ())
268       if (aValue != null)
269         throw new IllegalArgumentException ("The value of '" + aName.get () + "' must be null but is " + aValue);
270   }
271 
272   /**
273    * Check that the passed String is neither <code>null</code> nor empty.
274    *
275    * @param <T>
276    *        Type to be checked and returned
277    * @param aValue
278    *        The String to check.
279    * @param sName
280    *        The name of the value (e.g. the parameter name)
281    * @return The passed value.
282    * @throws IllegalArgumentException
283    *         if the passed value is empty
284    */
285   public static <T extends CharSequence> T notEmpty (final T aValue, final String sName)
286   {
287     return notEmpty (aValue, () -> sName);
288   }
289 
290   /**
291    * Check that the passed String is neither <code>null</code> nor empty.
292    *
293    * @param <T>
294    *        Type to be checked and returned
295    * @param aValue
296    *        The String to check.
297    * @param aName
298    *        The name of the value (e.g. the parameter name)
299    * @return The passed value.
300    * @throws IllegalArgumentException
301    *         if the passed value is empty
302    */
303   public static <T extends CharSequence> T notEmpty (final T aValue, @Nonnull final Supplier <? extends String> aName)
304   {
305     notNull (aValue, aName);
306     if (isEnabled ())
307       if (aValue.length () == 0)
308         throw new IllegalArgumentException ("The value of the string '" + aName.get () + "' may not be empty!");
309     return aValue;
310   }
311 
312   /**
313    * Check that the passed Array is neither <code>null</code> nor empty.
314    *
315    * @param <T>
316    *        Type to be checked and returned
317    * @param aValue
318    *        The Array to check.
319    * @param sName
320    *        The name of the value (e.g. the parameter name)
321    * @return The passed value.
322    * @throws IllegalArgumentException
323    *         if the passed value is empty
324    */
325   public static <T> T [] notEmpty (final T [] aValue, final String sName)
326   {
327     return notEmpty (aValue, () -> sName);
328   }
329 
330   /**
331    * Check that the passed Array is neither <code>null</code> nor empty.
332    *
333    * @param <T>
334    *        Type to be checked and returned
335    * @param aValue
336    *        The Array to check.
337    * @param aName
338    *        The name of the value (e.g. the parameter name)
339    * @return The passed value.
340    * @throws IllegalArgumentException
341    *         if the passed value is empty
342    */
343   public static <T> T [] notEmpty (final T [] aValue, @Nonnull final Supplier <? extends String> aName)
344   {
345     notNull (aValue, aName);
346     if (isEnabled ())
347       if (aValue.length == 0)
348         throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
349     return aValue;
350   }
351 
352   /**
353    * Check that the passed Array is neither <code>null</code> nor empty.
354    *
355    * @param aValue
356    *        The Array to check.
357    * @param sName
358    *        The name of the value (e.g. the parameter name)
359    * @return The passed value.
360    * @throws IllegalArgumentException
361    *         if the passed value is empty
362    */
363   public static boolean [] notEmpty (final boolean [] aValue, final String sName)
364   {
365     return notEmpty (aValue, () -> sName);
366   }
367 
368   /**
369    * Check that the passed Array is neither <code>null</code> nor empty.
370    *
371    * @param aValue
372    *        The Array to check.
373    * @param aName
374    *        The name of the value (e.g. the parameter name)
375    * @return The passed value.
376    * @throws IllegalArgumentException
377    *         if the passed value is empty
378    */
379   public static boolean [] notEmpty (final boolean [] aValue, @Nonnull final Supplier <? extends String> aName)
380   {
381     notNull (aValue, aName);
382     if (isEnabled ())
383       if (aValue.length == 0)
384         throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
385     return aValue;
386   }
387 
388   /**
389    * Check that the passed Array is neither <code>null</code> nor empty.
390    *
391    * @param aValue
392    *        The Array to check.
393    * @param sName
394    *        The name of the value (e.g. the parameter name)
395    * @return The passed value.
396    * @throws IllegalArgumentException
397    *         if the passed value is empty
398    */
399   public static byte [] notEmpty (final byte [] aValue, final String sName)
400   {
401     return notEmpty (aValue, () -> sName);
402   }
403 
404   /**
405    * Check that the passed Array is neither <code>null</code> nor empty.
406    *
407    * @param aValue
408    *        The Array to check.
409    * @param aName
410    *        The name of the value (e.g. the parameter name)
411    * @return The passed value.
412    * @throws IllegalArgumentException
413    *         if the passed value is empty
414    */
415   public static byte [] notEmpty (final byte [] aValue, @Nonnull final Supplier <? extends String> aName)
416   {
417     notNull (aValue, aName);
418     if (isEnabled ())
419       if (aValue.length == 0)
420         throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
421     return aValue;
422   }
423 
424   /**
425    * Check that the passed Array is neither <code>null</code> nor empty.
426    *
427    * @param aValue
428    *        The Array to check.
429    * @param sName
430    *        The name of the value (e.g. the parameter name)
431    * @return The passed value.
432    * @throws IllegalArgumentException
433    *         if the passed value is empty
434    */
435   public static char [] notEmpty (final char [] aValue, final String sName)
436   {
437     return notEmpty (aValue, () -> sName);
438   }
439 
440   /**
441    * Check that the passed Array is neither <code>null</code> nor empty.
442    *
443    * @param aValue
444    *        The Array to check.
445    * @param aName
446    *        The name of the value (e.g. the parameter name)
447    * @return The passed value.
448    * @throws IllegalArgumentException
449    *         if the passed value is empty
450    */
451   public static char [] notEmpty (final char [] aValue, @Nonnull final Supplier <? extends String> aName)
452   {
453     notNull (aValue, aName);
454     if (isEnabled ())
455       if (aValue.length == 0)
456         throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
457     return aValue;
458   }
459 
460   /**
461    * Check that the passed Array is neither <code>null</code> nor empty.
462    *
463    * @param aValue
464    *        The Array to check.
465    * @param sName
466    *        The name of the value (e.g. the parameter name)
467    * @return The passed value.
468    * @throws IllegalArgumentException
469    *         if the passed value is empty
470    */
471   public static double [] notEmpty (final double [] aValue, final String sName)
472   {
473     return notEmpty (aValue, () -> sName);
474   }
475 
476   /**
477    * Check that the passed Array is neither <code>null</code> nor empty.
478    *
479    * @param aValue
480    *        The Array to check.
481    * @param aName
482    *        The name of the value (e.g. the parameter name)
483    * @return The passed value.
484    * @throws IllegalArgumentException
485    *         if the passed value is empty
486    */
487   public static double [] notEmpty (final double [] aValue, @Nonnull final Supplier <? extends String> aName)
488   {
489     notNull (aValue, aName);
490     if (isEnabled ())
491       if (aValue.length == 0)
492         throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
493     return aValue;
494   }
495 
496   /**
497    * Check that the passed Array is neither <code>null</code> nor empty.
498    *
499    * @param aValue
500    *        The Array to check.
501    * @param sName
502    *        The name of the value (e.g. the parameter name)
503    * @return The passed value.
504    * @throws IllegalArgumentException
505    *         if the passed value is empty
506    */
507   public static float [] notEmpty (final float [] aValue, final String sName)
508   {
509     return notEmpty (aValue, () -> sName);
510   }
511 
512   /**
513    * Check that the passed Array is neither <code>null</code> nor empty.
514    *
515    * @param aValue
516    *        The Array to check.
517    * @param aName
518    *        The name of the value (e.g. the parameter name)
519    * @return The passed value.
520    * @throws IllegalArgumentException
521    *         if the passed value is empty
522    */
523   public static float [] notEmpty (final float [] aValue, @Nonnull final Supplier <? extends String> aName)
524   {
525     notNull (aValue, aName);
526     if (isEnabled ())
527       if (aValue.length == 0)
528         throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
529     return aValue;
530   }
531 
532   /**
533    * Check that the passed Array is neither <code>null</code> nor empty.
534    *
535    * @param aValue
536    *        The Array to check.
537    * @param sName
538    *        The name of the value (e.g. the parameter name)
539    * @return The passed value.
540    * @throws IllegalArgumentException
541    *         if the passed value is empty
542    */
543   public static int [] notEmpty (final int [] aValue, final String sName)
544   {
545     return notEmpty (aValue, () -> sName);
546   }
547 
548   /**
549    * Check that the passed Array is neither <code>null</code> nor empty.
550    *
551    * @param aValue
552    *        The Array to check.
553    * @param aName
554    *        The name of the value (e.g. the parameter name)
555    * @return The passed value.
556    * @throws IllegalArgumentException
557    *         if the passed value is empty
558    */
559   public static int [] notEmpty (final int [] aValue, @Nonnull final Supplier <? extends String> aName)
560   {
561     notNull (aValue, aName);
562     if (isEnabled ())
563       if (aValue.length == 0)
564         throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
565     return aValue;
566   }
567 
568   /**
569    * Check that the passed Array is neither <code>null</code> nor empty.
570    *
571    * @param aValue
572    *        The Array to check.
573    * @param sName
574    *        The name of the value (e.g. the parameter name)
575    * @return The passed value.
576    * @throws IllegalArgumentException
577    *         if the passed value is empty
578    */
579   public static long [] notEmpty (final long [] aValue, final String sName)
580   {
581     return notEmpty (aValue, () -> sName);
582   }
583 
584   /**
585    * Check that the passed Array is neither <code>null</code> nor empty.
586    *
587    * @param aValue
588    *        The Array to check.
589    * @param aName
590    *        The name of the value (e.g. the parameter name)
591    * @return The passed value.
592    * @throws IllegalArgumentException
593    *         if the passed value is empty
594    */
595   public static long [] notEmpty (final long [] aValue, @Nonnull final Supplier <? extends String> aName)
596   {
597     notNull (aValue, aName);
598     if (isEnabled ())
599       if (aValue.length == 0)
600         throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
601     return aValue;
602   }
603 
604   /**
605    * Check that the passed Array is neither <code>null</code> nor empty.
606    *
607    * @param aValue
608    *        The Array to check.
609    * @param sName
610    *        The name of the value (e.g. the parameter name)
611    * @return The passed value.
612    * @throws IllegalArgumentException
613    *         if the passed value is empty
614    */
615   public static short [] notEmpty (final short [] aValue, final String sName)
616   {
617     return notEmpty (aValue, () -> sName);
618   }
619 
620   /**
621    * Check that the passed Array is neither <code>null</code> nor empty.
622    *
623    * @param aValue
624    *        The Array to check.
625    * @param aName
626    *        The name of the value (e.g. the parameter name)
627    * @return The passed value.
628    * @throws IllegalArgumentException
629    *         if the passed value is empty
630    */
631   public static short [] notEmpty (final short [] aValue, @Nonnull final Supplier <? extends String> aName)
632   {
633     notNull (aValue, aName);
634     if (isEnabled ())
635       if (aValue.length == 0)
636         throw new IllegalArgumentException ("The value of the array '" + aName.get () + "' may not be empty!");
637     return aValue;
638   }
639 
640   /**
641    * Check that the passed {@link Collection} is neither <code>null</code> nor
642    * empty.
643    *
644    * @param <T>
645    *        Type to be checked and returned
646    * @param aValue
647    *        The String to check.
648    * @param sName
649    *        The name of the value (e.g. the parameter name)
650    * @return The passed value.
651    * @throws IllegalArgumentException
652    *         if the passed value is empty
653    */
654   public static <T extends Collection <?>> T notEmpty (final T aValue, final String sName)
655   {
656     return notEmpty (aValue, () -> sName);
657   }
658 
659   /**
660    * Check that the passed {@link Collection} is neither <code>null</code> nor
661    * empty.
662    *
663    * @param <T>
664    *        Type to be checked and returned
665    * @param aValue
666    *        The String to check.
667    * @param aName
668    *        The name of the value (e.g. the parameter name)
669    * @return The passed value.
670    * @throws IllegalArgumentException
671    *         if the passed value is empty
672    */
673   public static <T extends Collection <?>> T notEmpty (final T aValue, @Nonnull final Supplier <? extends String> aName)
674   {
675     notNull (aValue, aName);
676     if (isEnabled ())
677       if (aValue.isEmpty ())
678         throw new IllegalArgumentException ("The value of the collection '" + aName.get () + "' may not be empty!");
679     return aValue;
680   }
681 
682   /**
683    * Check that the passed {@link Iterable} is neither <code>null</code> nor
684    * empty.
685    *
686    * @param <T>
687    *        Type to be checked and returned
688    * @param aValue
689    *        The String to check.
690    * @param sName
691    *        The name of the value (e.g. the parameter name)
692    * @return The passed value.
693    * @throws IllegalArgumentException
694    *         if the passed value is empty
695    */
696   public static <T extends Iterable <?>> T notEmpty (final T aValue, final String sName)
697   {
698     return notEmpty (aValue, () -> sName);
699   }
700 
701   /**
702    * Check that the passed {@link Iterable} is neither <code>null</code> nor
703    * empty.
704    *
705    * @param <T>
706    *        Type to be checked and returned
707    * @param aValue
708    *        The String to check.
709    * @param aName
710    *        The name of the value (e.g. the parameter name)
711    * @return The passed value.
712    * @throws IllegalArgumentException
713    *         if the passed value is empty
714    */
715   public static <T extends Iterable <?>> T notEmpty (final T aValue, @Nonnull final Supplier <? extends String> aName)
716   {
717     notNull (aValue, aName);
718     if (isEnabled ())
719       if (!aValue.iterator ().hasNext ())
720         throw new IllegalArgumentException ("The value of the iterable '" + aName.get () + "' may not be empty!");
721     return aValue;
722   }
723 
724   /**
725    * Check that the passed Collection is neither <code>null</code> nor empty.
726    *
727    * @param <T>
728    *        Type to be checked and returned
729    * @param aValue
730    *        The String to check.
731    * @param sName
732    *        The name of the value (e.g. the parameter name)
733    * @return The passed value.
734    * @throws IllegalArgumentException
735    *         if the passed value is empty
736    */
737   public static <T extends Map <?, ?>> T notEmpty (final T aValue, final String sName)
738   {
739     return notEmpty (aValue, () -> sName);
740   }
741 
742   /**
743    * Check that the passed Collection is neither <code>null</code> nor empty.
744    *
745    * @param <T>
746    *        Type to be checked and returned
747    * @param aValue
748    *        The String to check.
749    * @param aName
750    *        The name of the value (e.g. the parameter name)
751    * @return The passed value.
752    * @throws IllegalArgumentException
753    *         if the passed value is empty
754    */
755   public static <T extends Map <?, ?>> T notEmpty (final T aValue, @Nonnull final Supplier <? extends String> aName)
756   {
757     notNull (aValue, aName);
758     if (isEnabled ())
759       if (aValue.isEmpty ())
760         throw new IllegalArgumentException ("The value of the map '" + aName.get () + "' may not be empty!");
761     return aValue;
762   }
763 
764   /**
765    * Check that the passed Array contains no <code>null</code> value. But the
766    * whole array can be <code>null</code> or empty.
767    *
768    * @param <T>
769    *        Type to be checked and returned
770    * @param aValue
771    *        The Array to check. May be <code>null</code>.
772    * @param sName
773    *        The name of the value (e.g. the parameter name)
774    * @return The passed value. Maybe <code>null</code>.
775    * @throws IllegalArgumentException
776    *         if the passed value is not empty and a <code>null</code> value is
777    *         contained
778    */
779   @Nullable
780   public static <T> T [] noNullValue (final T [] aValue, final String sName)
781   {
782     return noNullValue (aValue, () -> sName);
783   }
784 
785   /**
786    * Check that the passed Array contains no <code>null</code> value. But the
787    * whole array can be <code>null</code> or empty.
788    *
789    * @param <T>
790    *        Type to be checked and returned
791    * @param aValue
792    *        The Array to check. May be <code>null</code>.
793    * @param aName
794    *        The name of the value (e.g. the parameter name)
795    * @return The passed value. Maybe <code>null</code>.
796    * @throws IllegalArgumentException
797    *         if the passed value is not empty and a <code>null</code> value is
798    *         contained
799    */
800   @Nullable
801   public static <T> T [] noNullValue (final T [] aValue, @Nonnull final Supplier <? extends String> aName)
802   {
803     if (isEnabled ())
804       if (aValue != null)
805       {
806         int nIndex = 0;
807         for (final T aItem : aValue)
808         {
809           if (aItem == null)
810             throw new IllegalArgumentException ("Item " + nIndex + " of array '" + aName.get () + "' may not be null!");
811           ++nIndex;
812         }
813       }
814     return aValue;
815   }
816 
817   /**
818    * Check that the passed iterable contains no <code>null</code> value. But the
819    * whole iterable can be <code>null</code> or empty.
820    *
821    * @param <T>
822    *        Type to be checked and returned
823    * @param aValue
824    *        The collection to check. May be <code>null</code>.
825    * @param sName
826    *        The name of the value (e.g. the parameter name)
827    * @return The passed value. Maybe <code>null</code>.
828    * @throws IllegalArgumentException
829    *         if the passed value is not empty and a <code>null</code> value is
830    *         contained
831    */
832   @Nullable
833   public static <T extends Iterable <?>> T noNullValue (final T aValue, final String sName)
834   {
835     return noNullValue (aValue, () -> sName);
836   }
837 
838   /**
839    * Check that the passed iterable contains no <code>null</code> value. But the
840    * whole iterable can be <code>null</code> or empty.
841    *
842    * @param <T>
843    *        Type to be checked and returned
844    * @param aValue
845    *        The collection to check. May be <code>null</code>.
846    * @param aName
847    *        The name of the value (e.g. the parameter name)
848    * @return The passed value. Maybe <code>null</code>.
849    * @throws IllegalArgumentException
850    *         if the passed value is not empty and a <code>null</code> value is
851    *         contained
852    */
853   @Nullable
854   public static <T extends Iterable <?>> T noNullValue (final T aValue,
855                                                         @Nonnull final Supplier <? extends String> aName)
856   {
857     if (isEnabled ())
858       if (aValue != null)
859       {
860         int nIndex = 0;
861         for (final Object aItem : aValue)
862         {
863           if (aItem == null)
864             throw new IllegalArgumentException ("Item " +
865                                                 nIndex +
866                                                 " of iterable '" +
867                                                 aName.get () +
868                                                 "' may not be null!");
869           ++nIndex;
870         }
871       }
872     return aValue;
873   }
874 
875   /**
876    * Check that the passed map is neither <code>null</code> nor empty and that
877    * no <code>null</code> key or value is contained.
878    *
879    * @param <T>
880    *        Type to be checked and returned
881    * @param aValue
882    *        The map to check. May be <code>null</code>.
883    * @param sName
884    *        The name of the value (e.g. the parameter name)
885    * @return The passed value. Maybe <code>null</code>.
886    * @throws IllegalArgumentException
887    *         if the passed value is not empty and a <code>null</code> key or
888    *         <code>null</code> value is contained
889    */
890   @Nullable
891   public static <T extends Map <?, ?>> T noNullValue (final T aValue, final String sName)
892   {
893     return noNullValue (aValue, () -> sName);
894   }
895 
896   /**
897    * Check that the passed map is neither <code>null</code> nor empty and that
898    * no <code>null</code> key or value is contained.
899    *
900    * @param <T>
901    *        Type to be checked and returned
902    * @param aValue
903    *        The map to check. May be <code>null</code>.
904    * @param aName
905    *        The name of the value (e.g. the parameter name)
906    * @return The passed value. Maybe <code>null</code>.
907    * @throws IllegalArgumentException
908    *         if the passed value is not empty and a <code>null</code> key or
909    *         <code>null</code> value is contained
910    */
911   @Nullable
912   public static <T extends Map <?, ?>> T noNullValue (final T aValue, @Nonnull final Supplier <? extends String> aName)
913   {
914     if (isEnabled ())
915       if (aValue != null)
916       {
917         for (final Map.Entry <?, ?> aEntry : aValue.entrySet ())
918         {
919           if (aEntry.getKey () == null)
920             throw new IllegalArgumentException ("A key of map '" + aName.get () + "' may not be null!");
921           if (aEntry.getValue () == null)
922             throw new IllegalArgumentException ("A value of map '" + aName.get () + "' may not be null!");
923         }
924       }
925     return aValue;
926   }
927 
928   /**
929    * Check that the passed Array is not <code>null</code> and that no
930    * <code>null</code> value is contained.
931    *
932    * @param <T>
933    *        Type to be checked and returned
934    * @param aValue
935    *        The Array to check.
936    * @param sName
937    *        The name of the value (e.g. the parameter name)
938    * @return The passed value.
939    * @throws IllegalArgumentException
940    *         if the passed value is null or a <code>null</code> value is
941    *         contained
942    */
943   public static <T> T [] notNullNoNullValue (final T [] aValue, final String sName)
944   {
945     return notNullNoNullValue (aValue, () -> sName);
946   }
947 
948   /**
949    * Check that the passed Array is not <code>null</code> and that no
950    * <code>null</code> value is contained.
951    *
952    * @param <T>
953    *        Type to be checked and returned
954    * @param aValue
955    *        The Array to check.
956    * @param aName
957    *        The name of the value (e.g. the parameter name)
958    * @return The passed value.
959    * @throws IllegalArgumentException
960    *         if the passed value is null or a <code>null</code> value is
961    *         contained
962    */
963   public static <T> T [] notNullNoNullValue (final T [] aValue, @Nonnull final Supplier <? extends String> aName)
964   {
965     notNull (aValue, aName);
966     noNullValue (aValue, aName);
967     return aValue;
968   }
969 
970   /**
971    * Check that the passed collection is not <code>null</code> and that no
972    * <code>null</code> value is contained.
973    *
974    * @param <T>
975    *        Type to be checked and returned
976    * @param aValue
977    *        The collection to check.
978    * @param sName
979    *        The name of the value (e.g. the parameter name)
980    * @return The passed value.
981    * @throws IllegalArgumentException
982    *         if the passed value is <code>null</code> or a <code>null</code>
983    *         value is contained
984    */
985   public static <T extends Iterable <?>> T notNullNoNullValue (final T aValue, final String sName)
986   {
987     return notNullNoNullValue (aValue, () -> sName);
988   }
989 
990   /**
991    * Check that the passed collection is not <code>null</code> and that no
992    * <code>null</code> value is contained.
993    *
994    * @param <T>
995    *        Type to be checked and returned
996    * @param aValue
997    *        The collection to check.
998    * @param aName
999    *        The name of the value (e.g. the parameter name)
1000    * @return The passed value.
1001    * @throws IllegalArgumentException
1002    *         if the passed value is <code>null</code> or a <code>null</code>
1003    *         value is contained
1004    */
1005   public static <T extends Iterable <?>> T notNullNoNullValue (final T aValue,
1006                                                                @Nonnull final Supplier <? extends String> aName)
1007   {
1008     notNull (aValue, aName);
1009     noNullValue (aValue, aName);
1010     return aValue;
1011   }
1012 
1013   /**
1014    * Check that the passed map is not <code>null</code> and that no
1015    * <code>null</code> value is contained.
1016    *
1017    * @param <T>
1018    *        Type to be checked and returned
1019    * @param aValue
1020    *        The map to check.
1021    * @param sName
1022    *        The name of the value (e.g. the parameter name)
1023    * @return The passed value.
1024    * @throws IllegalArgumentException
1025    *         if the passed value is <code>null</code> or a <code>null</code>
1026    *         value is contained
1027    */
1028   public static <T extends Map <?, ?>> T notNullNoNullValue (final T aValue, final String sName)
1029   {
1030     return notNullNoNullValue (aValue, () -> sName);
1031   }
1032 
1033   /**
1034    * Check that the passed map is not <code>null</code> and that no
1035    * <code>null</code> value is contained.
1036    *
1037    * @param <T>
1038    *        Type to be checked and returned
1039    * @param aValue
1040    *        The map to check.
1041    * @param aName
1042    *        The name of the value (e.g. the parameter name)
1043    * @return The passed value.
1044    * @throws IllegalArgumentException
1045    *         if the passed value is <code>null</code> or a <code>null</code>
1046    *         value is contained
1047    */
1048   public static <T extends Map <?, ?>> T notNullNoNullValue (final T aValue,
1049                                                              @Nonnull final Supplier <? extends String> aName)
1050   {
1051     notNull (aValue, aName);
1052     noNullValue (aValue, aName);
1053     return aValue;
1054   }
1055 
1056   /**
1057    * Check that the passed Array is neither <code>null</code> nor empty and that
1058    * no <code>null</code> value is contained.
1059    *
1060    * @param <T>
1061    *        Type to be checked and returned
1062    * @param aValue
1063    *        The Array to check.
1064    * @param sName
1065    *        The name of the value (e.g. the parameter name)
1066    * @return The passed value.
1067    * @throws IllegalArgumentException
1068    *         if the passed value is empty or a <code>null</code> value is
1069    *         contained
1070    */
1071   public static <T> T [] notEmptyNoNullValue (final T [] aValue, final String sName)
1072   {
1073     return notEmptyNoNullValue (aValue, () -> sName);
1074   }
1075 
1076   /**
1077    * Check that the passed Array is neither <code>null</code> nor empty and that
1078    * no <code>null</code> value is contained.
1079    *
1080    * @param <T>
1081    *        Type to be checked and returned
1082    * @param aValue
1083    *        The Array to check.
1084    * @param aName
1085    *        The name of the value (e.g. the parameter name)
1086    * @return The passed value.
1087    * @throws IllegalArgumentException
1088    *         if the passed value is empty or a <code>null</code> value is
1089    *         contained
1090    */
1091   public static <T> T [] notEmptyNoNullValue (final T [] aValue, @Nonnull final Supplier <? extends String> aName)
1092   {
1093     notEmpty (aValue, aName);
1094     noNullValue (aValue, aName);
1095     return aValue;
1096   }
1097 
1098   /**
1099    * Check that the passed collection is neither <code>null</code> nor empty and
1100    * that no <code>null</code> value is contained.
1101    *
1102    * @param <T>
1103    *        Type to be checked and returned
1104    * @param aValue
1105    *        The collection to check.
1106    * @param sName
1107    *        The name of the value (e.g. the parameter name)
1108    * @return The passed value.
1109    * @throws IllegalArgumentException
1110    *         if the passed value is empty or a <code>null</code> value is
1111    *         contained
1112    */
1113   public static <T extends Iterable <?>> T notEmptyNoNullValue (final T aValue, final String sName)
1114   {
1115     return notEmptyNoNullValue (aValue, () -> sName);
1116   }
1117 
1118   /**
1119    * Check that the passed collection is neither <code>null</code> nor empty and
1120    * that no <code>null</code> value is contained.
1121    *
1122    * @param <T>
1123    *        Type to be checked and returned
1124    * @param aValue
1125    *        The collection to check.
1126    * @param aName
1127    *        The name of the value (e.g. the parameter name)
1128    * @return The passed value.
1129    * @throws IllegalArgumentException
1130    *         if the passed value is empty or a <code>null</code> value is
1131    *         contained
1132    */
1133   public static <T extends Iterable <?>> T notEmptyNoNullValue (final T aValue,
1134                                                                 @Nonnull final Supplier <? extends String> aName)
1135   {
1136     notEmpty (aValue, aName);
1137     noNullValue (aValue, aName);
1138     return aValue;
1139   }
1140 
1141   /**
1142    * Check that the passed map is neither <code>null</code> nor empty and that
1143    * no <code>null</code> value is contained.
1144    *
1145    * @param <T>
1146    *        Type to be checked and returned
1147    * @param aValue
1148    *        The map to check.
1149    * @param sName
1150    *        The name of the value (e.g. the parameter name)
1151    * @return The passed value.
1152    * @throws IllegalArgumentException
1153    *         if the passed value is empty or a <code>null</code> value is
1154    *         contained
1155    */
1156   public static <T extends Map <?, ?>> T notEmptyNoNullValue (final T aValue, final String sName)
1157   {
1158     return notEmptyNoNullValue (aValue, () -> sName);
1159   }
1160 
1161   /**
1162    * Check that the passed map is neither <code>null</code> nor empty and that
1163    * no <code>null</code> value is contained.
1164    *
1165    * @param <T>
1166    *        Type to be checked and returned
1167    * @param aValue
1168    *        The map to check.
1169    * @param aName
1170    *        The name of the value (e.g. the parameter name)
1171    * @return The passed value.
1172    * @throws IllegalArgumentException
1173    *         if the passed value is empty or a <code>null</code> value is
1174    *         contained
1175    */
1176   public static <T extends Map <?, ?>> T notEmptyNoNullValue (final T aValue,
1177                                                               @Nonnull final Supplier <? extends String> aName)
1178   {
1179     notEmpty (aValue, aName);
1180     noNullValue (aValue, aName);
1181     return aValue;
1182   }
1183 
1184   /**
1185    * Check that the passed value is not <code>null</code> and not equal to the
1186    * provided value.
1187    *
1188    * @param <T>
1189    *        Type to be checked and returned
1190    * @param aValue
1191    *        The value to check. May not be <code>null</code>.
1192    * @param sName
1193    *        The name of the value (e.g. the parameter name)
1194    * @param aUnexpectedValue
1195    *        The value that may not be equal to aValue. May not be
1196    *        <code>null</code>.
1197    * @return The passed value.
1198    */
1199   public static <T> T notNullNotEquals (final T aValue, final String sName, @Nonnull final T aUnexpectedValue)
1200   {
1201     return notNullNotEquals (aValue, () -> sName, aUnexpectedValue);
1202   }
1203 
1204   /**
1205    * Check that the passed value is not <code>null</code> and not equal to the
1206    * provided value.
1207    *
1208    * @param <T>
1209    *        Type to be checked and returned
1210    * @param aValue
1211    *        The value to check. May not be <code>null</code>.
1212    * @param aName
1213    *        The name of the value (e.g. the parameter name)
1214    * @param aUnexpectedValue
1215    *        The value that may not be equal to aValue. May not be
1216    *        <code>null</code>.
1217    * @return The passed value.
1218    */
1219   public static <T> T notNullNotEquals (final T aValue,
1220                                         @Nonnull final Supplier <? extends String> aName,
1221                                         @Nonnull final T aUnexpectedValue)
1222   {
1223     notNull (aValue, aName);
1224     notNull (aUnexpectedValue, "UnexpectedValue");
1225     if (isEnabled ())
1226       if (aValue.equals (aUnexpectedValue))
1227         throw new IllegalArgumentException ("The value of '" +
1228                                             aName.get () +
1229                                             "' may not be equal to " +
1230                                             aUnexpectedValue +
1231                                             "!");
1232     return aValue;
1233   }
1234 
1235   /**
1236    * Check that the passed value is not <code>null</code> and equal to the
1237    * provided expected value.
1238    *
1239    * @param <T>
1240    *        Type to be checked and returned
1241    * @param aValue
1242    *        The value to check.
1243    * @param sName
1244    *        The name of the value (e.g. the parameter name)
1245    * @param aExpectedValue
1246    *        The expected value. May not be <code>null</code>.
1247    * @return The passed value.
1248    * @throws IllegalArgumentException
1249    *         if the passed value is not <code>null</code>.
1250    */
1251   public static <T> T notNullAndEquals (final T aValue, final String sName, @Nonnull final T aExpectedValue)
1252   {
1253     return notNullAndEquals (aValue, () -> sName, aExpectedValue);
1254   }
1255 
1256   /**
1257    * Check that the passed value is not <code>null</code> and equal to the
1258    * provided expected value.
1259    *
1260    * @param <T>
1261    *        Type to be checked and returned
1262    * @param aValue
1263    *        The value to check.
1264    * @param aName
1265    *        The name of the value (e.g. the parameter name)
1266    * @param aExpectedValue
1267    *        The expected value. May not be <code>null</code>.
1268    * @return The passed value.
1269    * @throws IllegalArgumentException
1270    *         if the passed value is not <code>null</code>.
1271    */
1272   public static <T> T notNullAndEquals (final T aValue,
1273                                         @Nonnull final Supplier <? extends String> aName,
1274                                         @Nonnull final T aExpectedValue)
1275   {
1276     notNull (aValue, aName);
1277     if (isEnabled ())
1278       if (!aValue.equals (aExpectedValue))
1279         throw new IllegalArgumentException ("The value of '" +
1280                                             aName.get () +
1281                                             "' does not match the expected value. Passed value: " +
1282                                             aValue +
1283                                             " -- Expected value: " +
1284                                             aExpectedValue);
1285     return aValue;
1286   }
1287 
1288   /**
1289    * Check that the passed value is the same as the provided expected value
1290    * using <code>==</code> to check comparison.
1291    *
1292    * @param <T>
1293    *        Type to be checked and returned
1294    * @param aValue
1295    *        The value to check.
1296    * @param sName
1297    *        The name of the value (e.g. the parameter name)
1298    * @param aExpectedValue
1299    *        The expected value. May be <code>null</code>.
1300    * @return The passed value and maybe <code>null</code> if the expected value
1301    *         is null.
1302    * @throws IllegalArgumentException
1303    *         if the passed value is not <code>null</code>.
1304    */
1305   public static <T> T isSame (final T aValue, final String sName, @Nullable final T aExpectedValue)
1306   {
1307     return isSame (aValue, () -> sName, aExpectedValue);
1308   }
1309 
1310   /**
1311    * Check that the passed value is the same as the provided expected value
1312    * using <code>==</code> to check comparison.
1313    *
1314    * @param <T>
1315    *        Type to be checked and returned
1316    * @param aValue
1317    *        The value to check.
1318    * @param aName
1319    *        The name of the value (e.g. the parameter name)
1320    * @param aExpectedValue
1321    *        The expected value. May be <code>null</code>.
1322    * @return The passed value and maybe <code>null</code> if the expected value
1323    *         is null.
1324    * @throws IllegalArgumentException
1325    *         if the passed value is not <code>null</code>.
1326    */
1327   public static <T> T isSame (final T aValue,
1328                               @Nonnull final Supplier <? extends String> aName,
1329                               @Nullable final T aExpectedValue)
1330   {
1331     if (isEnabled ())
1332       if (aValue != aExpectedValue)
1333         throw new IllegalArgumentException ("The value of '" +
1334                                             aName.get () +
1335                                             "' does not match the expected value. Passed value: " +
1336                                             aValue +
1337                                             " -- Expected value: " +
1338                                             aExpectedValue);
1339     return aValue;
1340   }
1341 
1342   /**
1343    * Check that the passed value is the same as the provided expected value
1344    * using <code>equals</code> to check comparison.
1345    *
1346    * @param <T>
1347    *        Type to be checked and returned
1348    * @param aValue
1349    *        The value to check.
1350    * @param sName
1351    *        The name of the value (e.g. the parameter name)
1352    * @param aExpectedValue
1353    *        The expected value. May be <code>null</code>.
1354    * @return The passed value and maybe <code>null</code> if the expected value
1355    *         is null.
1356    * @throws IllegalArgumentException
1357    *         if the passed value is not <code>null</code>.
1358    */
1359   public static <T> T isEqual (final T aValue, @Nullable final T aExpectedValue, final String sName)
1360   {
1361     return isSame (aValue, () -> sName, aExpectedValue);
1362   }
1363 
1364   /**
1365    * Check that the passed value is the same as the provided expected value
1366    * using <code>equals</code> to check comparison.
1367    *
1368    * @param <T>
1369    *        Type to be checked and returned
1370    * @param aValue
1371    *        The value to check.
1372    * @param aName
1373    *        The name of the value (e.g. the parameter name)
1374    * @param aExpectedValue
1375    *        The expected value. May be <code>null</code>.
1376    * @return The passed value and maybe <code>null</code> if the expected value
1377    *         is null.
1378    * @throws IllegalArgumentException
1379    *         if the passed value is not <code>null</code>.
1380    */
1381   public static <T> T isEqual (final T aValue,
1382                                @Nullable final T aExpectedValue,
1383                                @Nonnull final Supplier <? extends String> aName)
1384   {
1385     if (isEnabled ())
1386       if (aValue != aExpectedValue)
1387         throw new IllegalArgumentException ("The value of '" +
1388                                             aName.get () +
1389                                             "' does not match the expected value. Passed value: " +
1390                                             aValue +
1391                                             " -- Expected value: " +
1392                                             aExpectedValue);
1393     return aValue;
1394   }
1395 
1396   /**
1397    * Check that the passed value is the same as the provided expected value
1398    * using <code>==</code> to check comparison.
1399    *
1400    * @param nValue
1401    *        The First value.
1402    * @param nExpectedValue
1403    *        The expected value.
1404    * @param sName
1405    *        The name of the value (e.g. the parameter name)
1406    * @throws IllegalArgumentException
1407    *         if the passed value is not <code>null</code>.
1408    */
1409   public static void isEqual (final int nValue, final int nExpectedValue, final String sName)
1410   {
1411     isEqual (nValue, nExpectedValue, () -> sName);
1412   }
1413 
1414   /**
1415    * Check that the passed value is the same as the provided expected value
1416    * using <code>==</code> to check comparison.
1417    *
1418    * @param nValue
1419    *        The First value.
1420    * @param nExpectedValue
1421    *        The expected value.
1422    * @param aName
1423    *        The name of the value (e.g. the parameter name)
1424    * @throws IllegalArgumentException
1425    *         if the passed value is not <code>null</code>.
1426    */
1427   public static void isEqual (final int nValue,
1428                               final int nExpectedValue,
1429                               @Nonnull final Supplier <? extends String> aName)
1430   {
1431     if (isEnabled ())
1432       if (nValue != nExpectedValue)
1433         throw new IllegalArgumentException ("The value of '" +
1434                                             aName.get () +
1435                                             "' does not match the expected value. Passed value: " +
1436                                             nValue +
1437                                             " -- Expected value: " +
1438                                             nExpectedValue);
1439   }
1440 
1441   /**
1442    * Check that the passed value is the same as the provided expected value
1443    * using <code>==</code> to check comparison.
1444    *
1445    * @param nValue
1446    *        The First value.
1447    * @param nExpectedValue
1448    *        The expected value.
1449    * @param sName
1450    *        The name of the value (e.g. the parameter name)
1451    * @throws IllegalArgumentException
1452    *         if the passed value is not <code>null</code>.
1453    */
1454   public static void isEqual (final long nValue, final long nExpectedValue, final String sName)
1455   {
1456     isEqual (nValue, nExpectedValue, () -> sName);
1457   }
1458 
1459   /**
1460    * Check that the passed value is the same as the provided expected value
1461    * using <code>==</code> to check comparison.
1462    *
1463    * @param nValue
1464    *        The First value.
1465    * @param nExpectedValue
1466    *        The expected value.
1467    * @param aName
1468    *        The name of the value (e.g. the parameter name)
1469    * @throws IllegalArgumentException
1470    *         if the passed value is not <code>null</code>.
1471    */
1472   public static void isEqual (final long nValue,
1473                               final long nExpectedValue,
1474                               @Nonnull final Supplier <? extends String> aName)
1475   {
1476     if (isEnabled ())
1477       if (nValue != nExpectedValue)
1478         throw new IllegalArgumentException ("The value of '" +
1479                                             aName.get () +
1480                                             "' does not match the expected value. Passed value: " +
1481                                             nValue +
1482                                             " -- Expected value: " +
1483                                             nExpectedValue);
1484   }
1485 
1486   /**
1487    * Check that the passed value is the same as the provided expected value
1488    * using <code>==</code> to check comparison.
1489    *
1490    * @param dValue
1491    *        The First value.
1492    * @param dExpectedValue
1493    *        The expected value.
1494    * @param sName
1495    *        The name of the value (e.g. the parameter name)
1496    * @throws IllegalArgumentException
1497    *         if the passed value is not <code>null</code>.
1498    */
1499   public static void isEqual (final double dValue, final double dExpectedValue, final String sName)
1500   {
1501     isEqual (dValue, dExpectedValue, () -> sName);
1502   }
1503 
1504   /**
1505    * Check that the passed value is the same as the provided expected value
1506    * using <code>==</code> to check comparison.
1507    *
1508    * @param dValue
1509    *        The First value.
1510    * @param dExpectedValue
1511    *        The expected value.
1512    * @param aName
1513    *        The name of the value (e.g. the parameter name)
1514    * @throws IllegalArgumentException
1515    *         if the passed value is not <code>null</code>.
1516    */
1517   public static void isEqual (final double dValue,
1518                               final double dExpectedValue,
1519                               @Nonnull final Supplier <? extends String> aName)
1520   {
1521     if (isEnabled ())
1522       if (Double.compare (dValue, dExpectedValue) != 0)
1523         throw new IllegalArgumentException ("The value of '" +
1524                                             aName.get () +
1525                                             "' does not match the expected value. Passed value: " +
1526                                             dValue +
1527                                             " -- Expected value: " +
1528                                             dExpectedValue);
1529   }
1530 
1531   public static int isGE0 (final int nValue, final String sName)
1532   {
1533     return isGE0 (nValue, () -> sName);
1534   }
1535 
1536   public static int isGE0 (final int nValue, @Nonnull final Supplier <? extends String> aName)
1537   {
1538     if (isEnabled ())
1539       if (nValue < 0)
1540         throw new IllegalArgumentException ("The value of '" +
1541                                             aName.get () +
1542                                             "' must be >= 0! The current value is: " +
1543                                             nValue);
1544     return nValue;
1545   }
1546 
1547   public static long isGE0 (final long nValue, final String sName)
1548   {
1549     return isGE0 (nValue, () -> sName);
1550   }
1551 
1552   public static long isGE0 (final long nValue, @Nonnull final Supplier <? extends String> aName)
1553   {
1554     if (isEnabled ())
1555       if (nValue < 0)
1556         throw new IllegalArgumentException ("The value of '" +
1557                                             aName.get () +
1558                                             "' must be >= 0! The current value is: " +
1559                                             nValue);
1560     return nValue;
1561   }
1562 
1563   public static short isGE0 (final short nValue, final String sName)
1564   {
1565     return isGE0 (nValue, () -> sName);
1566   }
1567 
1568   public static short isGE0 (final short nValue, @Nonnull final Supplier <? extends String> aName)
1569   {
1570     if (isEnabled ())
1571       if (nValue < 0)
1572         throw new IllegalArgumentException ("The value of '" +
1573                                             aName.get () +
1574                                             "' must be >= 0! The current value is: " +
1575                                             nValue);
1576     return nValue;
1577   }
1578 
1579   public static double isGE0 (final double dValue, final String sName)
1580   {
1581     return isGE0 (dValue, () -> sName);
1582   }
1583 
1584   public static double isGE0 (final double dValue, @Nonnull final Supplier <? extends String> aName)
1585   {
1586     if (isEnabled ())
1587       if (dValue < 0)
1588         throw new IllegalArgumentException ("The value of '" +
1589                                             aName.get () +
1590                                             "' must be >= 0! The current value is: " +
1591                                             dValue);
1592     return dValue;
1593   }
1594 
1595   public static float isGE0 (final float fValue, final String sName)
1596   {
1597     return isGE0 (fValue, () -> sName);
1598   }
1599 
1600   public static float isGE0 (final float fValue, @Nonnull final Supplier <? extends String> aName)
1601   {
1602     if (isEnabled ())
1603       if (fValue < 0)
1604         throw new IllegalArgumentException ("The value of '" +
1605                                             aName.get () +
1606                                             "' must be >= 0! The current value is: " +
1607                                             fValue);
1608     return fValue;
1609   }
1610 
1611   public static BigDecimal isGE0 (final BigDecimal aValue, final String sName)
1612   {
1613     return isGE0 (aValue, () -> sName);
1614   }
1615 
1616   public static BigDecimal isGE0 (final BigDecimal aValue, @Nonnull final Supplier <? extends String> aName)
1617   {
1618     notNull (aValue, aName);
1619     if (isEnabled ())
1620       if (aValue.compareTo (BigDecimal.ZERO) < 0)
1621         throw new IllegalArgumentException ("The value of '" +
1622                                             aName.get () +
1623                                             "' must be >= 0! The current value is: " +
1624                                             aValue);
1625     return aValue;
1626   }
1627 
1628   public static BigInteger isGE0 (final BigInteger aValue, final String sName)
1629   {
1630     return isGE0 (aValue, () -> sName);
1631   }
1632 
1633   public static BigInteger isGE0 (final BigInteger aValue, @Nonnull final Supplier <? extends String> aName)
1634   {
1635     notNull (aValue, aName);
1636     if (isEnabled ())
1637       if (aValue.compareTo (BigInteger.ZERO) < 0)
1638         throw new IllegalArgumentException ("The value of '" +
1639                                             aName.get () +
1640                                             "' must be >= 0! The current value is: " +
1641                                             aValue);
1642     return aValue;
1643   }
1644 
1645   public static int isGT0 (final int nValue, final String sName)
1646   {
1647     return isGT0 (nValue, () -> sName);
1648   }
1649 
1650   public static int isGT0 (final int nValue, @Nonnull final Supplier <? extends String> aName)
1651   {
1652     if (isEnabled ())
1653       if (nValue <= 0)
1654         throw new IllegalArgumentException ("The value of '" +
1655                                             aName.get () +
1656                                             "' must be > 0! The current value is: " +
1657                                             nValue);
1658     return nValue;
1659   }
1660 
1661   public static long isGT0 (final long nValue, final String sName)
1662   {
1663     return isGT0 (nValue, () -> sName);
1664   }
1665 
1666   public static long isGT0 (final long nValue, @Nonnull final Supplier <? extends String> aName)
1667   {
1668     if (isEnabled ())
1669       if (nValue <= 0)
1670         throw new IllegalArgumentException ("The value of '" +
1671                                             aName.get () +
1672                                             "' must be > 0! The current value is: " +
1673                                             nValue);
1674     return nValue;
1675   }
1676 
1677   public static short isGT0 (final short nValue, final String sName)
1678   {
1679     return isGT0 (nValue, () -> sName);
1680   }
1681 
1682   public static short isGT0 (final short nValue, @Nonnull final Supplier <? extends String> aName)
1683   {
1684     if (isEnabled ())
1685       if (nValue <= 0)
1686         throw new IllegalArgumentException ("The value of '" +
1687                                             aName.get () +
1688                                             "' must be > 0! The current value is: " +
1689                                             nValue);
1690     return nValue;
1691   }
1692 
1693   public static double isGT0 (final double dValue, final String sName)
1694   {
1695     return isGT0 (dValue, () -> sName);
1696   }
1697 
1698   public static double isGT0 (final double dValue, @Nonnull final Supplier <? extends String> aName)
1699   {
1700     if (isEnabled ())
1701       if (dValue <= 0)
1702         throw new IllegalArgumentException ("The value of '" +
1703                                             aName.get () +
1704                                             "' must be > 0! The current value is: " +
1705                                             dValue);
1706     return dValue;
1707   }
1708 
1709   public static float isGT0 (final float fValue, final String sName)
1710   {
1711     return isGT0 (fValue, () -> sName);
1712   }
1713 
1714   public static float isGT0 (final float fValue, @Nonnull final Supplier <? extends String> aName)
1715   {
1716     if (isEnabled ())
1717       if (fValue <= 0)
1718         throw new IllegalArgumentException ("The value of '" +
1719                                             aName.get () +
1720                                             "' must be > 0! The current value is: " +
1721                                             fValue);
1722     return fValue;
1723   }
1724 
1725   public static BigDecimal isGT0 (final BigDecimal aValue, final String sName)
1726   {
1727     return isGT0 (aValue, () -> sName);
1728   }
1729 
1730   public static BigDecimal isGT0 (final BigDecimal aValue, @Nonnull final Supplier <? extends String> aName)
1731   {
1732     notNull (aValue, aName);
1733     if (isEnabled ())
1734       if (aValue.compareTo (BigDecimal.ZERO) <= 0)
1735         throw new IllegalArgumentException ("The value of '" +
1736                                             aName.get () +
1737                                             "' must be > 0! The current value is: " +
1738                                             aValue);
1739     return aValue;
1740   }
1741 
1742   public static BigInteger isGT0 (final BigInteger aValue, final String sName)
1743   {
1744     return isGT0 (aValue, () -> sName);
1745   }
1746 
1747   public static BigInteger isGT0 (final BigInteger aValue, @Nonnull final Supplier <? extends String> aName)
1748   {
1749     notNull (aValue, aName);
1750     if (isEnabled ())
1751       if (aValue.compareTo (BigInteger.ZERO) <= 0)
1752         throw new IllegalArgumentException ("The value of '" +
1753                                             aName.get () +
1754                                             "' must be > 0! The current value is: " +
1755                                             aValue);
1756     return aValue;
1757   }
1758 
1759   public static int isLE0 (final int nValue, final String sName)
1760   {
1761     return isLE0 (nValue, () -> sName);
1762   }
1763 
1764   public static int isLE0 (final int nValue, @Nonnull final Supplier <? extends String> aName)
1765   {
1766     if (isEnabled ())
1767       if (nValue > 0)
1768         throw new IllegalArgumentException ("The value of '" +
1769                                             aName.get () +
1770                                             "' must be <= 0! The current value is: " +
1771                                             nValue);
1772     return nValue;
1773   }
1774 
1775   public static long isLE0 (final long nValue, final String sName)
1776   {
1777     return isLE0 (nValue, () -> sName);
1778   }
1779 
1780   public static long isLE0 (final long nValue, @Nonnull final Supplier <? extends String> aName)
1781   {
1782     if (isEnabled ())
1783       if (nValue > 0)
1784         throw new IllegalArgumentException ("The value of '" +
1785                                             aName.get () +
1786                                             "' must be <= 0! The current value is: " +
1787                                             nValue);
1788     return nValue;
1789   }
1790 
1791   public static short isLE0 (final short nValue, final String sName)
1792   {
1793     return isLE0 (nValue, () -> sName);
1794   }
1795 
1796   public static short isLE0 (final short nValue, @Nonnull final Supplier <? extends String> aName)
1797   {
1798     if (isEnabled ())
1799       if (nValue > 0)
1800         throw new IllegalArgumentException ("The value of '" +
1801                                             aName.get () +
1802                                             "' must be <= 0! The current value is: " +
1803                                             nValue);
1804     return nValue;
1805   }
1806 
1807   public static double isLE0 (final double dValue, final String sName)
1808   {
1809     return isLE0 (dValue, () -> sName);
1810   }
1811 
1812   public static double isLE0 (final double dValue, @Nonnull final Supplier <? extends String> aName)
1813   {
1814     if (isEnabled ())
1815       if (dValue > 0)
1816         throw new IllegalArgumentException ("The value of '" +
1817                                             aName.get () +
1818                                             "' must be <= 0! The current value is: " +
1819                                             dValue);
1820     return dValue;
1821   }
1822 
1823   public static float isLE0 (final float fValue, final String sName)
1824   {
1825     return isLE0 (fValue, () -> sName);
1826   }
1827 
1828   public static float isLE0 (final float fValue, @Nonnull final Supplier <? extends String> aName)
1829   {
1830     if (isEnabled ())
1831       if (fValue > 0)
1832         throw new IllegalArgumentException ("The value of '" +
1833                                             aName.get () +
1834                                             "' must be <= 0! The current value is: " +
1835                                             fValue);
1836     return fValue;
1837   }
1838 
1839   public static BigDecimal isLE0 (final BigDecimal aValue, final String sName)
1840   {
1841     return isLE0 (aValue, () -> sName);
1842   }
1843 
1844   public static BigDecimal isLE0 (final BigDecimal aValue, @Nonnull final Supplier <? extends String> aName)
1845   {
1846     notNull (aValue, aName);
1847     if (isEnabled ())
1848       if (aValue.compareTo (BigDecimal.ZERO) > 0)
1849         throw new IllegalArgumentException ("The value of '" +
1850                                             aName.get () +
1851                                             "' must be <= 0! The current value is: " +
1852                                             aValue);
1853     return aValue;
1854   }
1855 
1856   public static BigInteger isLE0 (final BigInteger aValue, final String sName)
1857   {
1858     return isLE0 (aValue, () -> sName);
1859   }
1860 
1861   public static BigInteger isLE0 (final BigInteger aValue, @Nonnull final Supplier <? extends String> aName)
1862   {
1863     notNull (aValue, aName);
1864     if (isEnabled ())
1865       if (aValue.compareTo (BigInteger.ZERO) > 0)
1866         throw new IllegalArgumentException ("The value of '" +
1867                                             aName.get () +
1868                                             "' must be <= 0! The current value is: " +
1869                                             aValue);
1870     return aValue;
1871   }
1872 
1873   public static int isLT0 (final int nValue, final String sName)
1874   {
1875     return isLT0 (nValue, () -> sName);
1876   }
1877 
1878   public static int isLT0 (final int nValue, @Nonnull final Supplier <? extends String> aName)
1879   {
1880     if (isEnabled ())
1881       if (nValue >= 0)
1882         throw new IllegalArgumentException ("The value of '" +
1883                                             aName.get () +
1884                                             "' must be < 0! The current value is: " +
1885                                             nValue);
1886     return nValue;
1887   }
1888 
1889   public static long isLT0 (final long nValue, final String sName)
1890   {
1891     return isLT0 (nValue, () -> sName);
1892   }
1893 
1894   public static long isLT0 (final long nValue, @Nonnull final Supplier <? extends String> aName)
1895   {
1896     if (isEnabled ())
1897       if (nValue >= 0)
1898         throw new IllegalArgumentException ("The value of '" +
1899                                             aName.get () +
1900                                             "' must be < 0! The current value is: " +
1901                                             nValue);
1902     return nValue;
1903   }
1904 
1905   public static short isLT0 (final short nValue, final String sName)
1906   {
1907     return isLT0 (nValue, () -> sName);
1908   }
1909 
1910   public static short isLT0 (final short nValue, @Nonnull final Supplier <? extends String> aName)
1911   {
1912     if (isEnabled ())
1913       if (nValue >= 0)
1914         throw new IllegalArgumentException ("The value of '" +
1915                                             aName.get () +
1916                                             "' must be < 0! The current value is: " +
1917                                             nValue);
1918     return nValue;
1919   }
1920 
1921   public static double isLT0 (final double dValue, final String sName)
1922   {
1923     return isLT0 (dValue, () -> sName);
1924   }
1925 
1926   public static double isLT0 (final double dValue, @Nonnull final Supplier <? extends String> aName)
1927   {
1928     if (isEnabled ())
1929       if (dValue >= 0)
1930         throw new IllegalArgumentException ("The value of '" +
1931                                             aName.get () +
1932                                             "' must be < 0! The current value is: " +
1933                                             dValue);
1934     return dValue;
1935   }
1936 
1937   public static float isLT0 (final float fValue, final String sName)
1938   {
1939     return isLT0 (fValue, () -> sName);
1940   }
1941 
1942   public static float isLT0 (final float fValue, @Nonnull final Supplier <? extends String> aName)
1943   {
1944     if (isEnabled ())
1945       if (fValue >= 0)
1946         throw new IllegalArgumentException ("The value of '" +
1947                                             aName.get () +
1948                                             "' must be < 0! The current value is: " +
1949                                             fValue);
1950     return fValue;
1951   }
1952 
1953   public static BigDecimal isLT0 (final BigDecimal aValue, final String sName)
1954   {
1955     return isLT0 (aValue, () -> sName);
1956   }
1957 
1958   public static BigDecimal isLT0 (final BigDecimal aValue, @Nonnull final Supplier <? extends String> aName)
1959   {
1960     notNull (aValue, aName);
1961     if (isEnabled ())
1962       if (aValue.compareTo (BigDecimal.ZERO) >= 0)
1963         throw new IllegalArgumentException ("The value of '" +
1964                                             aName.get () +
1965                                             "' must be < 0! The current value is: " +
1966                                             aValue);
1967     return aValue;
1968   }
1969 
1970   public static BigInteger isLT0 (final BigInteger aValue, final String sName)
1971   {
1972     return isLT0 (aValue, () -> sName);
1973   }
1974 
1975   public static BigInteger isLT0 (final BigInteger aValue, @Nonnull final Supplier <? extends String> aName)
1976   {
1977     notNull (aValue, aName);
1978     if (isEnabled ())
1979       if (aValue.compareTo (BigInteger.ZERO) >= 0)
1980         throw new IllegalArgumentException ("The value of '" +
1981                                             aName.get () +
1982                                             "' must be < 0! The current value is: " +
1983                                             aValue);
1984     return aValue;
1985   }
1986 
1987   /**
1988    * Check if
1989    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
1990    *
1991    * @param nValue
1992    *        Value
1993    * @param sName
1994    *        Name
1995    * @param nLowerBoundInclusive
1996    *        Lower bound
1997    * @param nUpperBoundInclusive
1998    *        Upper bound
1999    * @return The value
2000    */
2001   public static int isBetweenInclusive (final int nValue,
2002                                         final String sName,
2003                                         final int nLowerBoundInclusive,
2004                                         final int nUpperBoundInclusive)
2005   {
2006     return isBetweenInclusive (nValue, () -> sName, nLowerBoundInclusive, nUpperBoundInclusive);
2007   }
2008 
2009   /**
2010    * Check if
2011    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2012    *
2013    * @param nValue
2014    *        Value
2015    * @param aName
2016    *        Name
2017    * @param nLowerBoundInclusive
2018    *        Lower bound
2019    * @param nUpperBoundInclusive
2020    *        Upper bound
2021    * @return The value
2022    */
2023   public static int isBetweenInclusive (final int nValue,
2024                                         @Nonnull final Supplier <? extends String> aName,
2025                                         final int nLowerBoundInclusive,
2026                                         final int nUpperBoundInclusive)
2027   {
2028     if (isEnabled ())
2029       if (nValue < nLowerBoundInclusive || nValue > nUpperBoundInclusive)
2030         throw new IllegalArgumentException ("The value of '" +
2031                                             aName.get () +
2032                                             "' must be >= " +
2033                                             nLowerBoundInclusive +
2034                                             " and <= " +
2035                                             nUpperBoundInclusive +
2036                                             "! The current value is: " +
2037                                             nValue);
2038     return nValue;
2039   }
2040 
2041   /**
2042    * Check if
2043    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2044    *
2045    * @param nValue
2046    *        Value
2047    * @param sName
2048    *        Name
2049    * @param nLowerBoundInclusive
2050    *        Lower bound
2051    * @param nUpperBoundInclusive
2052    *        Upper bound
2053    * @return The value
2054    */
2055   public static long isBetweenInclusive (final long nValue,
2056                                          final String sName,
2057                                          final long nLowerBoundInclusive,
2058                                          final long nUpperBoundInclusive)
2059   {
2060     return isBetweenInclusive (nValue, () -> sName, nLowerBoundInclusive, nUpperBoundInclusive);
2061   }
2062 
2063   /**
2064    * Check if
2065    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2066    *
2067    * @param nValue
2068    *        Value
2069    * @param aName
2070    *        Name
2071    * @param nLowerBoundInclusive
2072    *        Lower bound
2073    * @param nUpperBoundInclusive
2074    *        Upper bound
2075    * @return The value
2076    */
2077   public static long isBetweenInclusive (final long nValue,
2078                                          @Nonnull final Supplier <? extends String> aName,
2079                                          final long nLowerBoundInclusive,
2080                                          final long nUpperBoundInclusive)
2081   {
2082     if (isEnabled ())
2083       if (nValue < nLowerBoundInclusive || nValue > nUpperBoundInclusive)
2084         throw new IllegalArgumentException ("The value of '" +
2085                                             aName.get () +
2086                                             "' must be >= " +
2087                                             nLowerBoundInclusive +
2088                                             " and <= " +
2089                                             nUpperBoundInclusive +
2090                                             "! The current value is: " +
2091                                             nValue);
2092     return nValue;
2093   }
2094 
2095   /**
2096    * Check if
2097    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2098    *
2099    * @param nValue
2100    *        Value
2101    * @param sName
2102    *        Name
2103    * @param nLowerBoundInclusive
2104    *        Lower bound
2105    * @param nUpperBoundInclusive
2106    *        Upper bound
2107    * @return The value
2108    */
2109   public static short isBetweenInclusive (final short nValue,
2110                                           final String sName,
2111                                           final short nLowerBoundInclusive,
2112                                           final short nUpperBoundInclusive)
2113   {
2114     return isBetweenInclusive (nValue, () -> sName, nLowerBoundInclusive, nUpperBoundInclusive);
2115   }
2116 
2117   /**
2118    * Check if
2119    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2120    *
2121    * @param nValue
2122    *        Value
2123    * @param aName
2124    *        Name
2125    * @param nLowerBoundInclusive
2126    *        Lower bound
2127    * @param nUpperBoundInclusive
2128    *        Upper bound
2129    * @return The value
2130    */
2131   public static short isBetweenInclusive (final short nValue,
2132                                           @Nonnull final Supplier <? extends String> aName,
2133                                           final short nLowerBoundInclusive,
2134                                           final short nUpperBoundInclusive)
2135   {
2136     if (isEnabled ())
2137       if (nValue < nLowerBoundInclusive || nValue > nUpperBoundInclusive)
2138         throw new IllegalArgumentException ("The value of '" +
2139                                             aName.get () +
2140                                             "' must be >= " +
2141                                             nLowerBoundInclusive +
2142                                             " and <= " +
2143                                             nUpperBoundInclusive +
2144                                             "! The current value is: " +
2145                                             nValue);
2146     return nValue;
2147   }
2148 
2149   /**
2150    * Check if
2151    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2152    *
2153    * @param dValue
2154    *        Value
2155    * @param sName
2156    *        Name
2157    * @param dLowerBoundInclusive
2158    *        Lower bound
2159    * @param dUpperBoundInclusive
2160    *        Upper bound
2161    * @return The value
2162    */
2163   public static double isBetweenInclusive (final double dValue,
2164                                            final String sName,
2165                                            final double dLowerBoundInclusive,
2166                                            final double dUpperBoundInclusive)
2167   {
2168     return isBetweenInclusive (dValue, () -> sName, dLowerBoundInclusive, dUpperBoundInclusive);
2169   }
2170 
2171   /**
2172    * Check if
2173    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2174    *
2175    * @param dValue
2176    *        Value
2177    * @param aName
2178    *        Name
2179    * @param dLowerBoundInclusive
2180    *        Lower bound
2181    * @param dUpperBoundInclusive
2182    *        Upper bound
2183    * @return The value
2184    */
2185   public static double isBetweenInclusive (final double dValue,
2186                                            @Nonnull final Supplier <? extends String> aName,
2187                                            final double dLowerBoundInclusive,
2188                                            final double dUpperBoundInclusive)
2189   {
2190     if (isEnabled ())
2191       if (dValue < dLowerBoundInclusive || dValue > dUpperBoundInclusive)
2192         throw new IllegalArgumentException ("The value of '" +
2193                                             aName.get () +
2194                                             "' must be >= " +
2195                                             dLowerBoundInclusive +
2196                                             " and <= " +
2197                                             dUpperBoundInclusive +
2198                                             "! The current value is: " +
2199                                             dValue);
2200     return dValue;
2201   }
2202 
2203   /**
2204    * Check if
2205    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2206    *
2207    * @param fValue
2208    *        Value
2209    * @param sName
2210    *        Name
2211    * @param fLowerBoundInclusive
2212    *        Lower bound
2213    * @param fUpperBoundInclusive
2214    *        Upper bound
2215    * @return The value
2216    */
2217   public static float isBetweenInclusive (final float fValue,
2218                                           final String sName,
2219                                           final float fLowerBoundInclusive,
2220                                           final float fUpperBoundInclusive)
2221   {
2222     return isBetweenInclusive (fValue, () -> sName, fLowerBoundInclusive, fUpperBoundInclusive);
2223   }
2224 
2225   /**
2226    * Check if
2227    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2228    *
2229    * @param fValue
2230    *        Value
2231    * @param aName
2232    *        Name
2233    * @param fLowerBoundInclusive
2234    *        Lower bound
2235    * @param fUpperBoundInclusive
2236    *        Upper bound
2237    * @return The value
2238    */
2239   public static float isBetweenInclusive (final float fValue,
2240                                           @Nonnull final Supplier <? extends String> aName,
2241                                           final float fLowerBoundInclusive,
2242                                           final float fUpperBoundInclusive)
2243   {
2244     if (isEnabled ())
2245       if (fValue < fLowerBoundInclusive || fValue > fUpperBoundInclusive)
2246         throw new IllegalArgumentException ("The value of '" +
2247                                             aName.get () +
2248                                             "' must be >= " +
2249                                             fLowerBoundInclusive +
2250                                             " and <= " +
2251                                             fUpperBoundInclusive +
2252                                             "! The current value is: " +
2253                                             fValue);
2254     return fValue;
2255   }
2256 
2257   /**
2258    * Check if
2259    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2260    *
2261    * @param aValue
2262    *        Value
2263    * @param sName
2264    *        Name
2265    * @param aLowerBoundInclusive
2266    *        Lower bound
2267    * @param aUpperBoundInclusive
2268    *        Upper bound
2269    * @return The value
2270    */
2271   public static BigDecimal isBetweenInclusive (final BigDecimal aValue,
2272                                                final String sName,
2273                                                @Nonnull final BigDecimal aLowerBoundInclusive,
2274                                                @Nonnull final BigDecimal aUpperBoundInclusive)
2275   {
2276     return isBetweenInclusive (aValue, () -> sName, aLowerBoundInclusive, aUpperBoundInclusive);
2277   }
2278 
2279   /**
2280    * Check if
2281    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2282    *
2283    * @param aValue
2284    *        Value
2285    * @param aName
2286    *        Name
2287    * @param aLowerBoundInclusive
2288    *        Lower bound
2289    * @param aUpperBoundInclusive
2290    *        Upper bound
2291    * @return The value
2292    */
2293   public static BigDecimal isBetweenInclusive (final BigDecimal aValue,
2294                                                @Nonnull final Supplier <? extends String> aName,
2295                                                @Nonnull final BigDecimal aLowerBoundInclusive,
2296                                                @Nonnull final BigDecimal aUpperBoundInclusive)
2297   {
2298     notNull (aValue, aName);
2299     notNull (aLowerBoundInclusive, "LowerBoundInclusive");
2300     notNull (aUpperBoundInclusive, "UpperBoundInclusive");
2301     if (isEnabled ())
2302       if (aValue.compareTo (aLowerBoundInclusive) < 0 || aValue.compareTo (aUpperBoundInclusive) > 0)
2303         throw new IllegalArgumentException ("The value of '" +
2304                                             aName.get () +
2305                                             "' must be >= " +
2306                                             aLowerBoundInclusive +
2307                                             " and <= " +
2308                                             aUpperBoundInclusive +
2309                                             "! The current value is: " +
2310                                             aValue);
2311     return aValue;
2312   }
2313 
2314   /**
2315    * Check if
2316    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2317    *
2318    * @param aValue
2319    *        Value
2320    * @param sName
2321    *        Name
2322    * @param aLowerBoundInclusive
2323    *        Lower bound
2324    * @param aUpperBoundInclusive
2325    *        Upper bound
2326    * @return The value
2327    */
2328   public static BigInteger isBetweenInclusive (final BigInteger aValue,
2329                                                final String sName,
2330                                                @Nonnull final BigInteger aLowerBoundInclusive,
2331                                                @Nonnull final BigInteger aUpperBoundInclusive)
2332   {
2333     return isBetweenInclusive (aValue, () -> sName, aLowerBoundInclusive, aUpperBoundInclusive);
2334   }
2335 
2336   /**
2337    * Check if
2338    * <code>nValue &ge; nLowerBoundInclusive &amp;&amp; nValue &le; nUpperBoundInclusive</code>
2339    *
2340    * @param aValue
2341    *        Value
2342    * @param aName
2343    *        Name
2344    * @param aLowerBoundInclusive
2345    *        Lower bound
2346    * @param aUpperBoundInclusive
2347    *        Upper bound
2348    * @return The value
2349    */
2350   public static BigInteger isBetweenInclusive (final BigInteger aValue,
2351                                                @Nonnull final Supplier <? extends String> aName,
2352                                                @Nonnull final BigInteger aLowerBoundInclusive,
2353                                                @Nonnull final BigInteger aUpperBoundInclusive)
2354   {
2355     notNull (aValue, aName);
2356     notNull (aLowerBoundInclusive, "LowerBoundInclusive");
2357     notNull (aUpperBoundInclusive, "UpperBoundInclusive");
2358     if (isEnabled ())
2359       if (aValue.compareTo (aLowerBoundInclusive) < 0 || aValue.compareTo (aUpperBoundInclusive) > 0)
2360         throw new IllegalArgumentException ("The value of '" +
2361                                             aName.get () +
2362                                             "' must be >= " +
2363                                             aLowerBoundInclusive +
2364                                             " and <= " +
2365                                             aUpperBoundInclusive +
2366                                             "! The current value is: " +
2367                                             aValue);
2368     return aValue;
2369   }
2370 
2371   /**
2372    * Check if
2373    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2374    *
2375    * @param nValue
2376    *        Value
2377    * @param sName
2378    *        Name
2379    * @param nLowerBoundExclusive
2380    *        Lower bound
2381    * @param nUpperBoundExclusive
2382    *        Upper bound
2383    * @return The value
2384    */
2385   public static int isBetweenExclusive (final int nValue,
2386                                         final String sName,
2387                                         final int nLowerBoundExclusive,
2388                                         final int nUpperBoundExclusive)
2389   {
2390     return isBetweenExclusive (nValue, () -> sName, nLowerBoundExclusive, nUpperBoundExclusive);
2391   }
2392 
2393   /**
2394    * Check if
2395    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2396    *
2397    * @param nValue
2398    *        Value
2399    * @param aName
2400    *        Name
2401    * @param nLowerBoundExclusive
2402    *        Lower bound
2403    * @param nUpperBoundExclusive
2404    *        Upper bound
2405    * @return The value
2406    */
2407   public static int isBetweenExclusive (final int nValue,
2408                                         @Nonnull final Supplier <? extends String> aName,
2409                                         final int nLowerBoundExclusive,
2410                                         final int nUpperBoundExclusive)
2411   {
2412     if (isEnabled ())
2413       if (nValue <= nLowerBoundExclusive || nValue >= nUpperBoundExclusive)
2414         throw new IllegalArgumentException ("The value of '" +
2415                                             aName.get () +
2416                                             "' must be > " +
2417                                             nLowerBoundExclusive +
2418                                             " and < " +
2419                                             nUpperBoundExclusive +
2420                                             "! The current value is: " +
2421                                             nValue);
2422     return nValue;
2423   }
2424 
2425   /**
2426    * Check if
2427    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2428    *
2429    * @param nValue
2430    *        Value
2431    * @param sName
2432    *        Name
2433    * @param nLowerBoundExclusive
2434    *        Lower bound
2435    * @param nUpperBoundExclusive
2436    *        Upper bound
2437    * @return The value
2438    */
2439   public static long isBetweenExclusive (final long nValue,
2440                                          final String sName,
2441                                          final long nLowerBoundExclusive,
2442                                          final long nUpperBoundExclusive)
2443   {
2444     return isBetweenExclusive (nValue, () -> sName, nLowerBoundExclusive, nUpperBoundExclusive);
2445   }
2446 
2447   /**
2448    * Check if
2449    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2450    *
2451    * @param nValue
2452    *        Value
2453    * @param aName
2454    *        Name
2455    * @param nLowerBoundExclusive
2456    *        Lower bound
2457    * @param nUpperBoundExclusive
2458    *        Upper bound
2459    * @return The value
2460    */
2461   public static long isBetweenExclusive (final long nValue,
2462                                          @Nonnull final Supplier <? extends String> aName,
2463                                          final long nLowerBoundExclusive,
2464                                          final long nUpperBoundExclusive)
2465   {
2466     if (isEnabled ())
2467       if (nValue <= nLowerBoundExclusive || nValue >= nUpperBoundExclusive)
2468         throw new IllegalArgumentException ("The value of '" +
2469                                             aName.get () +
2470                                             "' must be > " +
2471                                             nLowerBoundExclusive +
2472                                             " and < " +
2473                                             nUpperBoundExclusive +
2474                                             "! The current value is: " +
2475                                             nValue);
2476     return nValue;
2477   }
2478 
2479   /**
2480    * Check if
2481    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2482    *
2483    * @param nValue
2484    *        Value
2485    * @param sName
2486    *        Name
2487    * @param nLowerBoundExclusive
2488    *        Lower bound
2489    * @param nUpperBoundExclusive
2490    *        Upper bound
2491    * @return The value
2492    */
2493   public static short isBetweenExclusive (final short nValue,
2494                                           final String sName,
2495                                           final short nLowerBoundExclusive,
2496                                           final short nUpperBoundExclusive)
2497   {
2498     return isBetweenExclusive (nValue, () -> sName, nLowerBoundExclusive, nUpperBoundExclusive);
2499   }
2500 
2501   /**
2502    * Check if
2503    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2504    *
2505    * @param nValue
2506    *        Value
2507    * @param aName
2508    *        Name
2509    * @param nLowerBoundExclusive
2510    *        Lower bound
2511    * @param nUpperBoundExclusive
2512    *        Upper bound
2513    * @return The value
2514    */
2515   public static short isBetweenExclusive (final short nValue,
2516                                           @Nonnull final Supplier <? extends String> aName,
2517                                           final short nLowerBoundExclusive,
2518                                           final short nUpperBoundExclusive)
2519   {
2520     if (isEnabled ())
2521       if (nValue <= nLowerBoundExclusive || nValue >= nUpperBoundExclusive)
2522         throw new IllegalArgumentException ("The value of '" +
2523                                             aName.get () +
2524                                             "' must be > " +
2525                                             nLowerBoundExclusive +
2526                                             " and < " +
2527                                             nUpperBoundExclusive +
2528                                             "! The current value is: " +
2529                                             nValue);
2530     return nValue;
2531   }
2532 
2533   /**
2534    * Check if
2535    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2536    *
2537    * @param dValue
2538    *        Value
2539    * @param sName
2540    *        Name
2541    * @param dLowerBoundExclusive
2542    *        Lower bound
2543    * @param dUpperBoundExclusive
2544    *        Upper bound
2545    * @return The value
2546    */
2547   public static double isBetweenExclusive (final double dValue,
2548                                            final String sName,
2549                                            final double dLowerBoundExclusive,
2550                                            final double dUpperBoundExclusive)
2551   {
2552     return isBetweenExclusive (dValue, () -> sName, dLowerBoundExclusive, dUpperBoundExclusive);
2553   }
2554 
2555   /**
2556    * Check if
2557    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2558    *
2559    * @param dValue
2560    *        Value
2561    * @param aName
2562    *        Name
2563    * @param dLowerBoundExclusive
2564    *        Lower bound
2565    * @param dUpperBoundExclusive
2566    *        Upper bound
2567    * @return The value
2568    */
2569   public static double isBetweenExclusive (final double dValue,
2570                                            @Nonnull final Supplier <? extends String> aName,
2571                                            final double dLowerBoundExclusive,
2572                                            final double dUpperBoundExclusive)
2573   {
2574     if (isEnabled ())
2575       if (dValue <= dLowerBoundExclusive || dValue >= dUpperBoundExclusive)
2576         throw new IllegalArgumentException ("The value of '" +
2577                                             aName.get () +
2578                                             "' must be > " +
2579                                             dLowerBoundExclusive +
2580                                             " and < " +
2581                                             dUpperBoundExclusive +
2582                                             "! The current value is: " +
2583                                             dValue);
2584     return dValue;
2585   }
2586 
2587   /**
2588    * Check if
2589    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2590    *
2591    * @param fValue
2592    *        Value
2593    * @param sName
2594    *        Name
2595    * @param fLowerBoundExclusive
2596    *        Lower bound
2597    * @param fUpperBoundExclusive
2598    *        Upper bound
2599    * @return The value
2600    */
2601   public static float isBetweenExclusive (final float fValue,
2602                                           final String sName,
2603                                           final float fLowerBoundExclusive,
2604                                           final float fUpperBoundExclusive)
2605   {
2606     return isBetweenExclusive (fValue, () -> sName, fLowerBoundExclusive, fUpperBoundExclusive);
2607   }
2608 
2609   /**
2610    * Check if
2611    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2612    *
2613    * @param fValue
2614    *        Value
2615    * @param aName
2616    *        Name
2617    * @param fLowerBoundExclusive
2618    *        Lower bound
2619    * @param fUpperBoundExclusive
2620    *        Upper bound
2621    * @return The value
2622    */
2623   public static float isBetweenExclusive (final float fValue,
2624                                           @Nonnull final Supplier <? extends String> aName,
2625                                           final float fLowerBoundExclusive,
2626                                           final float fUpperBoundExclusive)
2627   {
2628     if (isEnabled ())
2629       if (fValue <= fLowerBoundExclusive || fValue >= fUpperBoundExclusive)
2630         throw new IllegalArgumentException ("The value of '" +
2631                                             aName.get () +
2632                                             "' must be > " +
2633                                             fLowerBoundExclusive +
2634                                             " and < " +
2635                                             fUpperBoundExclusive +
2636                                             "! The current value is: " +
2637                                             fValue);
2638     return fValue;
2639   }
2640 
2641   /**
2642    * Check if
2643    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2644    *
2645    * @param aValue
2646    *        Value
2647    * @param sName
2648    *        Name
2649    * @param aLowerBoundExclusive
2650    *        Lower bound
2651    * @param aUpperBoundExclusive
2652    *        Upper bound
2653    * @return The value
2654    */
2655   public static BigDecimal isBetweenExclusive (final BigDecimal aValue,
2656                                                final String sName,
2657                                                @Nonnull final BigDecimal aLowerBoundExclusive,
2658                                                @Nonnull final BigDecimal aUpperBoundExclusive)
2659   {
2660     return isBetweenExclusive (aValue, () -> sName, aLowerBoundExclusive, aUpperBoundExclusive);
2661   }
2662 
2663   /**
2664    * Check if
2665    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2666    *
2667    * @param aValue
2668    *        Value
2669    * @param aName
2670    *        Name
2671    * @param aLowerBoundExclusive
2672    *        Lower bound
2673    * @param aUpperBoundExclusive
2674    *        Upper bound
2675    * @return The value
2676    */
2677   public static BigDecimal isBetweenExclusive (final BigDecimal aValue,
2678                                                @Nonnull final Supplier <? extends String> aName,
2679                                                @Nonnull final BigDecimal aLowerBoundExclusive,
2680                                                @Nonnull final BigDecimal aUpperBoundExclusive)
2681   {
2682     notNull (aValue, aName);
2683     notNull (aLowerBoundExclusive, "LowerBoundInclusive");
2684     notNull (aUpperBoundExclusive, "UpperBoundInclusive");
2685     if (isEnabled ())
2686       if (aValue.compareTo (aLowerBoundExclusive) <= 0 || aValue.compareTo (aUpperBoundExclusive) >= 0)
2687         throw new IllegalArgumentException ("The value of '" +
2688                                             aName.get () +
2689                                             "' must be > " +
2690                                             aLowerBoundExclusive +
2691                                             " and < " +
2692                                             aUpperBoundExclusive +
2693                                             "! The current value is: " +
2694                                             aValue);
2695     return aValue;
2696   }
2697 
2698   /**
2699    * Check if
2700    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2701    *
2702    * @param aValue
2703    *        Value
2704    * @param sName
2705    *        Name
2706    * @param aLowerBoundExclusive
2707    *        Lower bound
2708    * @param aUpperBoundExclusive
2709    *        Upper bound
2710    * @return The value
2711    */
2712   public static BigInteger isBetweenExclusive (final BigInteger aValue,
2713                                                final String sName,
2714                                                @Nonnull final BigInteger aLowerBoundExclusive,
2715                                                @Nonnull final BigInteger aUpperBoundExclusive)
2716   {
2717     return isBetweenExclusive (aValue, () -> sName, aLowerBoundExclusive, aUpperBoundExclusive);
2718   }
2719 
2720   /**
2721    * Check if
2722    * <code>nValue &gt; nLowerBoundInclusive &amp;&amp; nValue &lt; nUpperBoundInclusive</code>
2723    *
2724    * @param aValue
2725    *        Value
2726    * @param aName
2727    *        Name
2728    * @param aLowerBoundExclusive
2729    *        Lower bound
2730    * @param aUpperBoundExclusive
2731    *        Upper bound
2732    * @return The value
2733    */
2734   public static BigInteger isBetweenExclusive (final BigInteger aValue,
2735                                                @Nonnull final Supplier <? extends String> aName,
2736                                                @Nonnull final BigInteger aLowerBoundExclusive,
2737                                                @Nonnull final BigInteger aUpperBoundExclusive)
2738   {
2739     notNull (aValue, aName);
2740     notNull (aLowerBoundExclusive, "LowerBoundInclusive");
2741     notNull (aUpperBoundExclusive, "UpperBoundInclusive");
2742     if (isEnabled ())
2743       if (aValue.compareTo (aLowerBoundExclusive) <= 0 || aValue.compareTo (aUpperBoundExclusive) >= 0)
2744         throw new IllegalArgumentException ("The value of '" +
2745                                             aName.get () +
2746                                             "' must be > " +
2747                                             aLowerBoundExclusive +
2748                                             " and < " +
2749                                             aUpperBoundExclusive +
2750                                             "! The current value is: " +
2751                                             aValue);
2752     return aValue;
2753   }
2754 
2755   private static void _isArrayOfsLen (@Nonnegative final int nArrayLen,
2756                                       @Nonnegative final int nOfs,
2757                                       @Nonnegative final int nLen)
2758   {
2759     isGE0 (nOfs, "Offset");
2760     isGE0 (nLen, "Length");
2761     if (isEnabled ())
2762       if ((nOfs + nLen) > nArrayLen)
2763         throw new IllegalArgumentException ("Offset (" +
2764                                             nOfs +
2765                                             ") + length (" +
2766                                             nLen +
2767                                             ") exceeds array length (" +
2768                                             nArrayLen +
2769                                             ")");
2770 
2771   }
2772 
2773   public static void isArrayOfsLen (final Object [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2774   {
2775     notNull (aArray, "Array");
2776     _isArrayOfsLen (aArray.length, nOfs, nLen);
2777   }
2778 
2779   public static void isArrayOfsLen (final boolean [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2780   {
2781     notNull (aArray, "Array");
2782     _isArrayOfsLen (aArray.length, nOfs, nLen);
2783   }
2784 
2785   public static void isArrayOfsLen (final byte [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2786   {
2787     notNull (aArray, "Array");
2788     _isArrayOfsLen (aArray.length, nOfs, nLen);
2789   }
2790 
2791   public static void isArrayOfsLen (final char [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2792   {
2793     notNull (aArray, "Array");
2794     _isArrayOfsLen (aArray.length, nOfs, nLen);
2795   }
2796 
2797   public static void isArrayOfsLen (final double [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2798   {
2799     notNull (aArray, "Array");
2800     _isArrayOfsLen (aArray.length, nOfs, nLen);
2801   }
2802 
2803   public static void isArrayOfsLen (final float [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2804   {
2805     notNull (aArray, "Array");
2806     _isArrayOfsLen (aArray.length, nOfs, nLen);
2807   }
2808 
2809   public static void isArrayOfsLen (final int [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2810   {
2811     notNull (aArray, "Array");
2812     _isArrayOfsLen (aArray.length, nOfs, nLen);
2813   }
2814 
2815   public static void isArrayOfsLen (final long [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2816   {
2817     notNull (aArray, "Array");
2818     _isArrayOfsLen (aArray.length, nOfs, nLen);
2819   }
2820 
2821   public static void isArrayOfsLen (final short [] aArray, @Nonnegative final int nOfs, @Nonnegative final int nLen)
2822   {
2823     notNull (aArray, "Array");
2824     _isArrayOfsLen (aArray.length, nOfs, nLen);
2825   }
2826 }