当前位置: 首页>>代码示例>>Java>>正文


Java ObjectUtils.isEmpty方法代码示例

本文整理汇总了Java中org.springframework.util.ObjectUtils.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectUtils.isEmpty方法的具体用法?Java ObjectUtils.isEmpty怎么用?Java ObjectUtils.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.util.ObjectUtils的用法示例。


在下文中一共展示了ObjectUtils.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: splitArrayElementsIntoProperties

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
/**
 * Take an array Strings and split each element based on the given delimiter.
 * A {@code Properties} instance is then generated, with the left of the
 * delimiter providing the key, and the right of the delimiter providing the value.
 * <p>Will trim both the key and value before adding them to the
 * {@code Properties} instance.
 * @param array the array to process
 * @param delimiter to split each element using (typically the equals symbol)
 * @param charsToDelete one or more characters to remove from each element
 * prior to attempting the split operation (typically the quotation mark
 * symbol), or {@code null} if no removal should occur
 * @return a {@code Properties} instance representing the array contents,
 * or {@code null} if the array to process was {@code null} or empty
 */
public static Properties splitArrayElementsIntoProperties(
		String[] array, String delimiter, String charsToDelete) {

	if (ObjectUtils.isEmpty(array)) {
		return null;
	}
	Properties result = new Properties();
	for (String element : array) {
		if (charsToDelete != null) {
			element = deleteAny(element, charsToDelete);
		}
		String[] splittedElement = split(element, delimiter);
		if (splittedElement == null) {
			continue;
		}
		result.setProperty(splittedElement[0].trim(), splittedElement[1].trim());
	}
	return result;
}
 
开发者ID:vindell,项目名称:spring-boot-starter-disruptor,代码行数:34,代码来源:StringUtils.java

