List of usage examples for java.util List clear
void clear();
From source file:android.databinding.tool.store.SetterStore.java
private static <K, V> void removeFromMap(Map<K, V> map, List<K> keys) { for (K key : keys) { map.remove(key);/*from w ww . j ava 2 s .com*/ } keys.clear(); }
From source file:com.opengamma.analytics.financial.interestrate.annuity.derivative.Annuity.java
/** * Create a new annuity with the payments of the original one paying strictly after the given time. * @param trimTime The time.// ww w. ja v a 2s .c om * @return The trimmed annuity. */ @SuppressWarnings("unchecked") public Annuity<P> trimBefore(final double trimTime) { final List<P> list = new ArrayList<>(); list.clear(); for (final P payment : _payments) { if (payment.getPaymentTime() > trimTime) { list.add(payment); } } return new Annuity<>(list.toArray((P[]) new Payment[list.size()])); }
From source file:gov.nih.nci.cabig.caaers.web.rule.notification.NotificationsTab.java
@Override public void onBind(HttpServletRequest request, ReportDefinitionCommand cmd, Errors errors) { super.onBind(request, cmd, errors); int size = cmd.getEmailNotifications().size(); for (int i = 0; i < size; i++) { String[] roleRecipients = request .getParameterValues("emailNotifications[" + i + "].roleBasedRecipients"); String[] contactRecipients = request .getParameterValues("emailNotifications[" + i + "].contactMechanismBasedRecipients"); PlannedNotification plannedNotification = cmd.getEmailNotifications().get(i); List<Recipient> recipients = plannedNotification.getRecipients(); recipients.clear(); if (roleRecipients != null) { for (String r : roleRecipients) { Recipient roleRecipient = new RoleBasedRecipient(r); if (!recipients.contains(roleRecipient)) plannedNotification.addRecipient(roleRecipient); }/* w w w . j a va2 s. c o m*/ } if (contactRecipients != null) { for (String r : contactRecipients) { Recipient cRecipient = new ContactMechanismBasedRecipient(r); if (!recipients.contains(cRecipient)) plannedNotification.addRecipient(cRecipient); } } } }
From source file:com.beetle.framework.util.ObjectUtil.java
public final static Map<String, Object> describe(Object target) { Map<String, Object> retMap = new HashMap<String, Object>(); List<String> retList = new LinkedList<String>(); Method[] methods = (Method[]) cache.get(target.getClass()); if (methods == null) { methods = target.getClass().getMethods(); cache.put(target.getClass(), methods); }/*from w w w . jav a2s.c om*/ for (int i = 0; i < methods.length; i++) { String method = methods[i].getName(); if (method.indexOf("set") == 0 || method.indexOf("get") == 0) { retList.add(method.substring(3, method.length())); } else if (method.indexOf("is") == 0) { retList.add(method.substring(2, method.length())); } } Collections.sort(retList); Object[] props = retList.toArray(); retList.clear(); for (int i = 0; i < props.length - 1; i++) { if (props[i].equals(props[i + 1])) { String prop = decapitalize(props[i].toString()); retMap.put(prop, getValue(prop, target)); } } retList = null; return retMap; }
From source file:com.hippo.ehviewer.client.EhEngine.java
public static List<GalleryInfo> fillGalleryListByApi(@Nullable EhClient.Task task, OkHttpClient okHttpClient, List<GalleryInfo> galleryInfoList) throws Exception { // We can only request 25 items one time at most final int MAX_REQUEST_SIZE = 25; List<GalleryInfo> requestItems = new ArrayList<>(MAX_REQUEST_SIZE); for (int i = 0, size = galleryInfoList.size(); i < size; i++) { requestItems.add(galleryInfoList.get(i)); if (requestItems.size() == MAX_REQUEST_SIZE || i == size - 1) { doFillGalleryListByApi(task, okHttpClient, requestItems); requestItems.clear(); }/*ww w . j a v a 2 s. c o m*/ } return galleryInfoList; }
From source file:com.precioustech.fxtrading.utils.TradingUtilsTest.java
@Test public void isEmptyTest() { List<String> nameColl = Lists.newArrayList("foo", "bar"); assertFalse(TradingUtils.isEmpty(nameColl)); nameColl.clear(); assertTrue(TradingUtils.isEmpty(nameColl)); nameColl = null;//www .j av a 2s .com assertTrue(TradingUtils.isEmpty(nameColl)); Map<Integer, String> idNameMap = Maps.newHashMap(); idNameMap.put(1, "foobar"); assertFalse(TradingUtils.isEmpty(idNameMap)); idNameMap.remove(1); assertTrue(TradingUtils.isEmpty(idNameMap)); idNameMap = null; assertTrue(TradingUtils.isEmpty(idNameMap)); }
From source file:com.epam.ta.reportportal.core.configs.MvcConfig.java
@Override public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { argumentResolvers.clear(); PagingHandlerMethodArgumentResolver pageableResolver = new PagingHandlerMethodArgumentResolver( sortArgumentResolver());/*www . j a va 2 s. co m*/ pageableResolver.setPrefix("page."); pageableResolver.setOneIndexedParameters(true); argumentResolvers.add(pageableResolver); argumentResolvers.add(new ActiveUserWebArgumentResolver()); argumentResolvers.add(new FilterCriteriaResolver()); }
From source file:org.broadleafcommerce.admin.catalog.service.AdminCatalogService.java
private void addAllCategories(List<Category> categories, List<Category> newCategories) { categories.clear(); for (Category category : newCategories) { categories.add(category);// w ww . j a v a 2 s.co m } }
From source file:uk.ac.ebi.ep.parser.parsers.EnzymePortalPDBeParser.java
public void updatePDBeData() { Set<UniprotXref> entries = new HashSet<>(); List<UniprotXref> pdbIds = parserService.findPDBcodes(); LOGGER.info("Number of PDB entries to process : " + pdbIds.size()); //int est = pdbIds.size()/500; Stream<UniprotXref> existingStream = pdbIds.stream(); Stream<List<UniprotXref>> partitioned = partition(existingStream, 500, 1); AtomicInteger count = new AtomicInteger(1); partitioned.parallel().forEach((chunk) -> { chunk.stream().forEach((pdb) -> { //obtain a concrete pdb entry PdbSearchResult results = pdbService.getPdbSearchResults(pdb.getSourceId().toLowerCase()); if (results != null) { List<PDBe> result = results.get(pdb.getSourceId().toLowerCase()); String title = result.stream().findAny().get().getTitle(); pdb.setSourceName(title); entries.add(pdb);// w w w . j a va 2 s .co m } }); }); // AtomicInteger count = new AtomicInteger(1); // pdbIds.stream().forEach((pdb) -> { // //obtain a concrete pdb entry // PdbSearchResult results = pdbService.getPdbSearchResults(pdb.getSourceId().toLowerCase()); // // System.out.println("count "+count.getAndIncrement() +" PDB id "+ pdb.getSourceId()); // if (results != null) { // List<PDBe> result = results.get(pdb.getSourceId().toLowerCase()); // String title = result.stream().findAny().get().getTitle(); // pdb.setSourceName(title); // entries.add(pdb); // } // }); //update entry List<UniprotXref> pdbEntries = entries.stream().collect(Collectors.toList()); List<UniprotXref> updatedEntries = parserService.updatePDB(pdbEntries); LOGGER.info("Number of PDB entries updated are : " + updatedEntries.size()); updatedEntries.clear(); }
From source file:com.projity.grouping.core.transform.sorting.NodeSorter.java
public void recycleList(List list) { try {//from ww w . j a va 2s .c o m list.clear(); pool.returnObject(list); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }