List of usage examples for org.springframework.util ObjectUtils isEmpty
@SuppressWarnings("rawtypes") public static boolean isEmpty(@Nullable Object obj)
From source file:com.excilys.ebi.spring.dbunit.test.TestConfigurationProcessor.java
/** * @param annotation the DataSet annotation * @param testContext the context/*from w ww . j a v a 2s . c o m*/ * @return an String array, containing the locations of resources * @throws IOException I/O failure */ private String[] getResourceLocationsByConventions(DataSet annotation, TestContext testContext) { String[] valueLocations = annotation.value(); String[] locations = annotation.locations(); if (!ObjectUtils.isEmpty(valueLocations)) { locations = valueLocations; } return conventions.getDataSetResourcesLocations(testContext.getTestClass(), locations); }
From source file:org.eclipse.gemini.blueprint.test.AbstractSynchronizedOsgiTests.java
/** * Determines if the given bundle, is Spring DM managed or not. This method * is used at startup, for waiting on all Spring DM contexts to be properly * started and published./*ww w . j a v a 2s. c o m*/ * * @param bundle * @return */ protected boolean isSpringDMManaged(Bundle bundle) { if (!ObjectUtils.isEmpty(ConfigUtils.getHeaderLocations(bundle.getHeaders()))) return true; Enumeration enm = bundle.findEntries("META-INF/spring", "*.xml", false); return (enm != null && enm.hasMoreElements()); }
From source file:com.excilys.ebi.spring.dbunit.test.TestConfigurationProcessor.java
/** * @param annotation the ExpectedDataSet annotation * @param testContext the context//from ww w .j a va 2 s .c o m * @return an String array, containing the locations of resources * @throws IOException I/O failure */ private String[] getExpectedResourceLocationsByConventions(ExpectedDataSet annotation, TestContext testContext) { String[] valueLocations = annotation.value(); String[] locations = annotation.locations(); if (!ObjectUtils.isEmpty(valueLocations)) { locations = valueLocations; } return conventions.getExpectedDataSetResourcesLocations(testContext.getTestClass(), locations); }
From source file:org.ireland.jnetty.webapp.ServletContextImpl.java
/** * Returns an enumeration of all the resources. * @see org.springframework.mock.web.MockServletContext.getResourcePaths(String path) *///www. j a va 2s .c om @Override public Set<String> getResourcePaths(String path) { String actualPath = (path.endsWith("/") ? path : path + "/"); Resource resource = this.resourceLoader.getResource(getResourceLocation(actualPath)); try { File file = resource.getFile(); String[] fileList = file.list(); if (ObjectUtils.isEmpty(fileList)) { return null; } Set<String> resourcePaths = new LinkedHashSet<String>(fileList.length); for (String fileEntry : fileList) { String resultPath = actualPath + fileEntry; if (resource.createRelative(fileEntry).getFile().isDirectory()) { resultPath += "/"; } resourcePaths.add(resultPath); } return resourcePaths; } catch (IOException ex) { log.warn("Couldn't get resource paths for " + resource, ex); return null; } }
From source file:com.qpark.eip.core.failure.FailureAssert.java
/** * Assert that an array has elements; that is, it must not be * <code>null</code> and must have at least one element. * * <pre class="code">/*from w w w. j av a 2s. c o m*/ * Assert.notEmpty(array, "The array must have elements"); * </pre> * * @param array * the array to check * @param errorCode * the error code to use if the assertion fails * @throws IllegalArgumentException * if the object array is <code>null</code> or has no elements */ public static void notEmpty(final Object[] array, final String errorCode) { if (ObjectUtils.isEmpty(array)) { BaseFailureHandler.throwFailureException(errorCode); } }
From source file:org.iff.infra.util.spring.script.ScriptFactoryPostProcessor.java
@Override public Class<?> predictBeanType(Class<?> beanClass, String beanName) { // We only apply special treatment to ScriptFactory implementations here. if (!ScriptFactory.class.isAssignableFrom(beanClass)) { return null; }//from w ww.j a v a2s . co m BeanDefinition bd = this.beanFactory.getMergedBeanDefinition(beanName); try { String scriptFactoryBeanName = SCRIPT_FACTORY_NAME_PREFIX + beanName; String scriptedObjectBeanName = SCRIPTED_OBJECT_NAME_PREFIX + beanName; prepareScriptBeans(bd, scriptFactoryBeanName, scriptedObjectBeanName); ScriptFactory scriptFactory = this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class); ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator()); Class<?>[] interfaces = scriptFactory.getScriptInterfaces(); Class<?> scriptedType = scriptFactory.getScriptedObjectType(scriptSource); if (scriptedType != null) { return scriptedType; } else if (!ObjectUtils.isEmpty(interfaces)) { return (interfaces.length == 1 ? interfaces[0] : createCompositeInterface(interfaces)); } else { if (bd.isSingleton()) { Object bean = this.scriptBeanFactory.getBean(scriptedObjectBeanName); if (bean != null) { return bean.getClass(); } } } } catch (Exception ex) { if (ex instanceof BeanCreationException && ((BeanCreationException) ex) .getMostSpecificCause() instanceof BeanCurrentlyInCreationException) { if (logger.isTraceEnabled()) { logger.trace("Could not determine scripted object type for bean '" + beanName + "': " + ex.getMessage()); } } else { if (logger.isDebugEnabled()) { logger.debug("Could not determine scripted object type for bean '" + beanName + "'", ex); } } } return null; }
From source file:com.gst.useradministration.service.AppUserWritePlatformServiceJpaRepositoryImpl.java
private Set<Role> assembleSetOfRoles(final String[] rolesArray) { final Set<Role> allRoles = new HashSet<>(); if (!ObjectUtils.isEmpty(rolesArray)) { for (final String roleId : rolesArray) { final Long id = Long.valueOf(roleId); final Role role = this.roleRepository.findOne(id); if (role == null) { throw new RoleNotFoundException(id); }// w w w . j a va2 s.co m allRoles.add(role); } } return allRoles; }
From source file:ee.kovmen.xtee.consumer.CustomServiceTemplate.java
/** * Initialize the default implementations for the template's strategies: {@link SoapFaultMessageResolver}, {@link * org.springframework.ws.soap.saaj.SaajSoapMessageFactory}, and {@link HttpUrlConnectionMessageSender}. * * @throws BeanInitializationException in case of initalization errors * @see #setFaultMessageResolver(FaultMessageResolver) * @see #setMessageFactory(WebServiceMessageFactory) * @see #setMessageSender(WebServiceMessageSender) *//*from ww w. j ava 2s . co m*/ protected void initDefaultStrategies() { Resource resource = new ClassPathResource( ClassUtils.getShortName(CustomServiceTemplate.class) + ".properties", CustomServiceTemplate.class); DefaultStrategiesHelper strategiesHelper = new DefaultStrategiesHelper(resource); if (getMessageFactory() == null) { initMessageFactory(strategiesHelper); } if (ObjectUtils.isEmpty(getMessageSenders())) { initMessageSenders(strategiesHelper); } if (getFaultMessageResolver() == null) { initFaultMessageResolver(strategiesHelper); } }
From source file:org.devgateway.ocds.web.rest.controller.AwardsWonLostController.java
@ApiOperation(value = "Counts the number of wins per supplierId per procuringEntityId, plus shows the flags" + " and the awarded total. You must provide supplierId parameter. Any other filter can be used as well.") @RequestMapping(value = "/api/supplierWinsPerProcuringEntity", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json") public List<DBObject> procurementsWonLostPerProcuringEntity( @ModelAttribute @Valid final YearFilterPagingRequest filter) { Assert.isTrue(/*from w w w . j av a 2s .c o m*/ !ObjectUtils.isEmpty(filter.getSupplierId()) || !ObjectUtils.isEmpty(filter.getProcuringEntityId()), "Either supplierId or procuringEntityId must not be empty!"); Aggregation agg = newAggregation( match(where(AWARDS_STATUS).is(Award.Status.active.toString()) .andOperator(getYearDefaultFilterCriteria(filter, TENDER_PERIOD_START_DATE)) .and(MongoConstants.FieldNames.TENDER_PROCURING_ENTITY_ID).exists(true) .and(MongoConstants.FieldNames.TENDER_PROCURING_ENTITY_NAME).exists(true)), unwind("awards"), unwind("awards.suppliers"), match(where(AWARDS_STATUS).is(Award.Status.active.toString()).andOperator( getYearDefaultFilterCriteria(filter.awardFiltering(), TENDER_PERIOD_START_DATE))), group(Fields.from(field("supplierId", MongoConstants.FieldNames.AWARDS_SUPPLIERS_ID), field("supplierName", MongoConstants.FieldNames.AWARDS_SUPPLIERS_NAME), field("procuringEntityName", MongoConstants.FieldNames.TENDER_PROCURING_ENTITY_NAME), field("procuringEntityId", MongoConstants.FieldNames.TENDER_PROCURING_ENTITY_ID))).count() .as("count").sum(MongoConstants.FieldNames.AWARDS_VALUE_AMOUNT) .as("totalAmountAwarded").sum(FLAGS_TOTAL_FLAGGED).as("countFlags"), sort(Sort.Direction.DESC, "count")); return releaseAgg(agg); }
From source file:ch.rasc.wampspring.broker.SimpleBrokerMessageHandlerTests.java
private void assertCapturedMessage(EventMessage... expectedMessages) { List<EventMessage> allCapturedMessages = this.messageCaptor.getAllValues(); if (!ObjectUtils.isEmpty(expectedMessages)) { assertThat(allCapturedMessages).hasSize(expectedMessages.length); for (EventMessage expectedMessage : expectedMessages) { EventMessage found = null;//from w w w . j a va2 s. co m for (EventMessage capturedMessage : allCapturedMessages) { if (capturedMessage.getPayload().equals(expectedMessage.getPayload()) && capturedMessage.getDestination().equals(expectedMessage.getDestination()) && capturedMessage.getWebSocketSessionId() .equals(expectedMessage.getWebSocketSessionId())) { found = capturedMessage; } } assertThat(found).isNotNull(); } } else { assertThat(allCapturedMessages).isEmpty(); } }