All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jbakery.arguments.Argument Maven / Gradle / Ivy

package org.jbakery.arguments;

public final class Argument
{
	private Argument() { }

	public static String notEmpty(String argument, String argumentName)
	{
		Argument.notNull(argumentName, "argumentName");
		Argument.notNull(argument, argumentName);

		if (argument.isEmpty())
			throw new EmptyArgumentException(argumentName);

		return argument;
	}

	public static byte notNegative(byte argument, String argumentName)
	{
		Argument.notNull(argumentName, "argumentName");

		if (argument < 0)
			throw new NegativeArgumentException(argumentName);

		return argument;
	}

	public static short notNegative(short argument, String argumentName)
	{
		Argument.notNull(argumentName, "argumentName");

		if (argument < 0)
			throw new NegativeArgumentException(argumentName);

		return argument;
	}

	public static int notNegative(int argument, String argumentName)
	{
		Argument.notNull(argumentName, "argumentName");

		if (argument < 0)
			throw new NegativeArgumentException(argumentName);

		return argument;
	}

	public static long notNegative(long argument, String argumentName)
	{
		Argument.notNull(argumentName, "argumentName");

		if (argument < 0)
			throw new NegativeArgumentException(argumentName);

		return argument;
	}

	public static  T notNull(T argument, String argumentName)
	{
		if (argumentName == null)
			throw new NullArgumentException("argumentName");

		if (argument == null)
			throw new NullArgumentException(argumentName);

		return argument;
	}

	public static String notNullOrEmpty(String argument, String argumentName)
	{
		Argument.notNull(argumentName, "argumentName");

		Argument.notNull(argument, argumentName);
		Argument.notEmpty(argument, argumentName);

		return argument;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy