List of usage examples for org.springframework.util ObjectUtils isEmpty
@SuppressWarnings("rawtypes") public static boolean isEmpty(@Nullable Object obj)
From source file:org.springframework.boot.actuate.metrics.export.MetricCopyExporter.java
@Override protected Iterable<Metric<?>> next(String group) { if (ObjectUtils.isEmpty(this.includes) && ObjectUtils.isEmpty(this.excludes)) { return this.reader.findAll(); }/* w w w . ja va 2s . com*/ return new PatternMatchingIterable(MetricCopyExporter.this.reader); }
From source file:org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.java
private String[] getMappingResources() { List<String> mappingResources = this.properties.getMappingResources(); return (!ObjectUtils.isEmpty(mappingResources) ? StringUtils.toStringArray(mappingResources) : null); }
From source file:org.springframework.boot.context.embedded.ServletRegistrationBean.java
/** * Configure registration settings. Subclasses can override this method to perform * additional configuration if required. * @param registration the registration/*from w w w. ja v a 2 s . c o m*/ */ protected void configure(ServletRegistration.Dynamic registration) { super.configure(registration); String[] urlMapping = this.urlMappings.toArray(new String[this.urlMappings.size()]); if (urlMapping.length == 0 && this.alwaysMapUrl) { urlMapping = DEFAULT_MAPPINGS; } if (!ObjectUtils.isEmpty(urlMapping)) { registration.addMapping(urlMapping); } registration.setLoadOnStartup(this.loadOnStartup); if (this.multipartConfig != null) { registration.setMultipartConfig(this.multipartConfig); } }
From source file:org.springframework.boot.context.logging.LoggingApplicationListener.java
protected void setLogLevels(LoggingSystem system, Environment environment) { if (!(environment instanceof ConfigurableEnvironment)) { return;// www .j av a2 s . co m } Binder binder = Binder.get(environment); Map<String, String[]> groups = getGroups(); binder.bind("logging.group", STRING_STRINGS_MAP.withExistingValue(groups)); Map<String, String> levels = binder.bind("logging.level", STRING_STRING_MAP) .orElseGet(Collections::emptyMap); levels.forEach((name, level) -> { String[] groupedNames = groups.get(name); if (ObjectUtils.isEmpty(groupedNames)) { setLogLevel(system, name, level); } else { setLogLevel(system, groupedNames, level); } }); }
From source file:org.springframework.boot.SpringApplication.java
/** * Called to log active profile information. * @param context the application context *//* ww w . j av a 2 s. com*/ protected void logStartupProfileInfo(ConfigurableApplicationContext context) { Log log = getApplicationLog(); if (log.isInfoEnabled()) { String[] activeProfiles = context.getEnvironment().getActiveProfiles(); if (ObjectUtils.isEmpty(activeProfiles)) { log.info("No profiles are active"); } else { log.info("The following profiles are active: " + StringUtils.arrayToCommaDelimitedString(activeProfiles)); } } }
From source file:org.springframework.boot.test.context.assertj.AssertProviderApplicationContextInvocationHandler.java
private Object getSourceContext(Object[] args) { ApplicationContext context = getStartedApplicationContext(); if (!ObjectUtils.isEmpty(args)) { Assert.isInstanceOf((Class<?>) args[0], context); }/*www .j a v a2 s .c o m*/ return context; }
From source file:org.springframework.boot.test.context.SpringBootTestContextBootstrapper.java
@Override protected ContextLoader resolveContextLoader(Class<?> testClass, List<ContextConfigurationAttributes> configAttributesList) { Class<?>[] classes = getClasses(testClass); if (!ObjectUtils.isEmpty(classes)) { for (ContextConfigurationAttributes configAttributes : configAttributesList) { addConfigAttributesClasses(configAttributes, classes); }/* w ww . j av a 2 s . c o m*/ } return super.resolveContextLoader(testClass, configAttributesList); }
From source file:org.springframework.boot.test.context.SpringBootTestContextBootstrapper.java
/** * Post process the property source properties, adding or removing elements as * required.//w w w. j av a 2s. c om * @param mergedConfig the merged context configuration * @param propertySourceProperties the property source properties to process */ protected void processPropertySourceProperties(MergedContextConfiguration mergedConfig, List<String> propertySourceProperties) { Class<?> testClass = mergedConfig.getTestClass(); String[] properties = getProperties(testClass); if (!ObjectUtils.isEmpty(properties)) { // Added first so that inlined properties from @TestPropertySource take // precedence propertySourceProperties.addAll(0, Arrays.asList(properties)); } if (getWebEnvironment(testClass) == WebEnvironment.RANDOM_PORT) { propertySourceProperties.add("server.port=0"); } }
From source file:org.springframework.cloud.dataflow.app.resolver.AetherModuleResolver.java
/** * Resolve a set of artifacts based on their coordinates, including their dependencies, and return the locations of * the transitive set in the local repository. Aether performs the normal Maven resolution process ensuring that the * latest update is cached to the local repository. A number of additional includes and excludes can be specified, * allowing to override the transitive dependencies of the original set. Includes and their transitive dependencies * will always/*from w w w. j av a 2 s . com*/ * * @param root the Maven coordinates of the artifacts * @return a {@link FileSystemResource} representing the resolved artifact in the local repository * @throws RuntimeException if the artifact does not exist or the resolution fails */ @Override public Resource[] resolve(Coordinates root, Coordinates[] includes, String[] excludePatterns) { Assert.notNull(root, "Root cannot be null"); validateCoordinates(root); if (!ObjectUtils.isEmpty(includes)) { for (Coordinates include : includes) { Assert.notNull(include, "Includes cannot be null"); validateCoordinates(include); } } List<Resource> result = new ArrayList<>(); Artifact rootArtifact = toArtifact(root); RepositorySystemSession session = newRepositorySystemSession(repositorySystem, localRepository.getAbsolutePath()); if (ObjectUtils.isEmpty(includes) && ObjectUtils.isEmpty(excludePatterns)) { ArtifactResult resolvedArtifact; try { resolvedArtifact = repositorySystem.resolveArtifact(session, new ArtifactRequest(rootArtifact, remoteRepositories, JavaScopes.RUNTIME)); } catch (ArtifactResolutionException e) { throw new RuntimeException(e); } result.add(toResource(resolvedArtifact)); } else { try { CollectRequest collectRequest = new CollectRequest(); collectRequest.setRepositories(remoteRepositories); collectRequest.setRoot(new Dependency(rootArtifact, JavaScopes.RUNTIME)); Artifact[] includeArtifacts = new Artifact[!ObjectUtils.isEmpty(includes) ? includes.length : 0]; int i = 0; for (Coordinates include : includes) { Artifact includedArtifact = toArtifact(include); collectRequest.addDependency(new Dependency(includedArtifact, JavaScopes.RUNTIME)); includeArtifacts[i++] = includedArtifact; } DependencyResult dependencyResult = repositorySystem.resolveDependencies(session, new DependencyRequest(collectRequest, new ModuleDependencyFilter(includeArtifacts, excludePatterns))); for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) { // we are only interested in the jars if ("jar".equalsIgnoreCase(artifactResult.getArtifact().getExtension())) { result.add(toResource(artifactResult)); } } } catch (DependencyResolutionException e) { throw new RuntimeException(e); } } return result.toArray(new Resource[result.size()]); }
From source file:org.springframework.cloud.gcp.core.DefaultCredentialsProvider.java
static List<String> resolveScopes(List<String> scopes) { if (!ObjectUtils.isEmpty(scopes)) { Set<String> resolvedScopes = new HashSet<>(); scopes.forEach((scope) -> {//from w w w . ja v a2 s . co m if (DEFAULT_SCOPES_PLACEHOLDER.equals(scope)) { resolvedScopes.addAll(CREDENTIALS_SCOPES_LIST); } else { resolvedScopes.add(scope); } }); return Collections.unmodifiableList(new ArrayList<>(resolvedScopes)); } return CREDENTIALS_SCOPES_LIST; }