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.shouwy.series.web.control.admin.AdminSerieController.java

@RequestMapping(value = "/admin/series/modif/{id}", method = RequestMethod.GET)
public ModelAndView modif(@PathVariable Integer id) {

    ModelAndView model = new ModelAndView("admin/serie/modif");
    model.addObject("listType", Util.initModelHeader(typeDao));
    model.addObject("mapEtat", Util.modelMapEtat(etatDao));
    model.addObject("mapEtatPerso", Util.modelMapEtatPerso(etatPersoDao));
    model.addObject("mapType", Util.modelMapType(typeDao));

    Series s = seriesDao.getById(id);/*from   ww w  .j a  va  2  s .co  m*/
    model.addObject("serie", s);

    ArrayList<Saison> listSaison = (ArrayList<Saison>) saisonDao.getBySeries(s);
    model.addObject("saison", listSaison);

    HashMap<Integer, ArrayList<Episode>> mapEpisodeByIdSaison = new HashMap<Integer, ArrayList<Episode>>();
    if (!listSaison.isEmpty()) {
        ArrayList<Episode> listEpisode = new ArrayList<Episode>();
        listEpisode = (ArrayList<Episode>) episodeDao.getByListSaison(listSaison);
        for (Saison saison : listSaison) {
            ArrayList<Episode> episode = new ArrayList<Episode>();
            for (Episode e : listEpisode) {
                if (saison.getId().equals(e.getIdSaison())) {
                    episode.add(e);
                }
            }
            mapEpisodeByIdSaison.put(saison.getId(), episode);
        }
    }
    model.addObject("episode", mapEpisodeByIdSaison);

    return model;
}

From source file:gov.wa.wsdot.android.wsdot.ui.YouTubeFragment.java

public void onLoadFinished(Loader<ArrayList<YouTubeItem>> loader, ArrayList<YouTubeItem> data) {

    if (!data.isEmpty()) {
        mAdapter.setData(data);//from  ww w  .j a  v  a2s . com
    } else {
        TextView t = (TextView) mEmptyView;
        t.setText(R.string.no_connection);
        getListView().setEmptyView(mEmptyView);
    }

    swipeRefreshLayout.setRefreshing(false);
}

From source file:com.pindroid.syncadapter.BookmarkSyncAdapter.java

private void InsertBookmarks(Account account, SyncResult syncResult) throws AuthenticationException,
        IOException, TooManyRequestsException, ParseException, PinboardException {

    long lastUpdate = getServerSyncMarker(account);
    final String username = account.name;
    mAccount = account;//from   w  ww .  ja  va2s . c  o m

    final Update update = PinboardApi.lastUpdate(account, mContext);

    if (update.getLastUpdate() > lastUpdate) {

        Log.d(TAG, "In Bookmark Load");
        final ArrayList<String> accounts = new ArrayList<String>();
        accounts.add(account.name);

        final ArrayList<Bookmark> addBookmarkList = getBookmarkList();
        BookmarkManager.TruncateBookmarks(accounts, mContext, false);
        if (!addBookmarkList.isEmpty()) {
            List<Bookmark> unsyncedBookmarks = BookmarkManager.GetLocalBookmarks(username, mContext);
            addBookmarkList.removeAll(unsyncedBookmarks);

            BookmarkManager.BulkInsert(addBookmarkList, username, mContext);
        }

        final ArrayList<Tag> tagList = PinboardApi.getTags(account, mContext);
        TagManager.TruncateTags(username, mContext);
        if (!tagList.isEmpty()) {
            TagManager.BulkInsert(tagList, username, mContext);
        }

        SyncNotes();

        setServerSyncMarker(account, update.getLastUpdate());

        syncResult.stats.numEntries += addBookmarkList.size();
    } else {
        Log.d(TAG, "No update needed.  Last update time before last sync.");
    }
}

From source file:org.opendatakit.database.data.ColumnDefinition.java

/**
 * This must match the code in the javascript layer
 * <p>/*from ww  w . j a va  2  s .  c  o  m*/
 * See databaseUtils.markUnitOfRetention
 * <p>
 * Sweeps through the collection of ColumnDefinition objects and marks the
 * ones that exist in the actual database table.
 *
 * @param defn the map of column definitions to mark
 */
private static void markUnitOfRetention(Map<String, ColumnDefinition> defn) {
    // for all arrays, mark all descendants of the array as not-retained
    // because they are all folded up into the json representation of the array
    for (Map.Entry<String, ColumnDefinition> stringColumnDefinitionEntry : defn.entrySet()) {
        ColumnDefinition colDefn = stringColumnDefinitionEntry.getValue();
        if (!colDefn.isUnitOfRetention()) {
            // this has already been processed
            continue;
        }
        ElementType type = colDefn.getType();
        if (ElementDataType.array == type.getDataType()) {
            ArrayList<ColumnDefinition> descendantsOfArray = new ArrayList<>(colDefn.getChildren());
            ArrayList<ColumnDefinition> scratchArray = new ArrayList<>();
            while (true) {
                for (ColumnDefinition subDefn : descendantsOfArray) {
                    if (!subDefn.isUnitOfRetention()) {
                        // this has already been processed
                        continue;
                    }
                    subDefn.setNotUnitOfRetention();
                    scratchArray.addAll(subDefn.getChildren());
                }

                descendantsOfArray.clear();
                descendantsOfArray.addAll(scratchArray);
                scratchArray.clear();
                if (descendantsOfArray.isEmpty()) {
                    break;
                }
            }
        }
    }
    // and mark any non-arrays with multiple fields as not retained
    for (Map.Entry<String, ColumnDefinition> stringColumnDefinitionEntry : defn.entrySet()) {
        ColumnDefinition colDefn = stringColumnDefinitionEntry.getValue();
        if (!colDefn.isUnitOfRetention()) {
            // this has already been processed
            continue;
        }
        ElementType type = colDefn.getType();
        if (ElementDataType.array != type.getDataType()) {
            if (!colDefn.getChildren().isEmpty()) {
                colDefn.setNotUnitOfRetention();
            }
        }
    }
}

From source file:com.thoughtworks.go.domain.ConsoleStreamerTest.java

@Test
public void processesNothingWhenStartLineIsBeyondEOF() throws Exception {
    final ArrayList<String> actual = new ArrayList<>();

    ConsoleStreamer console = new ConsoleStreamer(makeConsoleFile("first", "second").toPath(), 5L);
    console.stream(new Consumer<String>() {
        @Override//from  www.  j a  va2 s  .c  om
        public void accept(String s) {
            actual.add(s);
        }
    });
    assertTrue(actual.isEmpty());
    assertEquals(0L, console.totalLinesConsumed());
}

From source file:administraScan.OrganizaDirectorios.java

public boolean clasificar() {
    String ruta = conf.carpetaRemota + "aceptados\\";
    File f = new File(ruta);
    FileUtils Files = new FileUtils();
    String ct = "";
    System.out.println(f.list());
    ArrayList<String> names = new ArrayList<>(Arrays.asList(f.list()));
    if (!names.isEmpty()) {
        for (int i = 0; i < names.size(); i++) {
            System.out.println(names.get(i));
            System.out.println("hay algo");
            ct = obtenerCT(names.get(i));
            if (ct.equals("")) {
                System.out.println("Se acab");

            } else {
                String prueba = (String) (names.get(i).toString());
                System.out.println("" + prueba);
                String rutadestino = conf.carpetaCT + "\\" + names.get(i) + "\\";
                File destino = new File(conf.carpetaCT + ct + "\\" /*+ names.get(i) + "/"*/);
                File origen = new File(ruta + names.get(i) + "\\");
                try {
                    Files.moveDirectoryToDirectory(origen, destino, true);
                    //Aqu se actualiza la variable

                } catch (IOException E) {
                    E.printStackTrace();
                }/*from  w  w w . j  a  v a  2 s .  c  om*/
            }
        }
        resultado = false;
    } else {
        JOptionPane.showMessageDialog(null, "No ningun elemento que mover");
    }
    return resultado;
}

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

@RequestMapping(value = "/get-all", method = RequestMethod.GET, produces = "application/json")
@ApiImplicitParams({ @ApiImplicitParam(name = "page", paramType = "query", defaultValue = "1"),
        @ApiImplicitParam(name = "limit", paramType = "query", defaultValue = "10"),
        @ApiImplicitParam(name = "name", paramType = "query", defaultValue = "") })