示例2: toString

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
@Override
public String toString() {
	if (ObjectUtils.isEmpty(this.messageExceptions)) {
		return super.toString();
	}
	else {
		StringBuilder sb = new StringBuilder(super.toString());
		sb.append("; message exceptions (").append(this.messageExceptions.length).append(") are:");
		for (int i = 0; i < this.messageExceptions.length; i++) {
			Exception subEx = this.messageExceptions[i];
			sb.append('\n').append("Failed message ").append(i + 1).append(": ");
			sb.append(subEx);
		}
		return sb.toString();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:MailSendException.java

示例3: getServiceReference

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
public static ServiceReference getServiceReference(ServiceReference... references) {
	if (ObjectUtils.isEmpty(references)) {
		return null;
	}

	ServiceReference winningReference = references[0];

	if (references.length > 1) {
		long winningId = getServiceId(winningReference);
		int winningRanking = getServiceRanking(winningReference);

		// start iterating in order to find the best match
		for (int i = 1; i < references.length; i++) {
			ServiceReference reference = references[i];
			int serviceRanking = getServiceRanking(reference);
			long serviceId = getServiceId(reference);

			if ((serviceRanking > winningRanking) || (serviceRanking == winningRanking && winningId > serviceId)) {
				winningReference = reference;
				winningId = serviceId;
				winningRanking = serviceRanking;
			}
		}
	}
	return winningReference;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:27,代码来源:OsgiServiceReferenceUtils.java

示例4: getConfigurations

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
public String[] getConfigurations(Bundle bundle) {
	String[] locations = ConfigUtils.getHeaderLocations(bundle.getHeaders());

	// if no location is specified in the header, try the defaults
	if (ObjectUtils.isEmpty(locations)) {
		// check the default locations if the manifest doesn't provide any info
		Enumeration defaultConfig = bundle.findEntries(CONTEXT_DIR, CONTEXT_FILES, false);
		if (defaultConfig != null && defaultConfig.hasMoreElements()) {
			return new String[] { DEFAULT_CONFIG };
		}
		else {
			return new String[0];
		}
	}
	else {
		return locations;
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:19,代码来源:DefaultConfigurationScanner.java

示例5: getDirectChildNodeList

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
public <R> List<R> getDirectChildNodeList(I parentTreeNodeId, List<T> allTreeNodeList, TreeNodeConverter<T, R> treeNodeBuilder) {
	List<R> childList = new ArrayList<R>();
	if(CollectionUtils.isEmpty(allTreeNodeList) || ObjectUtils.isEmpty(parentTreeNodeId) || treeNodeBuilder == null){
		return childList;
	}
	for(T treeNode : allTreeNodeList){
		if(treeNode != null && parentTreeNodeId.equals(getParentTreeNodeId(treeNode))){
			childList.add(treeNodeBuilder.convertTreeNode(treeNode));
		}
	}
	return childList;
}
 
开发者ID:penggle,项目名称:xproject,代码行数:13,代码来源:AbstractXTreeBuilder.java

示例6: headersToMap

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
private static String[] headersToMap(KinesisBinderConfigurationProperties configurationProperties) {
	Assert.notNull(configurationProperties, "'configurationProperties' must not be null");
	if (ObjectUtils.isEmpty(configurationProperties.getHeaders())) {
		return BinderHeaders.STANDARD_HEADERS;
	}
	else {
		String[] combinedHeadersToMap = Arrays.copyOfRange(BinderHeaders.STANDARD_HEADERS, 0,
				BinderHeaders.STANDARD_HEADERS.length + configurationProperties.getHeaders().length);
		System.arraycopy(configurationProperties.getHeaders(), 0, combinedHeadersToMap,
				BinderHeaders.STANDARD_HEADERS.length, configurationProperties.getHeaders().length);
		return combinedHeadersToMap;
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-aws-kinesis,代码行数:14,代码来源:KinesisMessageChannelBinder.java

示例7: parseAttributes

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
/**
 * Generic attribute callback. Will parse the given callback array, w/o any standard callback.
 * 
 * @param element XML element
 * @param builder current bean definition builder
 * @param callbacks array of callbacks (can be null/empty)
 */
public static void parseAttributes(Element element, BeanDefinitionBuilder builder, AttributeCallback[] callbacks) {
	NamedNodeMap attributes = element.getAttributes();

	for (int x = 0; x < attributes.getLength(); x++) {
		Attr attr = (Attr) attributes.item(x);

		boolean shouldContinue = true;
		if (!ObjectUtils.isEmpty(callbacks))
			for (int i = 0; i < callbacks.length && shouldContinue; i++) {
				AttributeCallback callback = callbacks[i];
				shouldContinue = callback.process(element, attr, builder);
			}
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:22,代码来源:ParserUtils.java

示例8: prePersist

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
@PrePersist
public void prePersist(){
    if (ObjectUtils.isEmpty(getId()))
        setId(UUID.randomUUID().toString());
    if (ObjectUtils.isEmpty(getUpdateTime()))
        setUpdateTime(new Date());
    if (ObjectUtils.isEmpty(getCreateTime()))
        setCreateTime(new Date());
    if (ObjectUtils.isEmpty(getDel()))
        setDel(0);
}
 
开发者ID:finefuture,项目名称:data-migration,代码行数:12,代码来源:BaseEntity.java

示例9: removeParents

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
/**
 * Parses the given class array and eliminate parents of existing classes. Useful when creating proxies to minimize
 * the number of implemented interfaces and redundant class information.
 * 
 * @see #containsUnrelatedClasses(Class[])
 * @see #configureFactoryForClass(ProxyFactory, Class[])
 * 
 * @param classes array of classes
 * @return a new array without superclasses
 */
public static Class<?>[] removeParents(Class<?>[] classes) {
	if (ObjectUtils.isEmpty(classes))
		return new Class[0];

	List<Class<?>> clazz = new ArrayList<Class<?>>(classes.length);
	for (int i = 0; i < classes.length; i++) {
		clazz.add(classes[i]);
	}

	// remove null elements
	while (clazz.remove(null)) {
	}

	// only one class is allowed
	// there can be multiple interfaces
	// parents of classes inside the array are removed

	boolean dirty;
	do {
		dirty = false;
		for (int i = 0; i < clazz.size(); i++) {
			Class<?> currentClass = clazz.get(i);
			for (int j = 0; j < clazz.size(); j++) {
				if (i != j) {
					if (currentClass.isAssignableFrom(clazz.get(j))) {
						clazz.remove(i);
						i--;
						dirty = true;
						break;
					}
				}
			}
		}
	} while (dirty);

	return (Class[]) clazz.toArray(new Class[clazz.size()]);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:48,代码来源:ClassUtils.java

示例10: setConfigLocations

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
@Override
public void setConfigLocations(String[] configLocations) {
	if (!ObjectUtils.isEmpty(configLocations)) {
		throw new UnsupportedOperationException(
				"GenericWebApplicationContext does not support setConfigLocations(). " +
				"Do you still have an 'contextConfigLocations' init-param set?");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:GenericWebApplicationContext.java

示例11: getServiceReferences

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
/**
 * Returns references to <em>all</em> services matching the given class names and OSGi filter.
 * 
 * @param bundleContext OSGi bundle context
 * @param classes array of fully qualified class names
 * @param filter valid OSGi filter (can be <code>null</code>)
 * @return non-<code>null</code> array of references to matching services
 */
public static ServiceReference[] getServiceReferences(BundleContext bundleContext, String[] classes, String filter) {
	// use #getServiceReferences(BundleContext, String, String) method to
	// speed the service lookup process by
	// giving one class as a hint to the OSGi implementation
	// additionally this allows type filtering

	String clazz = (ObjectUtils.isEmpty(classes) ? null : classes[0]);
	return getServiceReferences(bundleContext, clazz, OsgiFilterUtils.unifyFilter(classes, filter));
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:OsgiServiceReferenceUtils.java

示例12: queryForObject

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
@Override
public <T> T queryForObject(String sql, Class<T> requiredType, Object... args) throws DataAccessException {
	return (ObjectUtils.isEmpty(args) ?
			getJdbcOperations().queryForObject(sql, requiredType) :
			getJdbcOperations().queryForObject(sql, getArguments(args), requiredType));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:SimpleJdbcTemplate.java

示例13: getHeaderValues

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
@Override
public String[] getHeaderValues(String headerName) {
	String[] headerValues = StringUtils.toStringArray(getRequest().getHeaders(headerName));
	return (!ObjectUtils.isEmpty(headerValues) ? headerValues : null);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:ServletWebRequest.java

示例14: createSqlSessionFactory

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
private @Nullable
SqlSessionFactory createSqlSessionFactory(
    ConfigurableListableBeanFactory configurableListableBeanFactory,
    String prefixName, MybatisProperties mybatisProperties) {
  DataSource dataSource = configurableListableBeanFactory
      .getBean(prefixName + "Ds", DataSource.class);

  SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
  sqlSessionFactoryBean.setDataSource(dataSource);
  sqlSessionFactoryBean.setVfs(LocSpringBootVFS.class);
  Optional.ofNullable(mybatisProperties.getConfigLocation()).map(this.resourceLoader::getResource)
      .ifPresent(sqlSessionFactoryBean::setConfigLocation);

  org.apache.ibatis.session.Configuration configuration = mybatisProperties.getConfiguration();
  if (configuration == null && !StringUtils.hasText(mybatisProperties.getConfigLocation())) {
    configuration = new org.apache.ibatis.session.Configuration();
  }

  sqlSessionFactoryBean.setConfiguration(configuration);
  Optional.ofNullable(mybatisProperties.getConfigurationProperties())
      .ifPresent(sqlSessionFactoryBean::setConfigurationProperties);
  Optional.ofNullable(mybatisProperties.getTypeAliasesPackage())
      .ifPresent(sqlSessionFactoryBean::setTypeAliasesPackage);
  Optional.ofNullable(mybatisProperties.getTypeHandlersPackage())
      .ifPresent(sqlSessionFactoryBean::setTypeHandlersPackage);
  if (!ObjectUtils.isEmpty(mybatisProperties.resolveMapperLocations())) {
    sqlSessionFactoryBean.setMapperLocations(mybatisProperties.resolveMapperLocations());
  }

  try {
    SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBean.getObject();
    if (sqlSessionFactory == null) {
      log.error("sqlSessionFactoryBean get object is null");
      return null;
    }
    register(configurableListableBeanFactory, sqlSessionFactory, prefixName + "SessionFactory",
        prefixName + "Sf");

    if (!Strings.isNullOrEmpty(mybatisProperties.getBasePackage())) {
      createBasePackageScanner((BeanDefinitionRegistry) configurableListableBeanFactory,
          mybatisProperties.getBasePackage(), prefixName);
    } else {
      createClassPathMapperScanner((BeanDefinitionRegistry) configurableListableBeanFactory,
          prefixName);
    }
    return sqlSessionFactory;
  } catch (Exception e) {
    log.error(e.getMessage(), e);
  }
  return null;
}
 
开发者ID:lord-of-code,项目名称:loc-framework,代码行数:52,代码来源:LocMybatisAutoConfiguration.java

示例15: mybatisSqlSessionFactoryBean

import org.springframework.util.ObjectUtils; //导入方法依赖的package包/类
/**
 * 这里全部使用mybatis-autoconfigure 已经自动加载的资源。不手动指定
 * 配置文件和mybatis-boot的配置文件同步
 * @return
 */
@Bean
@ConditionalOnMissingBean
public MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean() {
    MybatisSqlSessionFactoryBean mybatisPlus = new MybatisSqlSessionFactoryBean();
    mybatisPlus.setDataSource(dataSource);
    mybatisPlus.setVfs(SpringBootVFS.class);
    if (StringUtils.hasText(this.properties.getConfigLocation())) {
        mybatisPlus.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
    }
    mybatisPlus.setConfiguration(properties.getConfiguration());
    if (!ObjectUtils.isEmpty(this.interceptors)) {
        mybatisPlus.setPlugins(this.interceptors);
    }
    // MP 全局配置,更多内容进入类看注释
    GlobalConfiguration globalConfig = new GlobalConfiguration();
    //驼峰下划线规则
    globalConfig.setDbColumnUnderline(true);
    globalConfig.setDbType(DBType.MYSQL.name());
    // ID 策略
    // AUTO->`0`("数据库ID自增")
    // INPUT->`1`(用户输入ID")
    // ID_WORKER->`2`("全局唯一ID")
    // UUID->`3`("全局唯一ID")
    globalConfig.setIdType(3);
    mybatisPlus.setGlobalConfig(globalConfig);
    MybatisConfiguration mc = new MybatisConfiguration();
    mc.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
    mybatisPlus.setConfiguration(mc);
    if (this.databaseIdProvider != null) {
        mybatisPlus.setDatabaseIdProvider(this.databaseIdProvider);
    }
    if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
        mybatisPlus.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
    }
    if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
        mybatisPlus.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
    }
    if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
        mybatisPlus.setMapperLocations(this.properties.resolveMapperLocations());
    }
    return mybatisPlus;
}
 
开发者ID:MIYAOW,项目名称:MI-S,代码行数:48,代码来源:MybatisPlusConfig.java


注:本文中的org.springframework.util.ObjectUtils.isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。