Example usage for java.util ArrayList isEmpty

List of usage examples for java.util ArrayList isEmpty

Introduction

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

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:com.stv.launcher.compat.PackageInstallerCompatV16.java

private void replayUpdates() {
    if (DEBUG)/*from   w w  w. j a va2 s  .  c  o m*/
        Log.d(TAG, "updates resumed");
    LauncherState app = LauncherState.getInstanceNoCreate();
    if (app == null) {
        mReplayPending = true; // try again later
        if (DEBUG)
            Log.d(TAG, "app is null, delaying send");
        return;
    }
    mReplayPending = false;
    ArrayList<PackageInstallInfo> updates = new ArrayList<PackageInstallInfo>();
    for (String packageName : mPrefs.getAll().keySet()) {
        final String json = mPrefs.getString(packageName, null);
        if (!TextUtils.isEmpty(json)) {
            updates.add(infoFromJson(packageName, json));
        }
    }
    if (!updates.isEmpty()) {
        sendUpdate(app, updates);
    }
}

From source file:com.android.launcher3.compat.PackageInstallerCompatV16.java

private void replayUpdates() {
    if (DEBUG)/*from   ww w .  j  av  a 2  s  .c o m*/
        Log.d(TAG, "updates resumed");
    LauncherAppState app = LauncherAppState.getInstanceNoCreate();
    if (app == null) {
        mReplayPending = true; // try again later
        if (DEBUG)
            Log.d(TAG, "app is null, delaying send");
        return;
    }
    mReplayPending = false;
    ArrayList<PackageInstallInfo> updates = new ArrayList<PackageInstallInfo>();
    for (String packageName : mPrefs.getAll().keySet()) {
        final String json = mPrefs.getString(packageName, null);
        if (!TextUtils.isEmpty(json)) {
            updates.add(infoFromJson(packageName, json));
        }
    }
    if (!updates.isEmpty()) {
        sendUpdate(app, updates);
    }
}

From source file:org.khmeracademy.btb.auc.pojo.controller.Auction_controller.java

@RequestMapping(value = "/get-top-and-low-auctions", method = RequestMethod.GET, produces = "application/json")
@ResponseBody/*from  ww  w.ja  v a  2  s.  c om*/
public ResponseEntity<Map<String, Object>> getTopAndLow() {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        ArrayList<Auction_Detail> auction = auc_service.getTopAndLowAuction();
        if (!auction.isEmpty()) {
            map.put("DATA", auction);
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA FOUND!");
        } else {
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA NOT FOUND");
        }
    } catch (Exception e) {
        map.put("STATUS", false);
        map.put("MESSAGE", "Error!");
        e.printStackTrace();
    }
    return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK);
}

From source file:feedsplugin.FeedsPlugin.java

private ActionMenu getContextMenuAction(final ArrayList<SyndEntryWithParent> matches) {
    if (matches.isEmpty()) {
        return null;
    }// w  w  w  .j av  a  2 s .c om
    final ArrayList<SyndEntry> entries = new ArrayList<SyndEntry>(matches.size());
    for (SyndEntryWithParent match : matches) {
        entries.add(match.getEntry());
    }
    AbstractAction action = new AbstractAction(mLocalizer.msg("contextMenu", "Feeds {0}", matches.size()),
            getPluginIcon()) {
        public void actionPerformed(final ActionEvent e) {
            showFeedsDialog(new FeedsDialog(getParentFrame(), entries));
        }
    };
    return new ActionMenu(action);
}

From source file:org.khmeracademy.btb.auc.pojo.controller.Auction_controller.java

@RequestMapping(value = "/get", method = RequestMethod.GET, produces = "application/json")
@ResponseBody//from   w w  w.ja  va  2s. c  om
public ResponseEntity<Map<String, Object>> getAuctions(
        @RequestParam(value = "page", required = false, defaultValue = "1") int page,
        @RequestParam(value = "limit", required = false, defaultValue = "6") int limit) {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        Pagination pagination = new Pagination();
        pagination.setLimit(limit);
        pagination.setPage(page);
        pagination.setTotalCount(auc_service.countAuction());
        ArrayList<Auction_Detail> auction = auc_service.getAuctions(pagination);
        if (!auction.isEmpty()) {
            map.put("DATA", auction);
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA FOUND!");
            map.put("PAGINATION", pagination);
        } else {
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA NOT FOUND");
        }
    } catch (Exception e) {
        map.put("STATUS", false);
        map.put("MESSAGE", "Error!");
        e.printStackTrace();
    }
    return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK);
}

From source file:administraScan.OrganizaDirectorios.java

public int retornaSize() {

    int retorno = 100;
    String ruta = conf.carpetaRemota + "aceptados\\";
    File f = new File(ruta);
    ArrayList<String> names = new ArrayList<>(Arrays.asList(f.list()));
    System.out.println(names.size());
    retorno = names.size();//from ww w. j  a  va  2  s  .c o  m
    System.out.println(names.size());
    if (!names.isEmpty()) {
        System.out.println("Ya no hay nada");
    }

    return retorno;
}

From source file:com.fitbur.testify.system.SpringSystemTest.java

