org.javimmutable.collections.common.Conditions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javimmutable-collections Show documentation
Show all versions of javimmutable-collections Show documentation
Library providing immutable/persistent collection classes for
Java. While collections are immutable they provide methods for
adding and removing values by creating new modified copies of
themselves. Each copy shares almost all of its structure with
other copies to minimize memory consumption.
package org.javimmutable.collections.common;
/**
* Utility class containing static methods for implementing pre and post conditions.
*/
public final class Conditions
{
private Conditions()
{
// prevent class being instantiated
}
public static void stopNull(Object a)
{
if (a == null) {
throw new NullPointerException();
}
}
public static void stopNull(Object a,
Object b)
{
if (a == null || b == null) {
throw new NullPointerException();
}
}
public static void stopNull(Object a,
Object b,
Object c)
{
if (a == null || b == null || c == null) {
throw new NullPointerException();
}
}
public static void stopNull(Object a,
Object b,
Object c,
Object d)
{
if (a == null || b == null || c == null || d == null) {
throw new NullPointerException();
}
}
}