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


Java ArrayUtils.isEmpty方法代码示例

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


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

示例1: trim

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * 分别去空格
 * 
 * @param paramArray
 * @return
 */
public static final String[] trim(String[] paramArray) {
	if (ArrayUtils.isEmpty(paramArray)) {
		return paramArray;
	}
	String[] resultArray = new String[paramArray.length];
	for (int i = 0; i < paramArray.length; i++) {
		String param = paramArray[i];
		resultArray[i] = StringUtils.trim(param);
	}
	return resultArray;
}
 
开发者ID:mumucommon,项目名称:mumu-core,代码行数:18,代码来源:DataUtil.java

示例2: convertChunk

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * Convert chunks get from Redis.
 * Make a zero-filled array if failed to read chunk from Redis.
 *
 * @param redisDataArray chunks get from all Redis nodes
 * @param chunkSize length of chunk data
 * @return pair of chunks and erasures array
 */
static Pair<byte[][], int[]> convertChunk(byte[][] redisDataArray, int chunkSize) {
  Validate.isTrue(ArrayUtils.isNotEmpty(redisDataArray));

  List<Integer> erasures = new ArrayList<Integer>();

  int i = 0;
  for (byte[] chunk : redisDataArray) {
    // can not read chunk data from redis
    // make a zero-filled array for ec decode
    if (ArrayUtils.isEmpty(chunk) || chunk.length != chunkSize) {
      chunk = new byte[chunkSize];
      erasures.add(i);
    }
    redisDataArray[i++] = chunk;
  }
  return Pair.create(redisDataArray, adjustErasures(erasures, redisDataArray.length));
}
 
开发者ID:XiaoMi,项目名称:ECFileCache,代码行数:26,代码来源:RedisAccessBase.java

示例3: getMessage

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public static String getMessage(CodeTemp templ, String... params) {
	String regContent = templ.getTemp();
	int index = 0;
	while (regContent.indexOf("{}") >= 0) {
		if (ArrayUtils.isEmpty(params) || params.length <= index) {
			if (regContent.indexOf("{}") >= 0) {
				regContent = regContent.replaceAll("\\{\\}", "");
			}
			break;
		}
		regContent = StringUtils.replaceOnce(regContent, "{}", params[index]);
		index++;
	}

	return regContent;
}
 
开发者ID:zhaoqilong3031,项目名称:spring-cloud-samples,代码行数:17,代码来源:ErrorHolder.java

示例4: getQueryParams

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * 获取查询参数Map
 *
 * @param obj pojo对象
 * @return Map[String, Object]
 */
public static <T> Map<String, Object> getQueryParams(T obj) {
    if (obj == null) {
        return new HashMap<>(0);
    }

    Field[] fields = obj.getClass().getDeclaredFields();
    if (ArrayUtils.isEmpty(fields)) {
        return new HashMap<>(0);
    }

    Map<String, Object> params = new HashMap<>(fields.length);
    for (Field field : fields) {
        Object value = getValue(field, obj);
        if (value != null) params.put(field.getName(), value);
    }
    return params;
}
 
开发者ID:xianrendzw,项目名称:DailyHelper,代码行数:24,代码来源:ParameterBuilder.java

示例5: replaceWithSysPropUserHome

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
private static String[] replaceWithSysPropUserHome(final String[] pathArray) {
    if (ArrayUtils.isEmpty(pathArray)) {
        return pathArray;
    }
    final String SYS_PROP_USER_HOME = System.getProperty("user.home");
    for (int index = 0; index < pathArray.length; index++) {
        if (StringUtils.startsWith(pathArray[index], "~")) {
            pathArray[index] = StringUtils.replaceOnce(pathArray[index], "~", SYS_PROP_USER_HOME);
        }
    }
    return pathArray;
}
 
开发者ID:alibaba,项目名称:jvm-sandbox,代码行数:13,代码来源:CoreConfigure.java