public ClientContext getClientContext(TestContext testContext, ServerContext serverContext) {
    return testContext.getAnnotation(App.class).map(app -> {
        SpringSystemClientDescriptor descriptor = new SpringSystemClientDescriptor(app, testContext,
                serverContext.getInstance().getURI());

        ServiceLoader<ClientProvider> clientProviderLoader = ServiceLoader.load(ClientProvider.class);
        ArrayList<ClientProvider> clientProviders = Lists.newArrayList(clientProviderLoader);

        checkState(!clientProviders.isEmpty(),
                "ClientProvider provider implementation not found in the classpath");

        checkState(clientProviders.size() == 1,
                "Multiple ClientProvider provider implementations found in the classpath. "
                        + "Please insure there is only one ClientProvider provider implementations "
                        + "in the classpath.");

        ClientProvider clientProvider = clientProviders.get(0);
        Object configuration = clientProvider.configuration(descriptor);

        testContext.getConfigMethod(configuration.getClass()).map(m -> m.getMethod()).ifPresent(m -> {
            AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
                try {
                    m.setAccessible(true);
                    m.invoke(testContext.getTestInstance(), configuration);
                } catch (Exception e) {
                    checkState(false, "Call to config method '%s' in test class '%s' failed due to: ",
                            m.getName(), descriptor.getTestClassName(), e.getMessage());
                }//  w w w .j a  v a 2  s .c om

                return null;
            });
        });

        ClientInstance instance = clientProvider.init(descriptor, configuration);
        ServiceLocator serviceLocator = serverContext.getLocator();
        ClientContext context = new ClientContext(clientProvider, descriptor, instance, configuration);

        serviceLocator.addConstant(context.getClass().getSimpleName(), context);
        serviceLocator.addConstant(instance.getClass().getSimpleName(), instance);

        return context;

    }).get();
}

From source file:com.iggroup.oss.sample.web.controller.BaseController.java

/**
 * Validate the given object using the configured validator, throwing a
 * BusinessException if the object fails validation
 * // ww w .j a  v  a 2 s  . c o  m
 * @param o the object to be validated
 */
protected void validate(Object o) {

    ArrayList<SampleError> errors = new ArrayList<SampleError>();
    for (ConstraintViolation<Object> violation : globalValidator.validate(o)) {

        errors.add(new ValidationError(violation.getLeafBean().getClass().getSimpleName(),
                violation.getPropertyPath().toString(), violation.getInvalidValue().toString(),
                violation.getRootBeanClass().getSimpleName()));
    }
    if (!errors.isEmpty()) {
        LOGGER.debug(errors);
        throw new SampleException(errors, HttpStatus.BAD_REQUEST);
    }

}

From source file:com.clustercontrol.maintenance.factory.MaintenanceCollectStringData.java

/**
 * ?//  ww w  .  jav a  2 s  .  c  o  m
 */
@Override
protected int _delete(Long boundary, boolean status, String ownerRoleId) {
    int ret = 0;
    JpaTransactionManager jtm = null;

    try {
        //AdminRole???ID??????
        if (RoleIdConstant.isAdministratorRole(ownerRoleId)) {
            jtm = new JpaTransactionManager();
            jtm.begin();
            ret = delete(boundary, status);
            jtm.commit();

        } else {
            ArrayList<MonitorInfo> monitorList = new MonitorSettingControllerBean().getMonitorList();

            ArrayList<String> monitorIdList = new ArrayList<>();

            for (MonitorInfo monitorInfo : monitorList) {
                if (RoleIdConstant.isAdministratorRole(ownerRoleId)
                        || monitorInfo.getOwnerRoleId().equals(ownerRoleId)) {
                    monitorIdList.add(monitorInfo.getMonitorId());
                }
            }
            if (monitorIdList.isEmpty()) {
                return -1;
            }
            jtm = new JpaTransactionManager();
            jtm.begin();

            for (int i = 0; i < monitorIdList.size(); i++) {
                ret += delete(boundary, status, monitorIdList.get(i));
                jtm.commit();
            }
        }
    } catch (Exception e) {
        m_log.warn("deleteCollectData() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
        if (jtm != null)
            jtm.rollback();
    } finally {
        if (jtm != null)
            jtm.close();
    }
    return ret;
}

From source file:com.clustercontrol.maintenance.factory.MaintenanceSummaryHour.java

/**
 * ?//from w  w  w . ja  va2 s. co m
 */
@Override
protected int _delete(Long boundary, boolean status, String ownerRoleId) {
    int ret = 0;
    JpaTransactionManager jtm = null;
    try {
        //AdminRole???ID??????
        if (RoleIdConstant.isAdministratorRole(ownerRoleId)) {
            jtm = new JpaTransactionManager();
            jtm.begin();
            ret = delete(boundary, status);
            jtm.commit();

        } else {
            ArrayList<MonitorInfo> monitorList = new MonitorSettingControllerBean().getMonitorList();

            ArrayList<String> monitorIdList = new ArrayList<>();

            for (MonitorInfo monitorInfo : monitorList) {
                if (RoleIdConstant.isAdministratorRole(ownerRoleId)
                        || monitorInfo.getOwnerRoleId().equals(ownerRoleId)) {
                    monitorIdList.add(monitorInfo.getMonitorId());
                }
            }
            if (monitorIdList.isEmpty()) {
                return -1;
            }
            jtm = new JpaTransactionManager();
            jtm.begin();

            for (int i = 0; i < monitorIdList.size(); i++) {
                ret += delete(boundary, status, monitorIdList.get(i));
                jtm.commit();
            }
        }
    } catch (Exception e) {
        m_log.warn("deleteCollectData() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
        if (jtm != null)
            jtm.rollback();
    } finally {
        if (jtm != null)
            jtm.close();
    }
    return ret;
}