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:de.metas.ui.web.window.datatypes.json.filters.JSONDocumentFilter.java

public static final List<JSONDocumentFilter> ofList(final List<DocumentFilter> filters) {
    if (filters == null || filters.isEmpty()) {
        return ImmutableList.of();
    }/*from   w  w w  .  j  a v a  2 s.co m*/

    return filters.stream().map(filter -> of(filter)).collect(GuavaCollectors.toImmutableList());
}

From source file:com.comcast.cats.monitor.util.FileSearchUtil.java

public static Integer countHitsByRegexList(String filePath, List<String> expressions) throws IOException {
    if ((null == expressions) || (expressions.isEmpty()) || (null == filePath) || (filePath.isEmpty())) {
        throw new IllegalArgumentException("Expressions/FilePath is NULL of EMPTY !!!");
    }//from ww w.j  ava 2 s.  c  o m

    LOGGER.info("Expressions to be searched = " + expressions);

    String combainedExpression = null;

    for (String expression : expressions) {
        if (null == combainedExpression) {
            combainedExpression = expression;
        } else {
            combainedExpression += OR + expression;
        }
    }

    return countHitsByRegex(filePath, combainedExpression);
}

From source file:com.cappuccino.requestframework.CookieManager.java

public static void saveCookie(DefaultHttpClient client) {

    //  //from w  ww . ja va 2 s.  c  o m
    if (CookieManager.initialized == false) {
        throw new RuntimeException(" ?");
    }
    if (client == null) {
        throw new IllegalArgumentException();
    }

    //    ? ?
    List<Cookie> cookieList = client.getCookieStore().getCookies();
    if (!cookieList.isEmpty()) {
        //  ? 
        for (Cookie cookie : cookieList) {

            //  sp ? 
            String cookieName = cookie.getName();
            String cookieValue = cookie.getValue();
            String cookieDomain = cookie.getDomain();
            // Date cookieExpiryDate = cookie.getExpiryDate();

            application.setCookieName(cookieName);
            application.setCookieValue(cookieValue);
            application.setCookieDomain(cookieDomain);
            // application.setCookieExpiryDate(cookieExpiryDate);

            if (RequestConfig.debuggable() == true) {
                Log.e();
                Log.e("?  ?");
                Log.e(" ? : " + cookieName);
                Log.e("  : " + cookieValue);
                Log.e(" ?? : " + cookieDomain);
            }
        }
    }
}

From source file:com.jms.notify.utils.StringUtil.java

/**
 *   ??. ??  // w  w  w  .  j  a  v  a  2  s .  co  m
 * 
 * @? @param obj
 * @? @return
 * @return boolean
 * @throws
 */
public static boolean isEmpty(List<?> obj) {
    return null == obj || obj.isEmpty();
}

From source file:eu.delving.x3ml.X3MLCommandLine.java

static void go(String xml, String x3ml, String policy, String rdf, String rdfFormat, boolean validate,
        int uuidTestSize) {
    Element xmlElement;//from   w  ww  .ja  v  a 2 s .c  o m
    if ("@".equals(xml)) {
        xmlElement = xml(System.in);
    } else {
        xmlElement = xml(file(xml));
    }
    InputStream x3mlStream;
    if ("@".equals(x3ml)) {
        if (validate) {
            throw exception("Cannot validate when X3ML is piped");
        }
        x3mlStream = System.in;
    } else {
        if (validate) {
            List<String> errors = X3MLEngine.validate(getStream(file(x3ml)));
            if (!errors.isEmpty()) {
                System.out.println("Validation:");
                for (String error : errors) {
                    System.out.println(error);
                }
                return;
            }
        }
        x3mlStream = getStream(file(x3ml));
    }
    X3MLEngine engine = X3MLEngine.load(x3mlStream);
    X3MLEngine.Output output = engine.execute(xmlElement,
            getValuePolicy(policy, X3MLGeneratorPolicy.createUUIDSource(uuidTestSize)));
    output.write(rdf(rdf), rdfFormat);
}

From source file:com.glaf.core.todo.config.TodoConfig.java

public static void reload() {
    if (!loading.get()) {
        try {/*from w w w  . j a  va2s . c  o m*/
            loading.set(true);
            ISysTodoService todoService = ContextFactory.getBean("sysTodoService");
            List<Todo> list = todoService.getTodoList();
            if (list != null && !list.isEmpty()) {
                for (Todo todo : list) {
                    todoMap.put(todo.getCode(), todo);
                    todoMap.put(String.valueOf(todo.getId()), todo);
                    if (StringUtils.isNotEmpty(todo.getProcessName())) {
                        String key = todo.getProcessName();
                        if (!todoMap.containsKey(key)) {
                            todoMap.put(key, todo);
                        }
                        if (StringUtils.isNotEmpty(todo.getTaskName())) {
                            key = key + "_" + todo.getTaskName();
                            if (!todoMap.containsKey(key)) {
                                todoMap.put(key, todo);
                            }
                        }
                    }
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        } finally {
            loading.set(false);
        }
    }
}

From source file:eu.trentorise.smartcampus.services.semantic.impl.ServiceScript.java

private static List<Concept> convertConcepts(List<Tag> tagList) {
    List<Concept> list = new ArrayList<Concept>();
    if (tagList != null && !tagList.isEmpty()) {
        for (Tag tag : tagList) {
            Concept c = new Concept();
            c.setId(tag.getId());/*from w w  w .  ja v  a  2s .c  om*/
            c.setName(tag.getName());
            c.setSummary(tag.getSummary());
            c.setDescription(tag.getDescription());
            list.add(c);
        }
    }
    return list;
}

From source file:org.datacleaner.util.http.HttpXmlUtils.java

public static String getChildNodeText(Node node, String childNodeName) {
    List<Node> childNodes = getChildNodesByName(node, childNodeName);
    if (childNodes.isEmpty()) {
        return null;
    }//from   www  .  j  a va 2  s.c  om
    if (childNodes.size() > 1) {
        throw new IllegalArgumentException(
                "The node " + node + " contains several childNodes named " + childNodeName);
    }
    return getText(childNodes.get(0));
}

From source file:com.glaf.core.util.IdentityUtils.java

/**
 * ???/* ww w . ja  v a2 s .c o  m*/
 * 
 * @param sqlSession
 * @param statement
 * @param paramMap
 * @return
 */
public static List<String> getActorIds(SqlSession sqlSession, String statement, Map<String, Object> paramMap) {
    List<String> actorIds = new java.util.ArrayList<String>();
    MyBatisEntityDAO entityDAO = new MyBatisEntityDAO(sqlSession);
    List<Object> rows = entityDAO.getList(statement, paramMap);
    if (rows != null && !rows.isEmpty()) {
        for (Object object : rows) {
            if (object instanceof com.glaf.core.identity.User) {
                String actorId = ((com.glaf.core.identity.User) object).getActorId();
                if (!actorIds.contains(actorId)) {
                    actorIds.add(actorId);
                }
            } else if (object instanceof String) {
                String actorId = (String) object;
                if (!actorIds.contains(actorId)) {
                    actorIds.add(actorId);
                }
            }
        }
    }
    return actorIds;
}

From source file:com.sporeon.baseutil.OrdenacaoUtil.java

/**
* Mtodo responsvel por retorna uma lista de Object ordenada pelo nome do campo informado.
* @author Senio Caires/*from w  ww  . ja v  a 2 s  . com*/
* @param lista - Lista
* @param campo - Campo
* @param tipoOrdenacao - Tipo de ordenao
* @return lista ordenada
*/
public static List ordenarLista(final List lista, final String campo, final TipoOrdenacao tipoOrdenacao) {

    if (lista != null && !lista.isEmpty() && campo != null && !(campo.trim().length() == 0)) {

        BeanComparator ordem = new BeanComparator(campo, new Comparator() {

            @Override
            public int compare(final Object o1, final Object o2) {

                int resultado = 0;
                final int maximoCaracteres = 20;

                if (o1 instanceof Integer) {
                    resultado = ((String) ManipulacaoUtil
                            .adicionarChar('0', maximoCaracteres, o2.toString(), true))
                                    .compareToIgnoreCase((String) ManipulacaoUtil.adicionarChar('0',
                                            maximoCaracteres, o1.toString(), true));
                } else {
                    resultado = ((String) o2.toString()).compareToIgnoreCase((String) o1.toString());
                }

                return resultado;
            }
        });

        Collections.sort(lista, ordem);

        if (TipoOrdenacao.CRESCENTE.equals(tipoOrdenacao)) {
            Collections.reverse(lista);
        }
    }

    return lista;
}