本文整理汇总了Java中com.vangav.backend.exceptions.VangavException.exceptionFactory方法的典型用法代码示例。如果您正苦于以下问题:Java VangavException.exceptionFactory方法的具体用法?Java VangavException.exceptionFactory怎么用?Java VangavException.exceptionFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vangav.backend.exceptions.VangavException
的用法示例。
在下文中一共展示了VangavException.exceptionFactory方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkInstanceOf
import com.vangav.backend.exceptions.VangavException; //导入方法依赖的package包/类
/**
* checkInstanceOf
* @param object: the object to be checked
* @param type: expected class type
* @param exceptionType: exception type to throw
* (bad request or code exception)
* @throws VangavException
* */
public static void checkInstanceOf (
Object object,
Class<?> type,
ExceptionType exceptionType) throws Exception {
if (object.getClass().equals(type) == false) {
throw VangavException.exceptionFactory(
41,
1,
"Wrong class type ["
+ object.getClass().getName()
+ "] expecting ["
+ type.getName()
+ "]",
exceptionType,
ExceptionClass.ARGUMENT);
}
}
示例2: checkNotNull
import com.vangav.backend.exceptions.VangavException; //导入方法依赖的package包/类
/**
* checkNotNull
* @param name: name of the object to be checked
* @param object: object to be checked
* @param exceptionType: exception type to throw
* (bad request or code exception)
* @throws VangavException
* */
public static void checkNotNull (
String name,
Object object,
ExceptionType exceptionType) throws Exception {
if (object == null) {
throw VangavException.exceptionFactory(
41,
2,
name
+ " can't be null",
exceptionType,
ExceptionClass.ARGUMENT);
}
}
示例3: checkNotEmpty
import com.vangav.backend.exceptions.VangavException; //导入方法依赖的package包/类
/**
* checkNotEmpty
* @param name
* @param string
* @param exceptionType
* @throws Exception if param string is null or empty
*/
public static void checkNotEmpty (
String name,
String string,
ExceptionType exceptionType) throws Exception {
checkNotNull(name, string, exceptionType);
if (string.length() == 0) {
throw VangavException.exceptionFactory(
41,
3,
name
+ " can't be empty",
exceptionType,
ExceptionClass.ARGUMENT);
}
}
示例4: checkIntWithinRange
import com.vangav.backend.exceptions.VangavException; //导入方法依赖的package包/类
/**
* checkIntWithinRange
* @param name: name of the integer to be checked
* @param value: value of the integer to be checked
* @param min: minimum valid value
* @param max: maximum valid value
* @param exceptionType: exception type to throw
* (bad request or code exception)
* @throws VangavException
* */
public static void checkIntWithinRange (
String name,
int value,
int min,
int max,
ExceptionType exceptionType) throws Exception {
if (value < min || value > max) {
throw VangavException.exceptionFactory(
41,
12,
name
+ " value ["
+ value
+ "] min ["
+ min
+ "] max ["
+ max
+ "] is out of range",
exceptionType,
ExceptionClass.ARGUMENT);
}
}
示例5: checkIntGreaterThanOrEqual
import com.vangav.backend.exceptions.VangavException; //导入方法依赖的package包/类
/**
* checkIntGreaterThanOrEqual
* @param name: name of the integer to be checked
* @param value: value of the integer to be checked
* @param minLimit: minimum valid value
* @param exceptionType: exception type to throw
* (bad request or code exception)
* @throws VangavException
* */
public static void checkIntGreaterThanOrEqual (
String name,
int value,
int minLimit,
ExceptionType exceptionType) throws Exception {
if (value < minLimit) {
throw VangavException.exceptionFactory(
41,
13,
name
+ " value ["
+ value
+ "] min limit ["
+ minLimit
+ "] is less than the minimum limit",
exceptionType,
ExceptionClass.ARGUMENT);
}
}
示例6: checkLongGreaterThanOrEqual
import com.vangav.backend.exceptions.VangavException; //导入方法依赖的package包/类
/**
* checkLongGreaterThanOrEqual
* @param name: name of the long to be checked
* @param value: value of the long to be checked
* @param minLimit: minimum valid value
* @param exceptionType: exception type to throw
* (bad request or code exception)
* @throws VangavException
* */
public static void checkLongGreaterThanOrEqual (
String name,
long value,
long minLimit,
ExceptionType exceptionType) throws Exception {
if (value < minLimit) {
throw VangavException.exceptionFactory(
41,
14,
name
+ " value ["
+ value
+ "] min limit ["
+ minLimit
+ "] is less than the minimum limit",
exceptionType,
ExceptionClass.ARGUMENT);
}
}
示例7: checkDoubleHasValue
import com.vangav.backend.exceptions.VangavException; //导入方法依赖的package包/类
/**
* checkDoubleHasValue
* throws an exception is param value is NAN or infinite
* @param name
* @param value
* @param exceptionType
* @throws Exception
*/
public static void checkDoubleHasValue (
String name,
double value,
ExceptionType exceptionType) throws Exception {
if (Double.isNaN(value) || Double.isInfinite(value) ) {
throw VangavException.exceptionFactory(
41,
15,
name
+ " double ["
+ value
+ "] has no value",
exceptionType,
ExceptionClass.ARGUMENT);
}
}
示例8: checkIpV4
import com.vangav.backend.exceptions.VangavException; //导入方法依赖的package包/类
/**
* checkIpV4
* throws an exception if param ip isn't a valid IP V4
* @param name
* @param ip
* @param exceptionType
* @throws Exception
*/
public static void checkIpV4 (
String name,
String ip,
ExceptionType exceptionType) throws Exception {
try {
String [] ipSplit = ip.split("\\.");
int currValue;
for (int i = 0; i < 4; i ++) {
currValue = Integer.parseInt(ipSplit[i] );
checkIntWithinRange(
"",
currValue,
0,
255,
exceptionType);
}
} catch (Exception e) {
throw VangavException.exceptionFactory(
41,
16,
name
+ " Invalid IP V4 ["
+ ip
+ "]",
exceptionType,
ExceptionClass.ARGUMENT);
}
}