@ResponseBody/*from   w  w  w  . j a  v  a  2 s. co  m*/
public ResponseEntity<Map<String, Object>> findAll(@ApiIgnore AuctionFilter filter,
        @ApiIgnore Pagination pagination) {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        pagination.setTotalCount(usr_service.count(filter));
        ArrayList<User> auction = (ArrayList<User>) usr_service.findAll(filter, 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:at.rocworks.oa4j.logger.dbs.NoSQLMongoDB.java

@Override
public boolean dpGetPeriod(Date t1, Date t2, Dp dp, Set<String> configs, DpGetPeriodResult result) {
    // db.events.find({tag: "System1:Test_1_1.Value", ts: {$gt: ISODate("2016-07-28T09:00:00.000Z"), $lt: ISODate("2016-07-28T10:00:00.000Z")}}, {_id:0, tag:1, ts:1});
    JDebug.out.log(Level.INFO, "dpGetPeriod {0}-{1} dp={2} configs={3}",
            new Object[] { t1, t2, dp, configs.toString() });

    final SimpleDateFormat fmt = new SimpleDateFormat(TimeVar.FMT_DATE_JS_MS);
    fmt.setTimeZone(TimeZone.getTimeZone("UTC"));

    // columns/*from w  w w  .  j  av a  2 s .  c  o  m*/
    final ArrayList<Dp> dps = createDpConfigAttrList(dp, configs);
    if (dps.isEmpty()) {
        JDebug.out.warning("dpGetPeriod without any valid config.");
        return false;
    }
    Document columns = new Document();
    columns.append("_id", 0);
    columns.append("ts", 1);
    dps.forEach((Dp x) -> {
        String c = attrMap.get(x.getAttribute());
        if (c != null)
            columns.append(c, 1);
    });

    // filter
    Document query = new Document();
    query.append("tag", getTagOfDp(dp));
    query.append("ts", new Document("$gte", t1).append("$lte", t2));

    // query
    FindIterable<Document> find = evcoll.find(query);
    find.projection(columns);
    find.forEach((Block<Document>) document -> {
        // { "ts" : { "$date" : 1469696660635 }, "value" : { "number" : 3.0 }, "status" : { "$numberLong" : "-9007199254738370303" }, "user" : 0 }
        //JDebug.out.info(document.toJson());
        Date ts = document.getDate("ts");
        Object value;
        for (int i = 0; i < dps.size(); i++) {
            try {
                final Dp attr = dps.get(i);
                switch (attr.getAttribute()) {
                case Value:
                    // value_number
                    value = document.get("value");
                    if (value instanceof Document) {
                        Document dval = (Document) value;
                        dval.keySet().forEach(type -> result.addValue(attr, ts, dval.get(type)));
                    }
                    break;
                case Status:
                    value = document.get("status");
                    result.addVariable(attr, ts, new Bit32Var(value));
                    break;

                case Status64:
                    value = document.get("status");
                    result.addVariable(attr, ts, new Bit64Var(value));
                    break;
                case Manager:
                    value = document.get("manager");
                    result.addVariable(attr, ts, Variable.newVariable(value));
                    break;
                case User:
                    value = document.get("user");
                    result.addVariable(attr, ts, Variable.newVariable(value));
                    break;
                case Stime:
                    value = ts;
                    result.addVariable(attr, ts, Variable.newVariable(value));
                    break;
                default:
                    JDebug.out.log(Level.SEVERE, "unhandeled config {0}", attr.getAttribute());
                }
            } catch (Exception ex) {
                JDebug.StackTrace(Level.SEVERE, ex);
            }
        }
    });

    return true;
}

From source file:edu.arizona.kfs.fp.businessobject.lookup.UaDisbursementPayeeLookupableHelperServiceImpl.java

/**
 * @see org.kuali.kfs.fp.businessobject.lookup.DisbursementPayeeLookupableHelperServiceImpl#getPersonAsPayees(java.util.Map)
 *//*from  w  w w . ja  v a2  s . c  o  m*/
protected List<DisbursementPayee> getPersonAsPayees(Map<String, String> fieldValues) {
    List<DisbursementPayee> payeeList = new ArrayList<DisbursementPayee>();

    ArrayList<String> employeeStatusCodes = new ArrayList<String>(
            CoreFrameworkServiceLocator.getParameterService().getParameterValuesAsString(
                    DisbursementVoucherDocument.class, UaKFSConstants.ACTIVE_EMPLOYEE_STATUS_CODES_PARAM_NAME));
    if (ObjectUtils.isNull(employeeStatusCodes) || employeeStatusCodes.isEmpty()) {
        throw new RuntimeException("The ACTIVE_EMPLOYEE_STATUS_CODES parameter has no values.");
    }

    for (String statusCode : employeeStatusCodes) {
        List<DisbursementPayee> payeesByEmployeeStatusCode = this
                .getPersonAsPayeesByEmployeeStatusCode(fieldValues, statusCode);
        payeeList.addAll(payeesByEmployeeStatusCode);
    }

    return payeeList;
}

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

@RequestMapping(value = "/get-all-admin", method = RequestMethod.GET, produces = "application/json")
@ApiImplicitParams({ @ApiImplicitParam(name = "page", paramType = "query", defaultValue = "1"),
        @ApiImplicitParam(name = "limit", paramType = "query", defaultValue = "10"),
        @ApiImplicitParam(name = "name", paramType = "query", defaultValue = "") })
@ResponseBody//from ww  w.  ja  va2  s . c om
public ResponseEntity<Map<String, Object>> findAllAdmin(@ApiIgnore AuctionFilter filter,
        @ApiIgnore Pagination pagination) {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        pagination.setTotalCount(usr_service.countAdmin(filter));
        ArrayList<User> auction = (ArrayList<User>) usr_service.findAllAdmin(filter, 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);
}