mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 00:45:44 +01:00
added AssertUtil
This commit is contained in:
76
scm-core/src/main/java/sonia/scm/util/AssertUtil.java
Normal file
76
scm-core/src/main/java/sonia/scm/util/AssertUtil.java
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class AssertUtil
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
*/
|
||||
public static void assertIsNotEmpty(String value)
|
||||
{
|
||||
if (Util.isEmpty(value))
|
||||
{
|
||||
throw new IllegalStateException("value is empty");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
public static void assertIsNotEmpty(Object[] array)
|
||||
{
|
||||
if (Util.isEmpty(array))
|
||||
{
|
||||
throw new IllegalStateException("array is empty");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param collection
|
||||
*/
|
||||
public static void assertIsNotEmpty(Collection<?> collection)
|
||||
{
|
||||
if (Util.isEmpty(collection))
|
||||
{
|
||||
throw new IllegalStateException("collection is empty");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param object
|
||||
*/
|
||||
public static void assertIsNotNull(Object object)
|
||||
{
|
||||
if (object == null)
|
||||
{
|
||||
throw new IllegalStateException("object is required");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user