Example usage for java.util List isEmpty

List of usage examples for java.util List isEmpty

Introduction

In this page you can find the example usage for java.util List isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:com.pinterest.deployservice.common.ChangeFeedJob.java

private static String toStringRepresentation(Object object) throws IllegalAccessException {
    if (object == null) {
        return "None";
    }//from www.  j  a va  2 s.  c  o m

    if (object instanceof List) {
        List<?> list = (List<?>) object;
        if (list.isEmpty()) {
            return "[]";
        }

        StringBuilder sb = new StringBuilder("[");
        for (Object element : list) {
            sb.append(toStringRepresentation(element));
            sb.append(", ");
        }

        sb.delete(sb.length() - 2, sb.length());
        sb.append(']');
        return sb.toString();
    }

    Field[] fields = object.getClass().getDeclaredFields();
    if (fields.length == 0) {
        return "{}";
    }

    StringBuilder sb = new StringBuilder("{");
    for (Field field : fields) {
        field.setAccessible(true);
        Object fieldItem = field.get(object);
        sb.append(field.getName());
        sb.append(":");
        sb.append(fieldItem);
        sb.append(", ");
    }

    sb.delete(sb.length() - 2, sb.length());
    sb.append('}');
    return sb.toString();
}

From source file:com.u2apple.rt.util.AndroidDeviceUtils.java

public static List<AndroidDeviceRanking> parse(List<AndroidDevice> devices) {
    List<AndroidDeviceRanking> androidDevices = new ArrayList<>();
    if (devices != null && !devices.isEmpty()) {
        for (AndroidDevice device : devices) {
            androidDevices.add(new AndroidDeviceRanking(device));
        }//from  www .  j  av a 2 s.  c  o m
    }
    return androidDevices;
}

From source file:com.ineunet.knife.persist.PersistUtils.java

/**
 * @since 1.2.3/*from   w  w  w . ja  v  a 2 s  .c  om*/
 */
public static boolean existsTable(String dbName, String tableName, JdbcTemplate jdbcTemplate) {
    String sql = "select `TABLE_NAME` from `INFORMATION_SCHEMA`.`TABLES` where `TABLE_SCHEMA`=? and `TABLE_NAME`=?";
    List<String> table = jdbcTemplate.queryForList(sql, String.class, dbName, tableName);
    if (table.isEmpty())
        return false;
    return true;
}

From source file:com.netflix.spinnaker.clouddriver.kubernetes.provider.KubernetesModelUtil.java

private static boolean someUpRemainingUnknown(List<Map<String, String>> healthsList) {
    List<Map<String, String>> knownHealthList = healthsList.stream()
            .filter(h -> !stateEquals(h, HealthState.Unknown)).collect(Collectors.toList());

    return !knownHealthList.isEmpty() && knownHealthList.stream().allMatch(h -> stateEquals(h, HealthState.Up));
}

From source file:com.netflix.spinnaker.clouddriver.kubernetes.provider.KubernetesModelUtil.java

private static boolean someSucceededRemainingUnknown(List<Map<String, String>> healthsList) {
    List<Map<String, String>> knownHealthList = healthsList.stream()
            .filter(h -> !stateEquals(h, HealthState.Unknown)).collect(Collectors.toList());

    return !knownHealthList.isEmpty()
            && knownHealthList.stream().allMatch(h -> stateEquals(h, HealthState.Succeeded));
}

From source file:com.pieframework.runtime.utils.ArtifactManager.java

private static String getArchivePath(List<File> flist) {

    if (!flist.isEmpty()) {
        if (flist.size() == 1 && flist.get(0).isFile()
                && FilenameUtils.isExtension(flist.get(0).getName(), "zip")) {
            return flist.get(0).getPath();
        }/* w w  w . j  a v a2  s . co  m*/
    }

    return null;
}

From source file:com.glaf.template.config.TemplateConfig.java

public static void reload() {
    if (!loading.get()) {
        InputStream inputStream = null;
        try {/*w w  w . j av  a2s. c  o  m*/
            loading.set(true);
            String config = SystemProperties.getConfigRootPath() + "/conf/templates/";
            logger.debug("load config dir:" + config);
            File directory = new File(config);
            if (directory.exists() && directory.isDirectory()) {
                TemplateReader reader = new TemplateReader();
                String[] filelist = directory.list();
                if (filelist != null) {
                    for (int i = 0, len = filelist.length; i < len; i++) {
                        String filename = config + filelist[i];
                        File file = new File(filename);
                        if (file.isFile() && file.getName().endsWith(".xml")) {
                            logger.debug("read config:" + filename);
                            inputStream = new FileInputStream(file);
                            List<Template> templates = reader.readTemplates(inputStream);
                            if (templates != null && !templates.isEmpty()) {
                                for (Template template : templates) {
                                    if (template.getName() != null) {
                                        concurrentMap.put(template.getName().toLowerCase(), template);
                                    }
                                    if (template.getTemplateId() != null) {
                                        concurrentMap.put(template.getTemplateId().toLowerCase(), template);
                                    }
                                }
                            }
                            IOUtils.closeStream(inputStream);
                        }
                    }
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            logger.error(ex);
        } finally {
            loading.set(false);
            IOUtils.closeStream(inputStream);
        }
    }
}

From source file:com.taobao.tddl.jdbc.group.util.ExceptionUtils.java

/**
 * sqlException error loglog,/*from  w  w w.  j  a va  2 s. co  m*/
 * 
 * list
 * 
 * @param logger
 * @param message
 * @param sqlExceptions
 */
public static void printSQLExceptionToErrorLog(Log logger, String message, List<SQLException> sqlExceptions) {
    if (sqlExceptions != null && !sqlExceptions.isEmpty()) {
        for (SQLException sqlException : sqlExceptions) {
            logger.error(message, sqlException);
        }
        sqlExceptions.clear();
    }
}

From source file:de.metas.ui.web.window.datatypes.json.JSONLookupValuesList.java

@JsonCreator
private static final JSONLookupValuesList ofJSONLookupValuesList(
        @JsonProperty("values") final List<JSONLookupValue> jsonLookupValues) {
    if (jsonLookupValues == null || jsonLookupValues.isEmpty()) {
        return EMPTY;
    }//  w  w  w .  j ava  2  s.c om

    return new JSONLookupValuesList(ImmutableList.copyOf(jsonLookupValues), ImmutableMap.of());
}

From source file:com.squarespace.template.TreeEmitter.java

private static void emitArgs(Arguments args, StringBuilder buf) {
    List<String> rawArgs = args.getArgs();
    if (!rawArgs.isEmpty()) {
        buf.append("delim='");
        buf.append(StringEscapeUtils.escapeJava("" + args.getDelimiter()));
        buf.append("' parsed=").append(args.getArgs());
    }//from  w  w w .ja v a 2s .  co  m
}