List of usage examples for org.springframework.util ObjectUtils isEmpty
@SuppressWarnings("rawtypes") public static boolean isEmpty(@Nullable Object obj)
From source file:org.springmodules.util.Strings.java
/** * Removes duplicates from the given String array. * /*w w w . java 2 s .c o m*/ * @param array * the given array * @return a new String array without duplicated entries */ public static String[] removeDuplicates(String[] array) { if (ObjectUtils.isEmpty(array)) { return array; } Set set = new TreeSet(); int arraySize = array.length; for (int i = 0; i < arraySize; i++) { set.add(array[i]); } return (String[]) set.toArray(new String[set.size()]); }
From source file:jp.xet.uncommons.web.env.RemoteEnvironmentProfile.java
public static EnvironmentProfile toEnvironmentProfile(String[] activeProfiles) { for (RemoteEnvironmentProfile p : RemoteEnvironmentProfile.values()) { if (ObjectUtils.containsElement(activeProfiles, p.toString())) { return p; }/*from w w w . ja va 2s. com*/ } if (ObjectUtils.isEmpty(activeProfiles)) { return DEVELOPMENT; } else { return new LocalEnvironmentProfile(activeProfiles[0]); } }
From source file:Main.java
/** * Find a single value of one of the given types in the given Collection: * searching the Collection for a value of the first type, then * searching for a value of the second type, etc. * @param collection the collection to search * @param types the types to look for, in prioritized order * @return a value of one of the given types found if there is a clear match, * or <code>null</code> if none or more than one such value found *///from ww w . j av a2 s .co m public static Object findValueOfType(Collection collection, Class[] types) { if (isEmpty(collection) || ObjectUtils.isEmpty(types)) { return null; } for (int i = 0; i < types.length; i++) { Object value = findValueOfType(collection, types[i]); if (value != null) { return value; } } return null; }
From source file:com.icl.integrator.util.patch.ServletAnnotationMappingUtils.java
/** * Check whether the given request matches the specified request methods. * @param methods the HTTP request methods to check against * @param request the current HTTP request to check *///from ww w . j a v a2s .c om public static boolean checkRequestMethod(RequestMethod[] methods, HttpServletRequest request) { if (ObjectUtils.isEmpty(methods)) { return true; } for (RequestMethod method : methods) { if (method.name().equals(request.getMethod())) { return true; } } return false; }
From source file:morph.plugin.views.annotation.ServletAnnotationMappingUtils.java
/** * Check whether the given request matches the specified parameter conditions. * @param params the parameter conditions, following * {@link org.springframework.web.bind.annotation.RequestMapping#params() RequestMapping.#params()} * @param request the current HTTP request to check *//*from w w w. ja v a 2 s .c o m*/ public static boolean checkParameters(String[] params, HttpServletRequest request) { if (!ObjectUtils.isEmpty(params)) { for (String param : params) { int separator = param.indexOf('='); if (separator == -1) { if (param.startsWith("!")) { if (WebUtils.hasSubmitParameter(request, param.substring(1))) { return false; } } else if (!WebUtils.hasSubmitParameter(request, param)) { return false; } } else { boolean negated = separator > 0 && param.charAt(separator - 1) == '!'; String key = !negated ? param.substring(0, separator) : param.substring(0, separator - 1); String value = param.substring(separator + 1); if (!value.equals(request.getParameter(key))) { return negated; } } } } return true; }
From source file:org.devefx.httpmapper.spring.handler.HandlerExecutionChain.java
public void addListeners(HandlerListener... listeners) { if (!ObjectUtils.isEmpty(listeners)) { initListenerList().addAll(Arrays.asList(listeners)); } }
From source file:sample.web.HomeController.java
@RequestMapping("/setValue") public String setValue(@RequestParam(name = "key", required = false) String key, @RequestParam(name = "value", required = false) String value, HttpServletRequest request) { if (!ObjectUtils.isEmpty(key) && !ObjectUtils.isEmpty(value)) { request.getSession().setAttribute(key, value); }/*from w ww . jav a 2 s . c om*/ return "home"; }
From source file:Main.java
/** * Find a single value of one of the given types in the given Collection: * searching the Collection for a value of the first type, then * searching for a value of the second type, etc. * * @param collection the collection to search * @param types the types to look for, in prioritized order * @return a value of one of the given types found if there is a clear match, * or {@code null} if none or more than one such value found *///from w w w .j a va2s . c o m public static Object findValueOfType(Collection<?> collection, Class<?>[] types) { if (isEmpty(collection) || ObjectUtils.isEmpty(types)) { return null; } for (Class<?> type : types) { Object value = findValueOfType(collection, type); if (value != null) { return value; } } return null; }
From source file:com.icl.integrator.util.patch.ServletAnnotationMappingUtils.java
/** * Check whether the given request matches the specified parameter conditions. * @param params the parameter conditions, following * {@link org.springframework.web.bind.annotation.RequestMapping#params() RequestMapping.#params()} * @param request the current HTTP request to check *//*from w w w.j av a2 s .c om*/ public static boolean checkParameters(String[] params, HttpServletRequest request) { if (!ObjectUtils.isEmpty(params)) { for (String param : params) { int separator = param.indexOf('='); if (separator == -1) { if (param.startsWith("!")) { if (WebUtils.hasSubmitParameter(request, param.substring(1))) { return false; } } else if (!WebUtils.hasSubmitParameter(request, param)) { return false; } } else { boolean negated = separator > 0 && param.charAt(separator - 1) == '!'; String key = !negated ? param.substring(0, separator) : param.substring(0, separator - 1); String value = param.substring(separator + 1); boolean match = value.equals(request.getParameter(key)); if (negated) { match = !match; } if (!match) { return false; } } } } return true; }
From source file:io.gmind7.spring.foundation.config.WebAppInitializer.java
@Override protected WebApplicationContext createRootApplicationContext() { Class<?>[] rootConfigClasses = this.getRootConfigClasses(); if (!ObjectUtils.isEmpty(rootConfigClasses)) { AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext(); String springProfilesActvie = rootAppContext.getEnvironment() .getProperty(EnvType.SPRING_PROFILE_ACTIVE.getKey()); if (springProfilesActvie == null) rootAppContext.getEnvironment().setActiveProfiles(EnvType.DEFAULT_ACTIVE_PROFILE.getKey()); rootAppContext.register(rootConfigClasses); return rootAppContext; } else {// ww w .jav a 2 s. co m return null; } }