com.github.cowwoc.requirements.DefaultRequirements Maven / Gradle / Ivy
Show all versions of token-bucket Show documentation
/*
* Copyright 2013 Gili Tzabari.
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/
package com.github.cowwoc.requirements;
import com.github.cowwoc.requirements.annotation.CheckReturnValue;
import java.math.BigDecimal;
import java.net.InetAddress;
import java.net.URI;
import java.net.URL;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import com.github.cowwoc.requirements.java.JavaRequirements;
import java.lang.String;
import com.github.cowwoc.requirements.java.ObjectVerifier;
import com.github.cowwoc.requirements.java.ObjectValidator;
import com.github.cowwoc.requirements.java.CollectionVerifier;
import com.github.cowwoc.requirements.java.CollectionValidator;
import com.github.cowwoc.requirements.java.ListVerifier;
import com.github.cowwoc.requirements.java.ListValidator;
import com.github.cowwoc.requirements.java.ArrayVerifier;
import com.github.cowwoc.requirements.java.ArrayValidator;
import com.github.cowwoc.requirements.java.ComparableVerifier;
import com.github.cowwoc.requirements.java.ComparableValidator;
import com.github.cowwoc.requirements.java.PrimitiveNumberVerifier;
import com.github.cowwoc.requirements.java.PrimitiveNumberValidator;
import com.github.cowwoc.requirements.java.PrimitiveIntegerVerifier;
import com.github.cowwoc.requirements.java.PrimitiveIntegerValidator;
import com.github.cowwoc.requirements.java.IntegerVerifier;
import com.github.cowwoc.requirements.java.IntegerValidator;
import com.github.cowwoc.requirements.java.PrimitiveFloatingPointVerifier;
import com.github.cowwoc.requirements.java.PrimitiveFloatingPointValidator;
import com.github.cowwoc.requirements.java.PrimitiveBooleanVerifier;
import com.github.cowwoc.requirements.java.PrimitiveBooleanValidator;
import com.github.cowwoc.requirements.java.PrimitiveCharacterVerifier;
import com.github.cowwoc.requirements.java.PrimitiveCharacterValidator;
import com.github.cowwoc.requirements.java.NumberVerifier;
import com.github.cowwoc.requirements.java.NumberValidator;
import com.github.cowwoc.requirements.java.BooleanVerifier;
import com.github.cowwoc.requirements.java.BooleanValidator;
import com.github.cowwoc.requirements.java.FloatingPointVerifier;
import com.github.cowwoc.requirements.java.FloatingPointValidator;
import com.github.cowwoc.requirements.java.BigDecimalVerifier;
import com.github.cowwoc.requirements.java.BigDecimalValidator;
import com.github.cowwoc.requirements.java.MapVerifier;
import com.github.cowwoc.requirements.java.MapValidator;
import com.github.cowwoc.requirements.java.PathVerifier;
import com.github.cowwoc.requirements.java.PathValidator;
import com.github.cowwoc.requirements.java.StringVerifier;
import com.github.cowwoc.requirements.java.StringValidator;
import com.github.cowwoc.requirements.java.UriVerifier;
import com.github.cowwoc.requirements.java.UriValidator;
import com.github.cowwoc.requirements.java.UrlVerifier;
import com.github.cowwoc.requirements.java.UrlValidator;
import com.github.cowwoc.requirements.java.ClassVerifier;
import com.github.cowwoc.requirements.java.ClassValidator;
import com.github.cowwoc.requirements.java.OptionalVerifier;
import com.github.cowwoc.requirements.java.OptionalValidator;
import com.github.cowwoc.requirements.java.InetAddressVerifier;
import com.github.cowwoc.requirements.java.InetAddressValidator;
import com.github.cowwoc.requirements.java.DefaultJavaRequirements;
import com.github.cowwoc.requirements.java.Configuration;
import com.github.cowwoc.requirements.java.ThreadRequirements;
import java.util.function.Consumer;
import java.util.function.Function;
/**
* Verifies requirements using the default {@link Configuration configuration}. Any method that exposes
* a {@code Requirements} instance is returning an independent copy. Any modifications applied to that
* copy are thrown away and do not affect the configuration of this class.
*
* To retain configuration changes, instantiate and reuse the same {@code Requirements} instance across
* multiple runs.
*
* Thread-safety: This class is thread-safe.
*
* @see Requirements
* @see JavaRequirements
*/
public final class DefaultRequirements
{
private static final Requirements REQUIREMENTS = new Requirements();
/**
* Returns true if assertions are enabled for this class.
*
* @return true if assertions are enabled for this class
*/
public static boolean assertionsAreEnabled()
{
return REQUIREMENTS.assertionsAreEnabled();
}
/**
* Indicates that {@code assertThat()} should verify requirements.
*
* @return a new {@code Requirements} object that operates independently of the original instance
*/
public static Requirements withAssertionsEnabled()
{
return REQUIREMENTS.copy().withAssertionsEnabled();
}
/**
* Indicates that {@code assertThat()} shouldn't do anything.
*
* @return a new {@code Requirements} object that operates independently of the original instance
*/
public static Requirements withAssertionsDisabled()
{
return REQUIREMENTS.copy().withAssertionsDisabled();
}
/**
* Indicates if exceptions should show the difference between the actual and expected values.
*
* @return true by default
*/
public static boolean isDiffEnabled()
{
return REQUIREMENTS.isDiffEnabled();
}
/**
* Indicates that exceptions should show the difference between the actual and expected values.
*
* @return a new {@code Requirements} object that operates independently of the original instance
*/
public static Requirements withDiff()
{
return REQUIREMENTS.copy().withDiff();
}
/**
* Indicates that exceptions should not show the difference between the actual and expected
* values.
*
* @return a new {@code Requirements} object that operates independently of the original instance
*/
public static Requirements withoutDiff()
{
return REQUIREMENTS.copy().withDiff();
}
/**
* Indicates if stack trace references to this library should be removed.
*
* @return {@code true} by default
* @see #withCleanStackTrace()
* @see #withoutCleanStackTrace()
*/
public static boolean isCleanStackTrace()
{
return REQUIREMENTS.isCleanStackTrace();
}
/**
* Indicates that stack trace references to this library should be removed.
*
* @return a new {@code Requirements} object that operates independently of the original instance
* @see #isCleanStackTrace()
*/
public static Requirements withCleanStackTrace()
{
return REQUIREMENTS.copy().withCleanStackTrace();
}
/**
* Indicates that stack trace references to this library should be kept.
*
* @return a new {@code Requirements} object that operates independently of the original instance
* @see #isCleanStackTrace()
*/
public static Requirements withoutCleanStackTrace()
{
return REQUIREMENTS.copy().withoutCleanStackTrace();
}
/**
* Returns an unmodifiable map to append to the exception message.
*
* @return an empty map by default
* @see #withContext(String, Object)
*/
public static Map getContext()
{
return REQUIREMENTS.getContext();
}
/**
* Adds or updates contextual information associated with the exception message. Overrides any values
* associated with the {@code name} at the {@link ThreadRequirements} level.
*
* @param name the name of the parameter
* @param value the value of the parameter
* @return a new {@code Requirements} object that operates independently of the original instance
* @throws NullPointerException if {@code name} is null
*/
public static Requirements withContext(String name, Object value)
{
return REQUIREMENTS.copy().withContext(name, value);
}
/**
* Returns the contextual information associated with this configuration.
*
* @param message the exception message ({@code null} if absent)
* @return the contextual information associated with this configuration
*/
public static String getContextMessage(String message)
{
return REQUIREMENTS.getContextMessage(message);
}
/**
* Returns the {@code String} representation of an object. By default, custom handlers are provided for
* arrays, {@code Integer}, {@code Long}, {@code BigDecimal}, and {@code Path}.
*
* @param value a value
* @return the {@code String} representation of the value
* @see #withStringConverter(Class, Function)
*/
public static String toString(Object value)
{
return REQUIREMENTS.toString(value);
}
/**
* Indicates that a function should be used to convert an object to a String.
*
* Please note that {@code type} must be an exact match (e.g. configuring a converter for
* {@code Set} will not match values of type {@code HashSet}).
*
* @param the type of object being converted
* @param type the type of object being converted (non-primitive arrays are mapped to
* {@code Object[].class})
* @param converter a function that converts an object of the specified type to a String
* @return a new {@code Requirements} object that operates independently of the original instance
* @throws NullPointerException if any of the arguments are null
*/
public static Requirements withStringConverter(Class type, Function converter)
{
return REQUIREMENTS.copy().withStringConverter(type, converter);
}
/**
* Indicates that an object's {@code toString()} method should be used to convert it to a String.
*
* @param the type of object being converted
* @param type the type of object being converted
* @return a new {@code Requirements} object that operates independently of the original instance
* @throws NullPointerException if {@code type} is null
*/
public static Requirements withoutStringConverter(Class type)
{
return REQUIREMENTS.copy().withoutStringConverter(type);
}
/**
* Replaces the configuration.
*
* @param configuration a new configuration
* @return a new {@code Requirements} object that operates independently of the original instance
* @throws NullPointerException if {@code configuration} is null
*/
public static Requirements withConfiguration(Configuration configuration)
{
return REQUIREMENTS.copy().withConfiguration(configuration);
}
/**
* Verifies requirements only if {@link Configuration#assertionsAreEnabled() assertions are enabled}.
*
* @param the return value of the operation
* @param requirements the requirements to verify
* @return the return value of the operation, or {@code null} if assertions are disabled
* @throws NullPointerException if {@code requirements} is null
* @see #assertThat(Consumer)
*/
public static V assertThatAndReturn(Function requirements)
{
// Use a simple if-statement to reduce computation/allocation when assertions are disabled
if (requirements == null)
throw new IllegalArgumentException("requirements may not be null");
if (!assertionsAreEnabled())
return null;
Requirements copy = REQUIREMENTS.copy();
return requirements.apply(copy);
}
/**
* Verifies requirements only if assertions are enabled.
*
* @param requirements the requirements to verify
* @throws NullPointerException if {@code requirements} is null
* @see #assertThatAndReturn(Function)
*/
public static void assertThat(Consumer requirements)
{
// Use a simple if-statement to reduce computation/allocation when assertions are disabled
if (requirements == null)
throw new IllegalArgumentException("requirements may not be null");
if (!assertionsAreEnabled())
return;
Requirements copy = REQUIREMENTS.copy();
requirements.accept(copy);
}
/**
* Verifies the requirements of an {@code Object}.
*
* @param the type of the value
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ObjectVerifier requireThat(T actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of an {@code Object}.
*
* @param the type of the value
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ObjectValidator validateThat(T actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code Collection}.
*
* @param the type of the collection
* @param the type of elements in the collection
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static , E> CollectionVerifier requireThat(C actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code Collection}.
*
* @param the type of the collection
* @param the type of elements in the collection
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static , E> CollectionValidator validateThat(C actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code List}.
*
* @param the type of the list
* @param the type of elements in the list
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static , E> ListVerifier requireThat(L actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code List}.
*
* @param the type of the list
* @param the type of elements in the list
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static , E> ListValidator validateThat(L actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a primitive {@code byte} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayVerifier requireThat(byte[] actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a primitive {@code byte} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayValidator validateThat(byte[] actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a primitive {@code short} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayVerifier requireThat(short[] actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a primitive {@code short} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayValidator validateThat(short[] actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a primitive {@code int} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayVerifier requireThat(int[] actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a primitive {@code int} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayValidator validateThat(int[] actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a primitive {@code long} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayVerifier requireThat(long[] actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a primitive {@code long} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayValidator validateThat(long[] actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a primitive {@code float} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayVerifier requireThat(float[] actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a primitive {@code float} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayValidator validateThat(float[] actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a primitive {@code double} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayVerifier requireThat(double[] actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a primitive {@code double} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayValidator validateThat(double[] actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a primitive {@code boolean} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayVerifier requireThat(boolean[] actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a primitive {@code boolean} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayValidator validateThat(boolean[] actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a primitive {@code char} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayVerifier requireThat(char[] actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a primitive {@code char} array.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayValidator validateThat(char[] actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of an {@code Object} array.
*
* @param the type of elements in the array
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayVerifier requireThat(E[] actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of an {@code Object} array.
*
* @param the type of elements in the array
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ArrayValidator validateThat(E[] actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code Comparable}.
*
* @param the type of objects that the value may be compared to
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static > ComparableVerifier requireThat(T actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code Comparable}.
*
* @param the type of objects that the value may be compared to
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static > ComparableValidator validateThat(T actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code byte}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveNumberVerifier requireThat(byte actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code byte}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveNumberValidator validateThat(byte actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code short}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveNumberVerifier requireThat(short actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code short}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveNumberValidator validateThat(short actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of an {@code int}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveIntegerVerifier requireThat(int actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of an {@code int}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveIntegerValidator validateThat(int actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of an {@code Integer}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static IntegerVerifier requireThat(Integer actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of an {@code Integer}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static IntegerValidator validateThat(Integer actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code long}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveIntegerVerifier requireThat(long actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code long}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveIntegerValidator validateThat(long actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code Long}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static IntegerVerifier requireThat(Long actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code Long}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static IntegerValidator validateThat(Long actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code float}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveFloatingPointVerifier requireThat(float actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code float}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveFloatingPointValidator validateThat(float actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code double}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveFloatingPointVerifier requireThat(double actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code double}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveFloatingPointValidator validateThat(double actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code boolean}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveBooleanVerifier requireThat(boolean actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code boolean}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveBooleanValidator validateThat(boolean actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code char}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveCharacterVerifier requireThat(char actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code char}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PrimitiveCharacterValidator validateThat(char actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code Number}.
*
* @param the type of the number
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static > NumberVerifier requireThat(T actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code Number}.
*
* @param the type of the number
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static > NumberValidator validateThat(T actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code Boolean}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static BooleanVerifier requireThat(Boolean actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code Boolean}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static BooleanValidator validateThat(Boolean actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code Float}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static FloatingPointVerifier requireThat(Float actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code Float}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static FloatingPointValidator validateThat(Float actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code Double}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static FloatingPointVerifier requireThat(Double actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code Double}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static FloatingPointValidator validateThat(Double actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code BigDecimal}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static BigDecimalVerifier requireThat(BigDecimal actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code BigDecimal}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static BigDecimalValidator validateThat(BigDecimal actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code Map}.
*
* @param the type of key in the map
* @param the type of value in the map
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static MapVerifier requireThat(Map actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code Map}.
*
* @param the type of key in the map
* @param the type of value in the map
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static MapValidator validateThat(Map actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code Path}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PathVerifier requireThat(Path actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code Path}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static PathValidator validateThat(Path actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code String}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static StringVerifier requireThat(String actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code String}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static StringValidator validateThat(String actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code URI}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static UriVerifier requireThat(URI actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code URI}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static UriValidator validateThat(URI actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code URL}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static UrlVerifier requireThat(URL actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code URL}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static UrlValidator validateThat(URL actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of a {@code Class}.
*
* @param the type of class
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ClassVerifier requireThat(Class actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of a {@code Class}.
*
* @param the type of class
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static ClassValidator validateThat(Class actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of an {@code Optional}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static OptionalVerifier requireThat(Optional> actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of an {@code Optional}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static OptionalValidator validateThat(Optional> actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Verifies the requirements of an {@code InetAddress}.
*
* @param actual the actual value
* @param name the name of the value
* @return a verifier for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static InetAddressVerifier requireThat(InetAddress actual, String name)
{
return REQUIREMENTS.requireThat(actual, name);
}
/**
* Validates the requirements of an {@code InetAddress}.
*
* @param actual the actual value
* @param name the name of the value
* @return a validator for the value
* @throws NullPointerException if {@code name} is null
* @throws IllegalArgumentException if {@code name} is blank
*/
@CheckReturnValue
public static InetAddressValidator validateThat(InetAddress actual, String name)
{
return REQUIREMENTS.validateThat(actual, name);
}
/**
* Prevent construction.
*/
private DefaultRequirements()
{
}
}