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.glaf.core.util.IdentityUtils.java

/**
 * ???//ww w  . jav  a 2s.  c  om
 * 
 * @param sqlSession
 * @param paramMap
 * @return
 */
public static List<String> getActorIds(SqlSession sqlSession, Map<String, Object> paramMap) {
    List<String> actorIds = new java.util.ArrayList<String>();
    String statementId = CustomProperties.getString("sys.getActorIds");
    if (StringUtils.isEmpty(statementId)) {
        statementId = "getActorIds";
    }
    MyBatisEntityDAO entityDAO = new MyBatisEntityDAO(sqlSession);
    List<Object> rows = entityDAO.getList(statementId, 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.netflix.imfutility.itunes.inputparameters.ITunesInputParametersValidator.java

private static void validateFiles(List<File> files, String fileType) throws ArgumentValidationException {
    if (files != null && !files.isEmpty()) {
        files.forEach((file) -> validateFile(file, fileType));
    }//from   w  ww  .j a  v  a 2 s.co m
}

From source file:com.fizzed.blaze.internal.DependencyHelper.java

/**
 * Get the dependency list from the application configuration file.
 * @param config/*from ww  w  .  j a  v a 2  s  .  com*/
 * @return 
 */
static public List<Dependency> applicationDependencies(Config config) {
    List<String> ds = config.valueList(Config.KEY_DEPENDENCIES).getOrNull();

    if (ds == null || ds.isEmpty()) {
        return null;
    }

    List<Dependency> dependencies = new ArrayList<>(ds.size());

    ds.stream().forEach((d) -> {
        dependencies.add(Dependency.parse(d));
    });

    return dependencies;
}

From source file:net.di2e.ecdr.commons.util.GeospatialUtils.java

/**
 * Converts a list of points into a geotools-based bounding box.
 *
 * @param points List of points, should only include the 'upper-left' and 'lower-right' points in that order.
 *               Code will not look at any other points that are passed in.
 * @return BoundingBox if transformation works, null otherwise.
 *///from   ww  w  .j  a  v  a  2 s.  c o m
public static BoundingBox pointsToBBox(List<org.opengis.geometry.primitive.Point> points) {
    BoundingBox bbox = null;
    if (!points.isEmpty()) {
        org.opengis.geometry.primitive.Point point1 = points.get(0);
        org.opengis.geometry.primitive.Point point2 = points.get(1);
        bbox = new ReferencedEnvelope(point1.getDirectPosition().getCoordinate()[0],
                point2.getDirectPosition().getCoordinate()[0], point1.getDirectPosition().getCoordinate()[1],
                point2.getDirectPosition().getCoordinate()[1], DefaultGeographicCRS.WGS84);
    }
    return bbox;
}

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

/**
 * get table script//from  w  w  w.  j a v a2 s .c om
 * 
 * @param userDB
 * @param tableDAO
 * @param showTableColumns
 * @return
 */
public static String genTableScript(UserDBDAO userDB, TableDAO tableDAO,
        List<TableColumnDAO> showTableColumns) {
    if (showTableColumns == null)
        return "";
    if (showTableColumns.isEmpty())
        return "";

    StringBuffer sbSQL = new StringBuffer();
    try {
        sbSQL.append("SELECT "); //$NON-NLS-1$
        for (int i = 0; i < showTableColumns.size(); i++) {
            TableColumnDAO dao = showTableColumns.get(i);
            sbSQL.append(StringUtils.trim(dao.getSysName()));

            //  ? ,  
            if (i < (showTableColumns.size() - 1))
                sbSQL.append(", "); //$NON-NLS-1$
            else
                sbSQL.append(" "); //$NON-NLS-1$
        }

        sbSQL.append(PublicTadpoleDefine.LINE_SEPARATOR + "FROM "); //$NON-NLS-1$ 
        sbSQL.append(SQLUtil.getTableName(userDB, tableDAO));
        sbSQL.append(PublicTadpoleDefine.SQL_DELIMITER);

    } catch (Exception e) {
        logger.error("Generate select statement", e);

        Status errStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); //$NON-NLS-1$
        ExceptionDetailsErrorDialog.openError(null, Messages.get().Error,
                Messages.get().GenerateSQLSelectAction_0, errStatus); //$NON-NLS-1$
    }

    return sbSQL.toString();
}

From source file:com.kdmanalytics.toif.util.MemberUtil.java

/**
 * find suitable resources/*www.  jav  a 2 s. c o m*/
 * 
 * @param member
 * @param file
 * @return
 * @throws CoreException
 */
public static IResource findMembers(IResource member, IFileGroup file) throws CoreException {
    String name = file.getName();

    String path = file.getPath();
    path = path.replace("\\", "/");

    String[] pathArray = path.split("/");
    ArrayUtils.reverse(pathArray);

    List<IResource> result = new ArrayList<IResource>();
    List<IResource> toDo = new ArrayList<IResource>();

    toDo.add(member);

    while (!toDo.isEmpty()) {
        IResource resource = toDo.remove(0);

        if (resource instanceof IContainer) {
            for (IResource iResource : ((IContainer) resource).members()) {
                toDo.add(iResource);
            }
        }

        result.add(resource);

    }

    ResourceMatch match = new ResourceMatch();

    for (IResource iResource : result) {
        if (iResource == null) {
            continue;
        }
        if (iResource.getName().equals(name)) {
            IPath ipath = iResource.getLocation();

            String stringPath = ipath.toString();
            stringPath = stringPath.replace("\\", "/");

            String[] resourcePathArray = stringPath.split("/");
            ArrayUtils.reverse(resourcePathArray);

            int smallestSize = (pathArray.length < resourcePathArray.length) ? pathArray.length
                    : resourcePathArray.length;
            for (int i = 0; i < smallestSize; i++) {
                if (pathArray[i].equals(resourcePathArray[i])) {
                    if (i >= match.getScore()) {
                        match = new ResourceMatch(iResource, i);
                    }
                } else {
                    break;
                }

            }
        }
    }

    return match.getIResource();
}

From source file:Main.java

/**
 * Internal function to realize the mathematical combination of given
 * values. This method creates the next sub-tree by iterating over values
 * given by parameter set./*  w ww.ja  va2 s  . c  o  m*/
 * 
 * @param <E>
 *            the type of the given and returned values
 * @param list
 *            the possible values for next iteration
 * @param combination
 *            the current path of the abstract combination tree
 * @param combinations
 *            overall combinations
 */
private static <E extends Object> void combination(List<E> list, List<E> combination,
        List<List<E>> combinations) {
    for (E value : list) {
        List<E> combination_ = new LinkedList<E>();
        combination_.addAll(combination);
        combination_.add(value);
        combinations.add(combination_);

        List<E> list_ = new LinkedList<E>();
        list_.addAll(list);
        list_.remove(list);
        if (!list_.isEmpty()) {
            combination(list_, combination_, combinations);
        }
    }
}

From source file:com.ejisto.core.classloading.scan.ScanAction.java

private static void scanClass(List<MockedField> group, ClassPool classPool, ClassTransformerImpl transformer,
        String destPath) {/*ww  w . ja  v  a2s. c  o  m*/
    if (!group.isEmpty()) {
        MockedField head = group.get(0);
        log.debug("scanning " + head.getClassName());
        try {
            CtClass clazz = classPool.get(head.getClassName());
            transformer.addMissingProperties(clazz, group);
            clazz.writeFile(destPath);
        } catch (NotFoundException | CannotCompileException | IOException e) {
            log.error("got exception: " + e.toString());
            throw new ApplicationException(e);
        }
    }
}

From source file:com.kdmanalytics.toif.report.internal.util.MemberUtil.java

/**
 * find suitable resources//from w  ww. j  a va  2  s  . c  o m
 * 
 * @param member
 * @param file
 * @return
 * @throws CoreException
 */
public static IResource findMembers(IResource member, IFileGroup file) throws CoreException {
    String name = file.getName();

    String path = file.getPath();
    path = path.replace("\\", "/");

    String[] pathArray = path.split("/");
    ArrayUtils.reverse(pathArray);

    List<IResource> result = new ArrayList<IResource>();
    List<IResource> toDo = new ArrayList<IResource>();

    toDo.add(member);

    while (!toDo.isEmpty()) {
        IResource resource = toDo.remove(0);

        if (resource instanceof IContainer) {
            for (IResource iResource : ((IContainer) resource).members()) {
                toDo.add(iResource);
            }
        }

        result.add(resource);

    }

    ResourceMatch match = new ResourceMatch();

    for (IResource iResource : result) {
        if (iResource == null) {
            continue;
        }
        if (iResource.getName().equals(name)) {
            IPath ipath = iResource.getLocation();

            String stringPath = ipath.toString();
            stringPath = stringPath.replace("\\", "/");

            String[] resourcePathArray = stringPath.split("/");
            ArrayUtils.reverse(resourcePathArray);

            int smallestSize = (pathArray.length < resourcePathArray.length) ? pathArray.length
                    : resourcePathArray.length;
            for (int i = 0; i < smallestSize; i++) {
                if (pathArray[i].equals(resourcePathArray[i])) {
                    if (i >= match.getScore()) {
                        match = new ResourceMatch(iResource, i);
                        System.err.println(stringPath);
                    }
                } else {
                    break;
                }

            }
        }
    }

    return match.getIResource();
}

From source file:Main.java

private static Integer indexOfClosestZoom(Camera.Parameters parameters, double targetZoomRatio) {
    List<Integer> ratios = parameters.getZoomRatios();
    Log.i(TAG, "Zoom ratios: " + ratios);
    int maxZoom = parameters.getMaxZoom();
    if (ratios == null || ratios.isEmpty() || ratios.size() != maxZoom + 1) {
        Log.w(TAG, "Invalid zoom ratios!");
        return null;
    }/*w ww .ja v  a 2 s  . c o m*/
    double target100 = 100.0 * targetZoomRatio;
    double smallestDiff = Double.POSITIVE_INFINITY;
    int closestIndex = 0;
    for (int i = 0; i < ratios.size(); i++) {
        double diff = Math.abs(ratios.get(i) - target100);
        if (diff < smallestDiff) {
            smallestDiff = diff;
            closestIndex = i;
        }
    }
    Log.i(TAG, "Chose zoom ratio of " + (ratios.get(closestIndex) / 100.0));
    return closestIndex;
}