示例6: main

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	String[] localArgs = args;
	if (ArrayUtils.isEmpty(localArgs)) {
		localArgs = (String[])ArrayUtils.add(localArgs, "server");
		localArgs = (String[])ArrayUtils.add(localArgs, "admin-ui.yml");
	}
	new AdminUIApplication().run(localArgs );
	
}
 
开发者ID:arityllc,项目名称:referenceapp,代码行数:10,代码来源:AdminUIApplication.java

示例7: generate

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/** 根据传入参数自动拼接cache 存储key */
@Override
public Object generate(Object manager, Method method, Object... params)
{
    if (ArrayUtils.isEmpty(params)){
        return null;
    }
    // 移除对象参数
    int i = 0;
    if (params.length > 1)
    {
        if(params[0] instanceof Integer || params[0] instanceof String || params[0] instanceof Float
                || params[0] instanceof Double || params[0] instanceof Character || params[0] instanceof Byte
                || params[0] instanceof Boolean || params[0] instanceof Short || params[0] instanceof Long )
        {
            i = 0; // do nothing
        }else {
            i = 1;
        }
    }
    StringBuffer sb = new StringBuffer();
    for (; i < params.length; i++)
    {
        sb.append(params[i]);
        if ((params.length - i) > 1){
            sb.append('_');
        }
    }

    return sb.toString().toUpperCase(Locale.US);
}
 
开发者ID:marlonwang,项目名称:raven,代码行数:32,代码来源:CacheKeyGenerator.java

示例8: main

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
    final BrickPopSolver solver = new BrickPopSolver();
    if (ArrayUtils.isEmpty(args)) {
        solver.solve().play();
    } else {
        solver.solve(Paths.get(args[0]));
    }
}
 
开发者ID:neocotic,项目名称:brick-pop-solver,代码行数:9,代码来源:BrickPopSolver.java

示例9: getAlias

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
public final Collection<String> getAlias() {
	final String[] alias = annotationParamExtractor.getAliasParam();

	if (ArrayUtils.isEmpty(alias)) {
		return Collections.emptyList();
	}

	return new HashSet<>(asList(alias));
}
 
开发者ID:pchudzik,项目名称:springmock,代码行数:10,代码来源:AnnotationDetails.java

示例10: isXSSInjectionAttack

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
@Override
public boolean isXSSInjectionAttack ( String rawCharacters , String[] ignoreStrings ) {
    if ( ArrayUtils.isEmpty( ignoreStrings ) ) {
        return this.isXSSInjectionAttack( rawCharacters );
    }
    return this.ignoreStringMatchingHandle( this.getXSSInjectionAttackMatcher( rawCharacters ) , ignoreStrings );
}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:8,代码来源:DefaultInjectionAttackHandler.java

示例11: createQueryHandler

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * 创建查询ResultSetHandler
 */
public static <T> ResultSetHandler<List<T>> createQueryHandler(final Class<T> type) {
    ResultSetHandler<List<T>> rsh = new ResultSetHandler<List<T>>() {

        @Override
        @SuppressWarnings("unchecked")
        public List<T> handle(ResultSet rs) throws SQLException {
            List<T> rets = new ArrayList<T>();

            while (rs.next()) {
                try {
                    if (ClassUtil.isPrimitive(type)) {
                        T object = (T) rs.getObject(1);
                        rets.add(object);
                    } else {
                        Field[] fields = type.getDeclaredFields();
                        if (ArrayUtils.isEmpty(fields)) {
                            break;
                        }

                        Object obj = Class.forName(type.getName()).newInstance();

                        //遍历每个字段
                        for (Field field : fields) {
                            if (isIgnore(field)) {
                                continue;
                            }
                            field.setAccessible(true);
                            field.set(obj, rs.getObject(getFieldName(field)));
                        }
                        rets.add((T) obj);
                    }
                } catch (Exception e) {
                    throw new RuntimeException("创建实体对象失败", e);
                }
            }

            return rets;
        }
    };

    return rsh;
}
 
开发者ID:huhuics,项目名称:tauren,代码行数:46,代码来源:ResultSetHandlerFactory.java

