Java Code Examples for org.springframework.util.StringUtils.startsWithIgnoreCase()

The following are Jave code examples for showing how to use startsWithIgnoreCase() of the org.springframework.util.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: cerebro   File: AlarmValidator.java   Source Code and License Vote up 6 votes
public void validateAlarm(final Alarm alarm) throws CerebroException {
    // Validate required fields
    if (StringUtils.isEmpty(alarm.getName())) {
        throw new CerebroException(ErrorCode.ALARM_INVALID, "Alarm name is required.");
    }

    if (StringUtils.isEmpty(alarm.getTarget()) || StringUtils.startsWithIgnoreCase(alarm.getTarget(), "*")) {
        throw new CerebroException(ErrorCode.ALARM_INVALID, "Alarm target is required.");
    }

    if (StringUtils.isEmpty(alarm.getWarn())) {
        throw new CerebroException(ErrorCode.ALARM_INVALID, "Alarm warning threshold is required.");
    }

    if (StringUtils.isEmpty(alarm.getError())) {
        throw new CerebroException(ErrorCode.ALARM_INVALID, "Alarm error threshold is required.");
    }
}
 
Example 2
Project: lams   File: WebRequestDataBinder.java   Source Code and License Vote up 3 votes
/**
 * Check if the request is a multipart request (by checking its Content-Type header).
 *
 * @param request request with parameters to bind
 */
private boolean isMultipartRequest(WebRequest request) {
	String contentType = request.getHeader("Content-Type");
	return ((contentType != null) && StringUtils.startsWithIgnoreCase(contentType, "multipart"));
}