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:Main.java

public static boolean isIntentResolvable(final Context pContext, final Intent pIntent) {
    final List<ResolveInfo> resolveInfo = pContext.getPackageManager().queryIntentActivities(pIntent, 0);
    return (resolveInfo != null) && !resolveInfo.isEmpty();
}

From source file:Main.java

public static String getCountry(Context context) {
    @SuppressWarnings("static-access")
    LocationManager lm = (LocationManager) context.getSystemService(context.LOCATION_SERVICE);
    Location l = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    Geocoder gc = new Geocoder(context);

    try {/*from  w  w w.j  a v a 2 s  .c o m*/
        List<Address> address = gc.getFromLocation(l.getLatitude(), l.getLongitude(), 1);
        if (address != null && address.isEmpty() == false)
            return address.get(0).getCountryName();
    } catch (IOException e) {
        return "";
    }

    return "";
}

From source file:com.reprezen.swagedit.validation.ValidationUtil.java

private static Node findNode(MappingNode root, List<String> paths) {
    if (paths.isEmpty())
        return root;

    String path = paths.get(0);/*from  w  ww .j  ava  2  s.  c  om*/
    if (path.startsWith("/")) {
        path = path.substring(1, path.length());
    }

    final List<String> next = paths.subList(1, paths.size());
    // ~1 is use to escape /
    if (path.contains("~1")) {
        path = path.replaceAll("~1", "/");
    }

    for (NodeTuple child : root.getValue()) {
        if (child.getKeyNode() instanceof ScalarNode) {
            ScalarNode scalar = (ScalarNode) child.getKeyNode();

            if (scalar.getValue().equals(path)) {
                return findNode(child, next);
            }
        }
    }

    return root;
}

From source file:controllers.charroi.Cars.java

public static void delete(long id) {
    Car car = Car.findById(id);//from w w  w  .j  a  v  a 2  s.com
    List<Input> inputs = Input.byCar(car);

    if (inputs.isEmpty()) {
        car.delete();
        flash.success("deleted");
    } else {
        flash.error("Cette voiture ne peut pas tre supprime");
    }

    index();
}

From source file:fi.vm.sade.organisaatio.service.util.OrganisaatioToSolrInputDocumentUtil.java

private static void addNimiHistoria(SolrInputDocument doc, String fieldName, List<OrganisaatioNimi> nimet) {
    if (nimet.isEmpty()) {
        LOG.warn("Nimihistoriassa ei nimi!");
    }//from  w w w.  j ava  2 s  . com
    for (OrganisaatioNimi nimi : nimet) {
        LOG.debug(
                "Nimihistoria " + fieldName + ": " + Joiner.on(", ").join(nimi.getNimi().getValues().values()));

        // Listn nimi kaikilla kielill
        for (String nimiValue : nimi.getNimi().getValues().values()) {
            add(doc, fieldName, nimiValue);
        }
    }
}

From source file:Main.java

/**
 * Gets the immediately descendant element from the parent element.
 * //from   w w w .j  a  va2 s.  c o  m
 * @param parent the parent element in the element tree
 * @param tagName the specified tag name.
 * @return immediately descendant element of parent element, NULL otherwise.
 */
public static Element getElement(Element parent, String tagName) {
    List<Element> children = getElements(parent, tagName);

    if (children.isEmpty()) {
        return null;
    } else {
        return children.get(0);
    }
}

From source file:Main.java

/**
 * Remove an element from a map whose values are lists of elements.
 * @param <T> the type of the keys in the map.
 * @param <U> the type of the elements in the lists.
 * @param key the key for the value to remove.
 * @param value the value to remove.//from   ww  w. j ava2s.  c  o  m
 * @param map the map from which to remove the key/value pair.
 */
public static <T, U> void removeFromListMap(T key, U value, Map<T, List<U>> map) {
    List<U> list = map.get(key);
    if (list == null)
        return;
    list.remove(value);
    if (list.isEmpty())
        map.remove(key);
}

From source file:com.hangum.tadpole.rdb.core.util.DialogUtil.java

/**
 * dialog util/*w w  w . j a  v a  2  s. co m*/
 * @param userDB
 * @param strObject
 */
public static void popupDMLDialog(UserDBDAO userDB, String strObject) {
    try {
        TableDAO tableDao = null;
        List<TableDAO> listTable = userDB.getListTable();
        if (listTable.isEmpty()) {
            if (DBDefine.POSTGRE_DEFAULT != userDB.getDBDefine()) {
                tableDao = TadpoleObjectQuery.getTable(userDB, StringUtils.trim(strObject));
            } else {
                tableDao = new TableDAO(strObject, "");
            }
        } else {
            for (TableDAO tmpTableDAO : listTable) {
                if (strObject.equalsIgnoreCase(tmpTableDAO.getName())) {
                    tableDao = tmpTableDAO;
                    break;
                }
            }
        }

        if (tableDao != null) {
            GenerateStatmentDMLDialog dialog = new GenerateStatmentDMLDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), false, userDB, tableDao);
            dialog.open();
        }

    } catch (Exception e) {
        logger.error("f4 function", e);
    }
}

From source file:Main.java

private static final <T> int indexOfMinSize(final List<Set<T>> sets) {
    if (sets.isEmpty())
        throw new IllegalArgumentException("empty sets");

    int res = 0;/*  w ww . java  2s  .  c o m*/
    for (int i = 1; i < sets.size(); i++) {
        if (sets.get(i).size() < sets.get(res).size())
            res = i;
    }
    return res;
}

From source file:Main.java

/**
 * Creates an unmodifiable shallow copy of the given original {@link List}. <p> While the copy returns an immutable
 * copy of the {@link List} the content is not cloned in any way. Unless the content is immutable by itself the
 * result is not fully immutable. In the shallow copy all references are the same as in the original {@link List}!
 * </p>//from w  w w.  ja  v a  2 s  .  c  o m
 *
 * @param original The {@link List} to copy the elements fro.
 * @param <E>      The type of the elements
 *
 * @return Returns an immutable (unmodifiable) copy of the original {@link List} with all the elements added but not
 * cloned!
 */
public static <E> List<E> createUnmodifiableShallowCopy(final List<E> original) {
    if (original == null || original.isEmpty()) {
        return Collections.emptyList();
    } else {
        return Collections.unmodifiableList(new ArrayList<E>(original));
    }
}