示例12: isNotEmpty

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
 * 判断数组是否非空
 */
public static boolean isNotEmpty(Object[] array) {
    return !ArrayUtils.isEmpty(array);
}
 
开发者ID:envyandgreed,项目名称:SmartFramework,代码行数:7,代码来源:ArrayUtil.java

示例13: processPathRequestMapping

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
private String processPathRequestMapping(String defaultValue, RequestMapping requestMappingMethod) {
    return (requestMappingMethod == null || ArrayUtils.isEmpty(requestMappingMethod.path())) ?
            defaultValue :
            defaultValue.concat(String.join("/", requestMappingMethod.path()));
}
 
开发者ID:fintonic,项目名称:versioning-spring-boot-starter,代码行数:6,代码来源:VersionRequestMappingHandlerMapping.java

示例14: injectRequiredResource

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
private void injectRequiredResource(final CoreModule coreModule) throws IllegalAccessException {

        final Module module = coreModule.getModule();
        final Field[] resourceFieldArray = FieldUtils.getFieldsWithAnnotation(module.getClass(), Resource.class);
        if (ArrayUtils.isEmpty(resourceFieldArray)) {
            return;
        }

        for (final Field resourceField : resourceFieldArray) {
            final Class<?> fieldType = resourceField.getType();

            // LoadedClassDataSource对象注入
            if (LoadedClassDataSource.class.isAssignableFrom(fieldType)) {
                FieldUtils.writeField(resourceField, module, classDataSource, true);
            }

            // ModuleContactorManager对象注入
            else if (ModuleEventWatcher.class.isAssignableFrom(fieldType)) {
                final ModuleEventWatcher moduleEventWatcher = new DefaultModuleEventWatcher(
                        inst,
                        classDataSource,
                        coreModule,
                        cfg.isEnableUnsafe()
                );
                moduleLifeCycleEventBus.append((DefaultModuleEventWatcher) moduleEventWatcher);
                FieldUtils.writeField(resourceField, module, moduleEventWatcher, true);
            }

            // ModuleController对象注入
            else if (ModuleController.class.isAssignableFrom(fieldType)) {
                final ModuleController moduleController = new DefaultModuleController(coreModule, this);
                FieldUtils.writeField(resourceField, module, moduleController, true);
            }

            // ModuleManager对象注入
            else if (ModuleManager.class.isAssignableFrom(fieldType)) {
                final ModuleManager moduleManager = new DefaultModuleManager(this);
                FieldUtils.writeField(resourceField, module, moduleManager, true);
            }

            // ConfigInfo注入
            else if (ConfigInfo.class.isAssignableFrom(fieldType)) {
                final ConfigInfo configInfo = new DefaultConfigInfo(cfg);
                FieldUtils.writeField(resourceField, module, configInfo, true);
            }

            // EventMonitor注入
            else if (EventMonitor.class.isAssignableFrom(fieldType)) {
                FieldUtils.writeField(resourceField, module, new DefaultEventMonitor(), true);
            }

            // 其他情况需要输出日志警告
            else {
                logger.warn("inject required @Resource field[name={};] into module[id={};class={};] failed, type={}; was not support yet.",
                        resourceField.getName(), coreModule.getUniqueId(), module.getClass(), fieldType);
            }

        }

    }
 
开发者ID:alibaba,项目名称:jvm-sandbox,代码行数:61,代码来源:DefaultCoreModuleManager.java

示例15: processMethodRequestMapping

import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
private String processMethodRequestMapping(String defaultValue, RequestMapping requestMappingMethod) {
    return (requestMappingMethod == null || ArrayUtils.isEmpty(requestMappingMethod.method())) ?
            defaultValue :
            Stream.of(requestMappingMethod.method()).map(Enum::name).sorted().collect(Collectors.joining("#"));
}
 
开发者ID:fintonic,项目名称:versioning-spring-boot-starter,代码行数:6,代码来源:VersionRequestMappingHandlerMapping.java


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