List of usage examples for java.util Iterator remove
default void remove()
From source file:com.evolveum.midpoint.schema.util.AdminGuiConfigTypeUtil.java
private static void joinObjectDetails(GuiObjectDetailsSetType objectDetailsSet, GuiObjectDetailsPageType newObjectDetails) { Iterator<GuiObjectDetailsPageType> iterator = objectDetailsSet.getObjectDetailsPage().iterator(); while (iterator.hasNext()) { GuiObjectDetailsPageType currentDetails = iterator.next(); if (isTheSameObjectType(currentDetails, newObjectDetails)) { iterator.remove(); }//from ww w. j a v a 2 s .c o m } objectDetailsSet.getObjectDetailsPage().add(newObjectDetails.clone()); }
From source file:com.aurel.track.item.consInf.ConsInfBL.java
/** * Deletes those elements from list/*from w w w .ja va2s .c om*/ * which correspond to elements of values array * @param personBeans * @param values * @return */ public static void deleteSelected(List<TPersonBean> personBeans, Integer[] values) { if (personBeans == null || values == null || values.length == 0) { return; } Set<Integer> valuesSet = new HashSet<Integer>(); for (int i = 0; i < values.length; i++) { valuesSet.add(values[i]); } Iterator<TPersonBean> iterator = personBeans.iterator(); while (iterator.hasNext()) { TPersonBean personBean = iterator.next(); if (valuesSet.contains(personBean.getObjectID())) { iterator.remove(); } } }
From source file:com.blackducksoftware.integration.jira.task.JiraSettingsService.java
public static List<TicketCreationError> expireOldErrors(final PluginSettings pluginSettings) { logger.debug("Pulling error messages from settings"); final Object errorObject = pluginSettings.get(HubJiraConstants.HUB_JIRA_ERROR); if (errorObject == null) { logger.debug("No error messages found in settings"); return null; }//from w ww .j a v a 2s . c om if (!(errorObject instanceof String)) { logger.warn( "The error object in settings is invalid (probably stored by an older version of the plugin); discarding it"); pluginSettings.remove(HubJiraConstants.HUB_JIRA_ERROR); return null; } List<TicketCreationError> ticketErrors = null; final String ticketErrorsString = (String) errorObject; try { ticketErrors = TicketCreationError.fromJson(ticketErrorsString); } catch (final Exception e) { logger.warn("Error deserializing JSON string pulled from settings: " + e.getMessage() + "; resettting error message list"); pluginSettings.remove(HubJiraConstants.HUB_JIRA_ERROR); return null; } if ((ticketErrors == null) || ticketErrors.isEmpty()) { logger.debug("No error messages found in settings"); return null; } logger.debug("# error messages pulled from settings: " + ticketErrors.size()); Collections.sort(ticketErrors); final DateTime currentTime = DateTime.now(); final Iterator<TicketCreationError> expirationIterator = ticketErrors.iterator(); while (expirationIterator.hasNext()) { final TicketCreationError ticketError = expirationIterator.next(); final DateTime errorTime = ticketError.getTimeStampDateTime(); if (Days.daysBetween(errorTime, currentTime).isGreaterThan(Days.days(30))) { logger.debug("Removing old error message with timestamp: " + ticketError.getTimeStamp()); expirationIterator.remove(); } } logger.debug("Saving " + ticketErrors.size() + " non-expired error messages in settings"); pluginSettings.put(HubJiraConstants.HUB_JIRA_ERROR, TicketCreationError.toJson(ticketErrors)); return ticketErrors; }
From source file:Main.java
/** * Returns reusable bitmap, if exists//from w ww .j a va 2 s.com * * @param options Options to look against * @return reusable bitmap, if exists */ @Nullable private static Bitmap getBitmapFromReusableSet(@NonNull final BitmapFactory.Options options) { Bitmap bitmap = null; if (sReusableBitmaps != null && sReusableBitmaps.isEmpty()) { synchronized (sReusableBitmaps) { final Iterator<SoftReference<Bitmap>> iterator = sReusableBitmaps.iterator(); Bitmap item; while (iterator.hasNext()) { item = iterator.next().get(); if (item != null && item.isMutable()) { // Check to see it the item can be used for inBitmap. if (canUseForInBitmap(item, options)) { bitmap = item; // Remove from reusable set so it can't be used again. iterator.remove(); break; } } else { // Remove from the set if the reference has been cleared. iterator.remove(); } } } } return bitmap; }
From source file:com.all.shared.json.JsonConverter.java
@SuppressWarnings("unchecked") private static <T> T cleanAndConvert(JSONObject jsonObject, Class<T> clazz) { try {/* ww w. j a v a 2 s . c o m*/ Iterator<String> keys = jsonObject.keys(); T instance = clazz.newInstance(); while (keys.hasNext()) { String key = keys.next(); if (!PropertyUtils.isWriteable(instance, key)) { keys.remove(); } } return (T) JSONObject.toBean(jsonObject, clazz); } catch (Exception e) { throw new IllegalArgumentException("Could not convert from json to bean of type " + clazz.getName(), e); } }
From source file:com.clustercontrol.agent.log.LogfileMonitorManager.java
private static void refresh() { synchronized (LogfileMonitorManager.class) { log.debug("refresh() : start"); List<MonitorInfoWrapper> monitorList = popMonitorInfoList(); // ??????????????? if (monitorList != null) { log.debug("refresh() : m_monitorList.size=" + monitorList.size()); // ???? if (statusRoot == null) { statusRoot = new ReadingStatusRoot(monitorList, getReadingStatesStorePath()); log.debug("refresh() : ReadingStatusRoot is initialized."); } else { statusRoot.update(monitorList); log.debug("refresh() : ReadingStatusRoot is updated."); }//from w w w . j ava2 s . c om } else { // ??? if (statusRoot != null) statusRoot.update(); } if (statusRoot == null) { log.debug("refresh() : ReadingStatusRoot is not initialized."); return; } log.debug("refresh() : monitoring files."); Set<String> newLogfileMonitorCacheKeySet = new HashSet<String>(); for (ReadingStatusDir miDir : statusRoot.getReadingStatusDirList()) { MonitorInfoWrapper wrapper = miDir.getMonitorInfo(); String monitorId = wrapper.monitorInfo.getMonitorId(); String directoryPath = wrapper.monitorInfo.getLogfileCheckInfo().getDirectory(); String fileNamePattern = wrapper.monitorInfo.getLogfileCheckInfo().getFileName(); String fileEncoding = wrapper.monitorInfo.getLogfileCheckInfo().getFileEncoding(); String fileReturnCode = wrapper.monitorInfo.getLogfileCheckInfo().getFileReturnCode(); log.debug("refresh() : monitorId=" + monitorId + ", directory=" + directoryPath + ", filenamePattern=" + fileNamePattern + ", fileEncoding=" + fileEncoding + ", fileReturnCode=" + fileReturnCode); for (ReadingStatus status : miDir.list()) { log.debug("refresh() : filePath=" + status.filePath.getPath()); String cacheKey = monitorId + status.rsFilePath.getPath(); LogfileMonitor logfileMonitor = logfileMonitorCache.get(cacheKey); if (logfileMonitor == null) { // ? logfileMonitor = new LogfileMonitor(wrapper, status); logfileMonitorCache.put(cacheKey, logfileMonitor); log.debug("refresh() : LogfileMonitor is created."); } else { log.debug("refresh() : LogfileMonitor is being cached."); } logfileMonitor.setMonitor(wrapper); newLogfileMonitorCacheKeySet.add(cacheKey); } } /* * ?????logfileMonitor???? */ Iterator<Entry<String, LogfileMonitor>> it = logfileMonitorCache.entrySet().iterator(); while (it.hasNext()) { Entry<String, LogfileMonitor> entry = it.next(); if (!newLogfileMonitorCacheKeySet.contains(entry.getKey())) { entry.getValue().clean(); it.remove(); } } } }
From source file:de.undercouch.citeproc.TestSuiteRunner.java
/** * Reads a compiled test file (.json)//from w w w.j av a 2 s .c o m * @param f the test file * @return the configuration read from the file * @throws IOException if the file could not be read */ private static Map<String, Object> readFile(File f) throws IOException { FileInputStream fis = new FileInputStream(f); try { JsonLexer jsonLexer = new JsonLexer(new InputStreamReader(fis, "UTF-8")); JsonParser jsonParser = new JsonParser(jsonLexer); Map<String, Object> m = jsonParser.parseObject(); //remove items whose value is 'false' Iterator<Map.Entry<String, Object>> i = m.entrySet().iterator(); while (i.hasNext()) { Map.Entry<String, Object> e = i.next(); if (e.getValue() instanceof Boolean && !((Boolean) e.getValue()).booleanValue()) { i.remove(); } } return m; } finally { fis.close(); } }
From source file:com.evolveum.midpoint.util.MiscUtil.java
/** * Only zero vs non-zero value of comparator is important. *///from w w w . j av a2 s.c o m public static <T> boolean unorderedArrayEquals(T[] a, T[] b, Comparator<T> comparator) { if (a == null && b == null) { return true; } if (a == null || b == null) { return false; } if (a.length != b.length) { return false; } List<T> outstanding = Arrays.asList(b); for (T ao : a) { boolean found = false; Iterator<T> iterator = outstanding.iterator(); while (iterator.hasNext()) { T oo = iterator.next(); if (comparator.compare(ao, oo) == 0) { iterator.remove(); found = true; } } if (!found) { return false; } } if (!outstanding.isEmpty()) { return false; } return true; }
From source file:fr.lirmm.graphik.graal.io.owl.OWL2Parser.java
private static InMemoryAtomSet removeUselessTopInBody(InMemoryAtomSet atomset) { InMemoryAtomSet newAtomset = new DefaultInMemoryGraphAtomSet(); Iterator<Atom> it = atomset.iterator(); Atom a;//from ww w.j a v a 2 s. co m while (it.hasNext()) { a = it.next(); if (!a.getPredicate().equals(Predicate.TOP)) { newAtomset.add(a); it.remove(); } else { } } // for each top predicate Set<Term> terms = newAtomset.getTerms(); it = atomset.iterator(); while (it.hasNext()) { a = it.next(); if (!terms.contains(a.getTerm(0))) { newAtomset.add(a); } } return newAtomset; }
From source file:com.evolveum.midpoint.util.MiscUtil.java
/** * Only zero vs non-zero value of comparator is important. */// w w w . j a v a2s.co m public static boolean unorderedCollectionEquals(Collection a, Collection b, Comparator comparator) { if (a == null && b == null) { return true; } if (a == null || b == null) { return false; } if (a.size() != b.size()) { return false; } Collection outstanding = new ArrayList(b.size()); outstanding.addAll(b); for (Object ao : a) { boolean found = false; Iterator iterator = outstanding.iterator(); while (iterator.hasNext()) { Object oo = iterator.next(); if (comparator.compare(ao, oo) == 0) { iterator.remove(); found = true; } } if (!found) { return false; } } if (!outstanding.isEmpty()) { return false; } return true; }