List of usage examples for org.springframework.util ObjectUtils isEmpty
@SuppressWarnings("rawtypes") public static boolean isEmpty(@Nullable Object obj)
From source file:org.devefx.httpmapper.spring.handler.HandlerExecutionChain.java
public void onRequest(RequestEntity requestEntity) throws Exception { HandlerListener[] listeners = getListeners(); if (!ObjectUtils.isEmpty(listeners)) { for (HandlerListener listener : listeners) { listener.onRequest(requestEntity); }/*from ww w.j a va2 s . c o m*/ } }
From source file:org.springmodules.cache.provider.ehcache.EhCacheModelValidator.java
/** * @throws InvalidCacheModelException if the given model does not specify at least one cache. * @see AbstractCacheModelValidator#validateFlushingModelProperties(Object) */// www .j a v a2 s. co m protected void validateFlushingModelProperties(Object flushingModel) throws InvalidCacheModelException { EhCacheFlushingModel model = (EhCacheFlushingModel) flushingModel; String[] cacheNames = model.getCacheNames(); if (ObjectUtils.isEmpty(cacheNames)) { throw new InvalidCacheModelException("There should be at least one cache name"); } }
From source file:biz.deinum.multitenant.batch.item.excel.AbstractExcelItemReader.java
@Override protected T doRead() throws Exception { if (this.noInput) { return null; }/*from ww w .j av a 2 s. co m*/ final Sheet sheet = this.getSheet(this.currentSheet); final String[] row = this.readRow(sheet); if (ObjectUtils.isEmpty(row)) { this.currentSheet++; if (this.currentSheet >= this.getNumberOfSheets()) { logger.debug("No more sheets in {}.", this.resource.getDescription()); return null; } else { this.currentRow = 0; this.openSheet(); return this.doRead(); } } else { try { return this.rowMapper.mapRow(sheet, row, this.currentRow); } catch (final Exception e) { throw new ExcelFileParseException("Exception parsing Excel file.", e, this.resource.getDescription(), sheet.getName(), this.currentRow, row); } } }
From source file:org.apache.struts2.spring.ClassReloadingBeanFactory.java
@Override protected BeanWrapper createBeanInstance(String beanName, RootBeanDefinition mbd, Object[] args) { Class beanClass = resolveBeanClass(mbd, beanName, null); if (mbd.getFactoryMethodName() != null) { return instantiateUsingFactoryMethod(beanName, mbd, args); }//from ww w. j av a2 s . c om //commented to cached constructor is not used /* // Shortcut when re-creating the same bean... if (mbd.resolvedConstructorOrFactoryMethod != null) { if (mbd.constructorArgumentsResolved) { return autowireConstructor(beanName, mbd, null, args); } else { return instantiateBean(beanName, mbd); } }*/ // Need to determine the constructor... Constructor[] ctors = determineConstructorsFromBeanPostProcessors(beanClass, beanName); if (ctors != null || mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_CONSTRUCTOR || mbd.hasConstructorArgumentValues() || !ObjectUtils.isEmpty(args)) { return autowireConstructor(beanName, mbd, ctors, args); } // No special handling: simply use no-arg constructor. return instantiateBean(beanName, mbd); }
From source file:org.springmodules.cache.config.CacheSetupStrategyElementBuilder.java
/** * @see XmlElementBuilder#toXml()//from w w w. j ava 2s.co m */ public Element toXml() { Element root = new DomElementStub("abstract"); root.setAttribute("providerId", cacheProviderId); if (!ObjectUtils.isEmpty(cachingListenerElementBuilders)) { Element listeners = new DomElementStub("cachingListeners"); appendChildren(listeners, cachingListenerElementBuilders); root.appendChild(listeners); } if (cacheKeyGeneratorElementBuilder != null) { root.appendChild(cacheKeyGeneratorElementBuilder.toXml()); } appendChildren(root, cachingModelElementBuilders); appendChildren(root, flushingModelElementBuilders); return root; }
From source file:morph.plugin.views.annotation.ServletAnnotationMappingUtils.java
/** * Check whether the given request matches the specified header conditions. * @param headers the header conditions, following * {@link org.springframework.web.bind.annotation.RequestMapping#headers() RequestMapping.headers()} * @param request the current HTTP request to check *//* w w w . j av a2 s . c o m*/ public static boolean checkHeaders(String[] headers, HttpServletRequest request) { if (!ObjectUtils.isEmpty(headers)) { for (String header : headers) { int separator = header.indexOf('='); if (separator == -1) { if (header.startsWith("!")) { if (request.getHeader(header.substring(1)) != null) { return false; } } else if (request.getHeader(header) == null) { return false; } } else { boolean negated = separator > 0 && header.charAt(separator - 1) == '!'; String key = !negated ? header.substring(0, separator) : header.substring(0, separator - 1); String value = header.substring(separator + 1); if (isMediaTypeHeader(key)) { List<MediaType> requestMediaTypes = MediaType.parseMediaTypes(request.getHeader(key)); List<MediaType> valueMediaTypes = MediaType.parseMediaTypes(value); boolean found = false; for (Iterator<MediaType> valIter = valueMediaTypes.iterator(); valIter.hasNext() && !found;) { MediaType valueMediaType = valIter.next(); for (Iterator<MediaType> reqIter = requestMediaTypes.iterator(); reqIter.hasNext() && !found;) { MediaType requestMediaType = reqIter.next(); if (valueMediaType.includes(requestMediaType)) { found = true; } } } if (!found) { return negated; } } else if (!value.equals(request.getHeader(key))) { return negated; } } } } return true; }
From source file:net.javacrumbs.springws.test.validator.SchemaRequestValidator.java
public void afterPropertiesSet() throws IOException { if (validator == null && !ObjectUtils.isEmpty(schemas)) { validator = getSchemaValidator().createValidatorFromSchemas(schemas, schemaLanguage); }//from ww w . j a v a 2s . c o m Assert.notNull(validator, "Setting 'schema', 'schemas', 'xsdSchema', or 'xsdSchemaCollection' is required"); }
From source file:org.works.batch.item.excel.AbstractExcelItemReader.java
@Override protected T doRead() throws Exception { if (this.noInput) { return null; }// w w w .j ava 2s . c o m logger.debug("read sheet {}.", currentSheet); logger.debug("sheet number {}.", this.getNumberOfSheets()); final Sheet sheet = this.getSheet(this.currentSheet); final String[] row = this.readRow(sheet); // this.openSheet(); try { if (!ObjectUtils.isEmpty(row)) { return this.rowMapper.mapRow(sheet, row, this.currentRow); } else { return null; } } catch (Exception e) { throw new ExcelFileParseException("Exception parsing Excel file.", e, this.resource.getDescription(), sheet.getName(), this.currentRow, row); } // if (ObjectUtils.isEmpty(row)) { // this.currentSheet++; // if (this.currentSheet >= this.getNumberOfSheets()) { // logger.debug("No more sheets in {}.", this.resource.getDescription()); // return null; // } else { // this.currentRow = 0; // this.openSheet(); // return this.doRead(); // } // } else { // try { // return this.rowMapper.mapRow(sheet, row, this.currentRow); // } catch (final Exception e) { // throw new ExcelFileParseException("Exception parsing Excel file.", e, this.resource.getDescription(), // sheet.getName(), this.currentRow, row); // } // } }
From source file:org.devefx.httpmapper.spring.handler.HandlerExecutionChain.java
public void onResponse(RequestEntity requestEntity, ResponseEntity responseEntity) throws Exception { HandlerListener[] listeners = getListeners(); if (!ObjectUtils.isEmpty(listeners)) { for (int i = listeners.length - 1; i >= 0; i--) { HandlerListener listener = listeners[i]; listener.onResponse(requestEntity, responseEntity); }//from w w w .java 2 s . co m } }
From source file:grails.plugin.cache.web.filter.LazyParamAwareEvaluationContext.java
protected void loadArgsAsVariables() { // shortcut if no args need to be loaded if (ObjectUtils.isEmpty(args)) { return;/* ww w . j a va 2 s .c om*/ } String key = toString(method); Method targetMethod = methodCache.get(key); if (targetMethod == null) { targetMethod = AopUtils.getMostSpecificMethod(method, targetClass); if (targetMethod == null) { targetMethod = method; } methodCache.put(key, targetMethod); } // save arguments as indexed variables for (int i = 0; i < args.length; i++) { setVariable("p" + i, args[i]); } String[] parameterNames = paramDiscoverer.getParameterNames(targetMethod); // save parameter names (if discovered) if (parameterNames != null) { for (int i = 0; i < parameterNames.length; i++) { setVariable(parameterNames[i], args[i]); } } }