本文整理汇总了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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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 );
}
示例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);
}
示例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]));
}
}
示例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));
}
示例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 );
}
示例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;
}
示例12: isNotEmpty
import org.apache.commons.lang3.ArrayUtils; //导入方法依赖的package包/类
/**
* 判断数组是否非空
*/
public static boolean isNotEmpty(Object[] array) {
return !ArrayUtils.isEmpty(array);
}
示例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);
}
}
}
示例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