List of usage examples for org.springframework.util Assert hasText
@Deprecated public static void hasText(@Nullable String text)
From source file:com.hortonworks.minicluster.util.StringAssertUtils.java
/** * * @param value/* w w w . j a v a 2 s .c o m*/ */ public static void assertNotEmptyAndNoSpaces(String value) { Assert.hasText(value); if (value.contains(" ")) { throw new IllegalArgumentException("'value' must not contain spaces"); } }
From source file:com.dianping.lion.util.BeanUtils.java
@SuppressWarnings("unchecked") public static <T> T getDeclaredFieldValue(Object object, String propertyName) throws NoSuchFieldException { Assert.notNull(object);// w w w. ja v a2s . com Assert.hasText(propertyName); Field field = getDeclaredField(object.getClass(), propertyName); boolean accessible = field.isAccessible(); Object result = null; synchronized (field) { field.setAccessible(true); try { result = field.get(object); } catch (IllegalAccessException e) { throw new NoSuchFieldException("No such field: " + object.getClass() + '.' + propertyName); } finally { field.setAccessible(accessible); } } return (T) result; }
From source file:springfox.documentation.spring.web.ControllerNamingUtils.java
public static String pathRoot(String requestPattern) { Assert.notNull(requestPattern);/*from w w w . j a v a2s. c om*/ Assert.hasText(requestPattern); log.info("Resolving path root for {}", requestPattern); requestPattern = requestPattern.startsWith("/") ? requestPattern : "/" + requestPattern; int idx = requestPattern.indexOf("/", 1); if (idx > -1) { return requestPattern.substring(0, idx); } return requestPattern; }
From source file:com.iterzp.momo.utils.JsonUtils.java
/** * JSON?// w ww .ja v a2s .c o m * * @param json * JSON * @param valueType * * @return */ public static <T> T toObject(String json, Class<T> valueType) { Assert.hasText(json); Assert.notNull(valueType); try { return mapper.readValue(json, valueType); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.zai360.portal.util.SpringUtils.java
/** * ?/*from w ww.j a v a 2 s .c o m*/ * * @param name * Bean?? * @return */ public static Object getBean(String name) { Assert.hasText(name); return applicationContext.getBean(name); }
From source file:com.tcz.api.service.impl.CaptchaServiceImpl.java
public BufferedImage buildImage(String captchaId) { Assert.hasText(captchaId); return (BufferedImage) imageCaptchaService.getChallengeForID(captchaId); }
From source file:com.dianping.lion.util.BeanUtils.java
public static Field getDeclaredField(Class<?> clazz, String propertyName) throws NoSuchFieldException { Assert.notNull(clazz);//w ww. j av a 2 s . com Assert.hasText(propertyName); for (Class<?> superClass = clazz; superClass != Object.class; superClass = superClass.getSuperclass()) { try { return superClass.getDeclaredField(propertyName); } catch (NoSuchFieldException e) { // Field??,? logger.debug("no such method !"); } } throw new NoSuchFieldException("No such field: " + clazz.getName() + '.' + propertyName); }
From source file:com.iterzp.momo.utils.WebUtils.java
/** * cookie/* ww w. jav a 2s. c o m*/ * * @param request * HttpServletRequest * @param response * HttpServletResponse * @param name * cookie?? * @param value * cookie * @param maxAge * (??: ) * @param path * * @param domain * * @param secure * ?? */ public static void addCookie(HttpServletRequest request, HttpServletResponse response, String name, String value, Integer maxAge, String path, String domain, Boolean secure) { Assert.notNull(request); Assert.notNull(response); Assert.hasText(name); try { name = URLEncoder.encode(name, "UTF-8"); value = URLEncoder.encode(value, "UTF-8"); Cookie cookie = new Cookie(name, value); if (maxAge != null) { cookie.setMaxAge(maxAge); } if (StringUtils.isNotEmpty(path)) { cookie.setPath(path); } if (StringUtils.isNotEmpty(domain)) { cookie.setDomain(domain); } if (secure != null) { cookie.setSecure(secure); } response.addCookie(cookie); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
From source file:converters.StringToVoteConverter.java
@Override public Vote convert(String key) { Assert.hasText(key); Vote result;/*from w w w . j a v a 2s. co m*/ int id; id = Integer.valueOf(key); result = voteRepository.findOne(id); Assert.notNull(result); return result; }
From source file:converters.StringToVotationConverter.java
@Override public Votation convert(String key) { Assert.hasText(key); Votation result;/*from ww w.j a v a 2 s . c o m*/ int id; id = Integer.valueOf(key); result = votationRepository.findOne(id); Assert.notNull(result); return result; }