Java Code Examples for org.apache.commons.lang3.ArrayUtils.isEmpty()

The following are Jave code examples for showing how to use isEmpty() of the org.apache.commons.lang3.ArrayUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ECFileCache   File: RedisAccessBase.java   View Source Code Vote up 6 votes
/**
 * 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));
}
 
Example 2
Project: spring-cloud-samples   File: ErrorHolder.java   View Source Code Vote up 6 votes
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;
}
 
Example 3
Project: DailyHelper   File: ParameterBuilder.java   View Source Code Vote up 6 votes
/**
 * 获取查询参数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;
}
 
Example 4
Project: mumu-core   File: DataUtil.java   View Source Code Vote up 5 votes
/**
 * 分别去空格
 * 
 * @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;
}
 
Example 5
Project: jvm-sandbox   File: CoreConfigure.java   View Source Code Vote up 5 votes
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;
}
 
Example 6
Project: iBase4J-Common   File: DataUtil.java   View Source Code Vote up 5 votes
/**
 * 分别去空格
 * 
 * @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;
}
 
Example 7
Project: referenceapp   File: AdminUIApplication.java   View Source Code Vote up 5 votes
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 );
	
}
 
Example 8
Project: JAVA-   File: DataUtil.java   View Source Code Vote up 5 votes
/**
 * 分别去空格
 * 
 * @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;
}
 
Example 9
Project: automat   File: DataUtil.java   View Source Code Vote up 5 votes
/**
 * 分别去空格
 * 
 * @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;
}
 
Example 10
Project: raven   File: CacheKeyGenerator.java   View Source Code Vote up 5 votes
/** 根据传入参数自动拼接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);
}
 
Example 11
Project: brick-pop-solver   File: BrickPopSolver.java   View Source Code Vote up 5 votes
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]));
    }
}
 
Example 12
Project: springmock   File: AnnotationDetails.java   View Source Code Vote up 5 votes
public final Collection<String> getAlias() {
	final String[] alias = annotationParamExtractor.getAliasParam();

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

	return new HashSet<>(asList(alias));
}
 
Example 13
Project: iBase4J   File: DataUtil.java   View Source Code Vote up 5 votes
/**
 * 分别去空格
 * 
 * @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;
}
 
Example 14
Project: spring-boot-start-current   File: DefaultInjectionAttackHandler.java   View Source Code Vote up 5 votes
@Override
public boolean isXSSInjectionAttack ( String rawCharacters , String[] ignoreStrings ) {
    if ( ArrayUtils.isEmpty( ignoreStrings ) ) {
        return this.isXSSInjectionAttack( rawCharacters );
    }
    return this.ignoreStringMatchingHandle( this.getXSSInjectionAttackMatcher( rawCharacters ) , ignoreStrings );
}
 
Example 15
Project: tauren   File: ResultSetHandlerFactory.java   View Source Code Vote up 4 votes
/**
 * 创建查询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;
}
 
Example 16
Project: SmartFramework   File: ArrayUtil.java   View Source Code Vote up 4 votes
/**
 * 判断数组是否非空
 */
public static boolean isNotEmpty(Object[] array) {
    return !ArrayUtils.isEmpty(array);
}
 
Example 17
Project: versioning-spring-boot-starter   File: VersionRequestMappingHandlerMapping.java   View Source Code Vote up 4 votes
private String processPathRequestMapping(String defaultValue, RequestMapping requestMappingMethod) {
    return (requestMappingMethod == null || ArrayUtils.isEmpty(requestMappingMethod.path())) ?
            defaultValue :
            defaultValue.concat(String.join("/", requestMappingMethod.path()));
}
 
Example 18
Project: jvm-sandbox   File: DefaultCoreModuleManager.java   View Source Code Vote up 4 votes
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);
            }

        }

    }
 
Example 19
Project: versioning-spring-boot-starter   File: VersionRequestMappingHandlerMapping.java   View Source Code Vote up 4 votes
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("#"));
}
 
Example 20
Project: light-framework   File: ArrayUtil.java   View Source Code Vote up 2 votes
/**
 * 判断数组是否为空
 * 
 * @param array
 * @return
 */
public static boolean isEmpty(Object[] array) {
	return ArrayUtils.isEmpty(array);
}