List of usage examples for org.springframework.util ObjectUtils isEmpty
@SuppressWarnings("rawtypes") public static boolean isEmpty(@Nullable Object obj)
From source file:com.geodevv.testing.irmina.IrminaContextLoader.java
/** * Process configuration classes in the supplied {@link org.springframework.test.context.ContextConfigurationAttributes}. * <p>If the configuration classes are <code>null</code> or empty and * {@link #isGenerateDefaultLocations()} returns <code>true</code>, this * <code>SmartContextLoader</code> will attempt to {@link * #detectDefaultConfigurationClasses detect default configuration classes}. * If defaults are detected they will be * {@link org.springframework.test.context.ContextConfigurationAttributes#setClasses(Class[]) set} in the * supplied configuration attributes. Otherwise, properties in the supplied * configuration attributes will not be modified. * * @param configAttributes the context configuration attributes to process * @see org.springframework.test.context.SmartContextLoader#processContextConfiguration() * @see #isGenerateDefaultLocations()/* w w w.j a v a2s. c o m*/ * @see #detectDefaultConfigurationClasses() */ public void processContextConfiguration(ContextConfigurationAttributes configAttributes) { if (ObjectUtils.isEmpty(configAttributes.getClasses()) && isGenerateDefaultLocations()) { Class<?>[] defaultConfigClasses = detectDefaultConfigurationClasses( configAttributes.getDeclaringClass()); configAttributes.setClasses(defaultConfigClasses); } }
From source file:example.app.repo.provider.GoogleMapsApiGeocodingRepository.java
@Override public Address reverseGeocode(Point location) { try {/*from www. j av a2 s. co m*/ GeoApiContext context = newGeoApiContext(); GeocodingResult[] results = GeocodingApi.reverseGeocode(context, toLatitudeLongitude(location)).await(); if (!ObjectUtils.isEmpty(results)) { GeocodingResult result = results[0]; return toAddress(result.addressComponents); } throw new GoogleMapsApiGeocodingException(String .format("address for geographic coordinates (latitude/longitude) [%s] not found", location)); } catch (Exception e) { throw new GoogleMapsApiGeocodingException(String.format( "failed to reverse geocode geographic coordinates (latitude/longitude) [%s] to a physical address", location), e); } }
From source file:com.dianwoba.redcliff.blink.config.MybatisConfig.java
@Bean(name = "aSqlSessionFactory") public SqlSessionFactory sqlSessionFactory(@Qualifier("aDataSource") DataSource dataSource) throws Exception { SqlSessionFactoryBean factory = new SqlSessionFactoryBean(); factory.setDataSource(dataSource);// ww w . j av a2s . com factory.setVfs(SpringBootVFS.class); if (StringUtils.hasText(this.properties.getConfigLocation())) { factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation())); } factory.setConfiguration(properties.getConfiguration()); if (!ObjectUtils.isEmpty(this.interceptors)) { factory.setPlugins(this.interceptors); } if (this.databaseIdProvider != null) { factory.setDatabaseIdProvider(this.databaseIdProvider); } if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) { factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage()); } if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) { factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage()); } if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) { factory.setMapperLocations(this.properties.resolveMapperLocations()); } return factory.getObject(); }
From source file:com.excilys.ebi.bank.util.Asserts.java
public static void notEmpty(Object[] array, String messagePattern, Object arg) { if (ObjectUtils.isEmpty(array)) { throw new IllegalArgumentException(MessageFormatter.format(messagePattern, arg).getMessage()); }/*from www .j a v a 2s . co m*/ }
From source file:org.fenixedu.bennu.spring.portal.PortalHandlerMapping.java
private String extractPath(RequestMapping mapping, Class<?> type) { if (ObjectUtils.isEmpty(mapping.value())) { throw new Error( "Functionality type " + type.getName() + " does not declare any @RequestMapping mappings!"); }//from w w w .j a v a2 s.com String path = mapping.value()[0]; return path.startsWith("/") ? path.substring(1) : path; }
From source file:com.excilys.ebi.bank.util.Asserts.java
public static void notEmpty(Object[] array, String messagePattern, Object arg1, Object arg2) { if (ObjectUtils.isEmpty(array)) { throw new IllegalArgumentException(MessageFormatter.format(messagePattern, arg1, arg2).getMessage()); }// www. j a v a2s . c o m }
From source file:com.github.mybatis.repository.autoconfig.MybatisAutoConfiguration.java
@Bean @ConditionalOnMissingBean//from w ww. j a v a 2s . c o m public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { SqlSessionFactoryBean factory = new SqlSessionFactoryBean(); factory.setDataSource(dataSource); factory.setVfs(SpringBootVFS.class); if (StringUtils.hasText(this.properties.getConfigLocation())) { factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation())); } factory.setConfiguration(properties.getConfiguration()); if (!ObjectUtils.isEmpty(this.interceptors)) { factory.setPlugins(this.interceptors); } if (this.databaseIdProvider != null) { factory.setDatabaseIdProvider(this.databaseIdProvider); } if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) { factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage()); } if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) { factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage()); } if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) { factory.setMapperLocations(this.properties.resolveMapperLocations()); } return factory.getObject(); }
From source file:org.springmodules.cache.interceptor.caching.AbstractCachingInterceptor.java
private void notifyListeners(Serializable key, Object cachedObject, CachingModel m) { if (ObjectUtils.isEmpty(listeners)) return;/*from w w w . java 2s .co m*/ for (int i = 0; i < listeners.length; i++) listeners[i].onCaching(key, cachedObject, m); }
From source file:com.excilys.ebi.bank.util.Asserts.java
public static void notEmpty(Object[] array, String messagePattern, Object... args) { if (ObjectUtils.isEmpty(array)) { throw new IllegalArgumentException(MessageFormatter.arrayFormat(messagePattern, args).getMessage()); }//w w w. ja v a2s .co m }