List of usage examples for java.util ArrayList isEmpty
public boolean isEmpty()
From source file:org.mythtv.service.guide.v27.ProgramGuideHelperV27.java
private static int load(final Context context, final LocationProfile locationProfile, final ProgramGuide programGuide) throws RemoteException, OperationApplicationException { Log.d(TAG, "load : enter"); if (null == context) throw new RuntimeException("ProgramGuideHelperV27 is not initialized"); String tag = UUID.randomUUID().toString(); int processed = -1; int count = 0; ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); for (ChannelInfo channel : programGuide.getChannels()) { for (Program program : channel.getPrograms()) { //Log.i( TAG, "load : count=" + count ); program.setChannel(channel); program.setHostName(locationProfile.getHostname()); ProgramHelperV27.getInstance().processProgram(context, locationProfile, ProgramConstants.CONTENT_URI_GUIDE, ProgramConstants.TABLE_NAME_GUIDE, ops, program, tag); count++;//w w w . j a v a2 s .c o m if (count > BATCH_COUNT_LIMIT) { // Log.i( TAG, "load : applying batch for '" + count + "' transactions, processing programs" ); processBatch(context, ops, processed, count); count = 0; } } } if (!ops.isEmpty()) { // Log.i( TAG, "load : applying final batch for '" + count + "' transactions, processing programs" ); processBatch(context, ops, processed, count); } // Log.v( TAG, "load : exit" ); return processed; }
From source file:org.khmeracademy.btb.auc.pojo.controller.Brand_controller.java
@RequestMapping(value = "/get", method = RequestMethod.GET, produces = "application/json") @ResponseBody//from w ww .jav a2 s. c o m public ResponseEntity<Map<String, Object>> getProductBrands() { Map<String, Object> map = new HashMap<String, Object>(); try { ArrayList<Brand> brand = bra_service.getProductBrand(); if (!brand.isEmpty()) { map.put("DATA", brand); 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:edu.oregonstate.eecs.mcplan.domains.voyager.policies.KillPolicy.java
@Override public VoyagerAction getAction() { final ArrayList<Planet> friendly = Voyager.playerPlanets(s_, self_); final ArrayList<Planet> enemy = Voyager.playerPlanets(s_, self_.enemy()); if (enemy.isEmpty()) { return new NothingAction(); }//from www . j a v a 2s. c o m Planet target = null; double weight = 0; for (final Planet t : enemy) { final double tw = targetWeight(t, friendly); if (tw > weight) { weight = tw; target = t; } } if (target == null) { return new NothingAction(); } while (friendly.size() > 0) { Planet src = null; double dist = Double.MAX_VALUE; for (final Planet s : friendly) { final double sd = Voyager.distance(s, target); if (sd < dist) { dist = sd; src = s; } } if (src != null) { final int spare_soldiers = src.population(Unit.Soldier) - garrison_; if (spare_soldiers > 0) { final int[] pop = new int[Unit.values().length]; pop[Unit.Soldier.ordinal()] = spare_soldiers; return new LaunchAction(src, target, pop); } else { friendly.remove(src); } } } return new NothingAction(); }
From source file:org.khmeracademy.btb.auc.pojo.controller.Brand_controller.java
@RequestMapping(value = "/get-number-auction-in-brand", method = RequestMethod.GET, produces = "application/json") @ResponseBody/*from www.ja va 2 s . c om*/ public ResponseEntity<Map<String, Object>> getNumberAuctionInBrand() { Map<String, Object> map = new HashMap<String, Object>(); try { ArrayList<Brand> brand = bra_service.getNumberOfAuctionInBrand(); if (!brand.isEmpty()) { map.put("DATA", brand); 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:com.ibm.bi.dml.parser.StatementBlock.java
public static ArrayList<StatementBlock> mergeStatementBlocks(ArrayList<StatementBlock> sb) { ArrayList<StatementBlock> result = new ArrayList<StatementBlock>(); if (sb == null || sb.isEmpty()) { return new ArrayList<StatementBlock>(); }/*from w ww.j a v a 2 s . c om*/ StatementBlock currentBlock = null; for (int i = 0; i < sb.size(); i++) { StatementBlock current = sb.get(i); if (current.mergeable()) { if (currentBlock != null) { currentBlock.addStatementBlock(current); } else { currentBlock = current; } } else { if (currentBlock != null) { result.add(currentBlock); } result.add(current); currentBlock = null; } } if (currentBlock != null) { result.add(currentBlock); } return result; }
From source file:org.khmeracademy.btb.auc.pojo.controller.Product_Controller.java
@RequestMapping(value = "/get", method = RequestMethod.GET, produces = "application/json") @ResponseBody/* ww w .ja v a 2 s .co m*/ public ResponseEntity<Map<String, Object>> getUsers() { Map<String, Object> map = new HashMap<String, Object>(); try { ArrayList<Product> pro = pro_service.getProduct(); if (!pro.isEmpty()) { map.put("DATA", pro); 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:org.khmeracademy.btb.auc.pojo.controller.Category_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/* www . ja v a 2 s . c o m*/ public ResponseEntity<Map<String, Object>> findAll(@ApiIgnore AuctionFilter filter, @ApiIgnore Pagination pagination) { Map<String, Object> map = new HashMap<String, Object>(); try { pagination.setTotalCount(cate_service.count(filter)); ArrayList<Category> auction = (ArrayList<Category>) cate_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:com.cloudera.impala.analysis.DescribeTableStmt.java
public DescribeTableStmt(ArrayList<String> rawPath, TDescribeOutputStyle outputStyle) { Preconditions.checkNotNull(rawPath); Preconditions.checkArgument(!rawPath.isEmpty()); rawPath_ = rawPath;//from w ww . j a va 2s. c om outputStyle_ = outputStyle; path_ = null; tableName_ = null; resultStruct_ = null; }
From source file:com.salsaberries.narchiver.HttpMessage.java
/** * Converts a list of cookies into a list of appropriate headers of the form * "Cookie: [Cookie text]"./* www .j a va2s .c o m*/ * * @param cookies The cookies to convert. */ public void addCookieHeaders(ArrayList<Cookie> cookies) { if (cookies.isEmpty()) { return; } String add = cookies.get(0).toString(); for (int i = 1; i < cookies.size(); ++i) { add = add + "; " + cookies.get(i).toString(); } headers.add(new Header("Cookie", add)); }
From source file:com.adobe.cq.wcm.core.components.internal.models.v2.PageImpl.java
@PostConstruct protected void initModel() { super.initModel(); String resourcesClientLibrary = currentStyle.get(PN_APP_RESOURCES_CLIENTLIB, String.class); if (resourcesClientLibrary != null) { Collection<ClientLibrary> clientLibraries = htmlLibraryManager .getLibraries(new String[] { resourcesClientLibrary }, LibraryType.CSS, true, true); ArrayList<ClientLibrary> clientLibraryList = Lists.newArrayList(clientLibraries.iterator()); if (!clientLibraryList.isEmpty()) { appResourcesPath = getProxyPath(clientLibraryList.get(0)); }/* w ww . j a v a2 s. co m*/ } populateClientLibCategoriesJs(); setRedirect(); }