List of usage examples for org.springframework.util Assert notNull
@Deprecated public static void notNull(@Nullable Object object)
From source file:com.apress.prospringintegration.corespring.config.componentscan.MainComponentScan.java
public static void main(String[] args) throws Exception { ApplicationContext app = new ClassPathXmlApplicationContext("ioc_component_scan.xml"); ColorPicker cp = app.getBean(ColorPicker.class); Assert.notNull(cp); Assert.notNull(cp.getColorRandomizer()); if ((cp.getColorRandomizer() != null)) { System.out.println(cp.getColorRandomizer().exceptColor(ColorEnum.red)); }/*from w w w . j a va 2s . c o m*/ }
From source file:net.shopxx.util.JsonUtil.java
/** * ?JSON//w w w.j a va2 s .com * @param object */ public static String toJson(Object object) { Assert.notNull(object); try { return mapper.writeValueAsString(object); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:org.geowebcache.diskquota.storage.SystemUtils.java
public static void set(SystemUtils instance) { Assert.notNull(instance); INSTANCE = instance; }
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); Assert.hasText(propertyName);//from w w w.j a v a 2s.c om 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:net.shopxx.util.JsonUtil.java
/** * ?JSON?//from w w w .j a v a 2s. c o m * @param response HttpServletResponse * @param contentType contentType * @param object */ public static void toJson(HttpServletResponse response, String contentType, Object value) { Assert.notNull(response); Assert.notNull(contentType); Assert.notNull(value); try { response.setContentType(contentType); mapper.writeValue(response.getWriter(), value); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static DocumentBuilder getDocumentBuilder() { DocumentBuilder builder = null; if (builderFactory == null) { builderFactory = DocumentBuilderFactory.newInstance(); builderFactory.setNamespaceAware(true); }// w w w . ja va2 s. c om try { builder = builderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } Assert.notNull(builder); return builder; }
From source file:springfox.documentation.spring.web.ControllerNamingUtils.java
public static String pathRoot(String requestPattern) { Assert.notNull(requestPattern); Assert.hasText(requestPattern);//from w ww . j av a2 s. c o m 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:org.jcf.graphicMessage.GraphicObjectFactory.java
/** * created object based on type of given go * @param go given GeographicObject/*from w w w .j a v a2s .c o m*/ * @param nikName nikanme to use * @param room room name to use * @param locs list of locations * @return copy of geographic object with new id */ public static GraphicObject create(GraphicObject go, String nikName, String room, List<Location> locs) { Assert.notNull(go); Assert.hasLength(nikName); Assert.hasLength(room); Assert.notNull(locs); if (go instanceof Point) { return createPoint(nikName, room, locs.get(0)); } if (go instanceof Line) { return createLine(nikName, room, locs); } if (go instanceof Polygon) { return createPolygon(nikName, room, locs); } if (go instanceof Text) { Text t = (Text) go; return createText(nikName, room, t.getText(), locs.get(0)); } throw new JCFException("Unsupported GraphicObject"); }
From source file:com.ai.bss.util.user.DigestUtils.java
/** * Calculate the SHA1 hash for a given string. * * @param text the given text to hash to a SHA1 * @return the SHA1 Hash/*from ww w . j a va 2 s . co m*/ */ public static String sha1(String text) { Assert.notNull(text); try { MessageDigest md = MessageDigest.getInstance("SHA1"); return hex(md.digest(text.getBytes("UTF-8"))); } catch (NoSuchAlgorithmException ex) { throw new IllegalStateException( "Unable to calculate hash. No SHA1 hasher available in this Java implementation", ex); } catch (UnsupportedEncodingException ex) { throw new IllegalStateException( "Unable to calculate hash. UTF-8 encoding is not available in this Java implementation", ex); } }
From source file:org.eclipse.swordfish.core.util.xml.XmlUtil.java
private static Transformer getTransformer() { if (transformerFactory == null) { transformerFactory = TransformerFactory.newInstance(); }//from w w w. j a v a 2s .c o m Assert.notNull(transformerFactory); Transformer ret; try { ret = transformerFactory.newTransformer(); } catch (TransformerConfigurationException ex) { throw new RuntimeException(ex); } Assert.notNull(ret); ret.setOutputProperty(OutputKeys.ENCODING, defaultCharset); return ret; }