本文整理汇总了Java中com.vangav.backend.exceptions.VangavException.ExceptionClass类的典型用法代码示例。如果您正苦于以下问题:Java ExceptionClass类的具体用法?Java ExceptionClass怎么用?Java ExceptionClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExceptionClass类属于com.vangav.backend.exceptions.VangavException包,在下文中一共展示了ExceptionClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDistance
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的package包/类
/**
* getDistance
* @param geoGrid
* @return returns the distance between this grid's coordinates
* and param grid's coordinates
* @throws Exception
*/
public Distance getDistance (GeoGrid geoGrid) throws Exception {
if (this.geoGridsConfig.equal(geoGrid.geoGridsConfig) == false) {
throw new CodeException(
61,
3,
"this GeoGrid and param GeoGrid has different configurations, "
+ "can't calculate distance between them",
ExceptionClass.ARGUMENT);
}
return this.geoCoordinates.getDistance(
geoGrid.geoCoordinates,
this.geoGridsConfig.getDistanceUnitType() );
}
示例2: getCentersDistance
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的package包/类
/**
* getCentersDistance
* @param geoGrid
* @return returns the distance between this grid's center coordinates
* and param grid's center coordinates
* @throws Exception
*/
public Distance getCentersDistance (GeoGrid geoGrid) throws Exception {
if (this.geoGridsConfig.equal(geoGrid.geoGridsConfig) == false) {
throw new CodeException(
61,
4,
"this GeoGrid and param GeoGrid has different configurations, "
+ "can't calculate distance between them",
ExceptionClass.ARGUMENT);
}
return this.centerGeoCoordinates.getDistance(
geoGrid.centerGeoCoordinates,
this.geoGridsConfig.getDistanceUnitType() );
}
示例3: SnowFlake
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的package包/类
/**
* Constructor SnowFlake
* @return new SnowFlake Object
* @throws Exception
*/
private SnowFlake () throws Exception {
this.machineId = this.getMachineId();
if (this.machineId > this.maxMachineId || this.machineId < 0) {
throw new CodeException(
81,
2,
"machineId > maxMachineId (maximum number of allowed instances is ["
+ this.maxMachineId
+ "] )",
ExceptionClass.UNAUTHORIZED);
}
}
示例4: Period
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的package包/类
/**
* Constructor Period
* @param value: number of units (e.g.: 5 seconds)
* @param unit: e.g.: second, hour, week, etc ...
* @return new Period Object
* @throws Exception
*/
public Period (
double value,
TimeUnitType unit) {
if (value < 0.0) {
throw new CodeException(
122,
5,
"Period value ["
+ value
+ "] can't be negative",
ExceptionClass.INVALID);
}
this.value = value;
this.unit = unit;
}
示例5: setValue
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的package包/类
/**
* setValue
* @param value
*/
public void setValue (double value) {
if (value < 0.0) {
throw new CodeException(
122,
6,
"Period value ["
+ value
+ "] can't be negative",
ExceptionClass.INVALID);
}
this.value = value;
}
示例6: minus
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的package包/类
/**
* minus
* @param value
* @return a new Period Object with this Period's unit and
* new value = this value - param value
* @throws Exception
*/
public Period minus (double value) throws Exception {
if (value > this.value) {
throw new CodeException(
122,
7,
"Period minus operation will lead to a negative Period, that's an "
+ "invalid operation, minus value must be smaller than or equal to "
+ "current value. Current value ["
+ this.value
+ "] minus value ["
+ value
+ "].",
ExceptionClass.INVALID);
}
return new Period(this.value - value, this.unit);
}
示例7: minus
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的package包/类
/**
* minus
* @param value
* @return a new Distance Object with this Distance's unit and
* new value = this value - param value
* @throws Exception
*/
public Distance minus (double value) throws Exception {
if (value > this.value) {
throw new CodeException(
122,
1,
"Distance minus operation will lead to a negative distance, that's an "
+ "invalid operation, minus value must be smaller than or equal to "
+ "current value. Current value ["
+ this.value
+ "] minus value ["
+ value
+ "].",
ExceptionClass.INVALID);
}
return new Distance(this.value - value, this.unit);
}
示例8: getResult
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的package包/类
/**
* getResult
* @return response's body as a play framework Result
* @throws Exception
*/
@JsonIgnore
public Result getResult () throws Exception {
if (this.getType() == ResponseType.JSON) {
return Results.ok((String)this.getContent() );
} else if (this.getType() == ResponseType.FILE) {
return Results.ok(new FileInputStream((String)this.getContent() ) );
} else if (this.getType() == ResponseType.HTML) {
return Results.ok((Content)this.getContent() );
}
throw new CodeException(
151,
12,
"Unhandled ResponseBody Type ["
+ this.getType().toString()
+ "]",
ExceptionClass.TYPE);
}
示例9: fromPlayRequest
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的package包/类
/**
* fromPlayRequest
* converts a play request's body to a new RequestJsonBody Object
* @param playRequest
* @return new RequestJsonBody Object
* @throws Exception
*/
@JsonIgnore
final public RequestJsonBody fromPlayRequest (
play.mvc.Http.Request playRequest) throws Exception {
if (RequestType.valueOf(playRequest.method().toUpperCase() ) ==
RequestType.POST) {
return this.fromJsonString(playRequest.body().asJson().toString() );
} else if (RequestType.valueOf(playRequest.method().toUpperCase() ) ==
RequestType.GET) {
return this.fromQueryString(playRequest.queryString() );
}
throw new BadRequestException(
151,
8,
"unhandled request type, only handles POST and GET request types",
ExceptionClass.TYPE);
}
示例10: checkInstanceOf
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的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);
}
}
示例11: checkNotNull
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的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);
}
}
示例12: checkNotEmpty
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的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);
}
}
示例13: checkIntWithinRange
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的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);
}
}
示例14: checkIntGreaterThanOrEqual
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的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);
}
}
示例15: checkLongGreaterThanOrEqual
import com.vangav.backend.exceptions.VangavException.ExceptionClass; //导入依赖的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);
}
}