List of usage examples for java.util Collection remove
boolean remove(Object o);
From source file:Main.java
public static boolean removeAll(final Collection<? super Character> c, final char[] array, final int off, final int len) { final int end = off + len; boolean result = false; for (int i = off; i < end; i++) { result |= c.remove(array[i]); }/* w w w . j av a 2 s .c om*/ return result; }
From source file:org.openmrs.module.webservices.rest.resource.BaseRestDataResource.java
/** * Syncs the base collection with the items in the sync collection. This will add any missing items, updating existing * items, and delete any items not found in the sync collection. * @param base The collection to update. * @param sync The collection used to update the base. * @param <E> The {@link OpenmrsObject} stored in the collection. *//*w w w . j a va 2 s .c om*/ public static <E extends OpenmrsObject> void syncCollection(Collection<E> base, Collection<E> sync) { syncCollection(base, sync, new Action2<Collection<E>, E>() { @Override public void apply(Collection<E> collection, E entity) { collection.add(entity); } }, new Action2<Collection<E>, E>() { @Override public void apply(Collection<E> collection, E entity) { collection.remove(entity); } }); }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.gep.ListMasterDegreeStudents.java
@Atomic public static Collection run(String executionYearName) { final ExecutionYear executionYear = ExecutionYear.readExecutionYearByName(executionYearName); final Collection<InfoStudentCurricularPlanWithFirstTimeEnrolment> infoStudentCurricularPlans = new ArrayList(); final Collection<StudentCurricularPlan> studentCurricularPlans = new ArrayList(); final Collection<DegreeCurricularPlan> masterDegreeCurricularPlans = DegreeCurricularPlan .readByDegreeTypeAndState(DegreeType.MASTER_DEGREE, DegreeCurricularPlanState.ACTIVE); CollectionUtils.filter(masterDegreeCurricularPlans, new Predicate() { @Override/* w ww.j a v a 2s . co m*/ public boolean evaluate(Object arg0) { DegreeCurricularPlan degreeCurricularPlan = (DegreeCurricularPlan) arg0; for (ExecutionDegree executionDegree : degreeCurricularPlan.getExecutionDegreesSet()) { if (executionDegree.getExecutionYear().equals(executionYear)) { return true; } } return false; } }); for (DegreeCurricularPlan degreeCurricularPlan : masterDegreeCurricularPlans) { studentCurricularPlans.addAll(degreeCurricularPlan.getStudentCurricularPlansSet()); } for (StudentCurricularPlan studentCurricularPlan : studentCurricularPlans) { if (!studentCurricularPlan.isActive()) { continue; } boolean firstTimeEnrolment = true; if (studentCurricularPlan.getSpecialization() != null && studentCurricularPlan.getSpecialization() .equals(Specialization.STUDENT_CURRICULAR_PLAN_MASTER_DEGREE)) { Collection<StudentCurricularPlan> previousStudentCurricularPlans = studentCurricularPlan .getRegistration().getStudentCurricularPlansBySpecialization( Specialization.STUDENT_CURRICULAR_PLAN_MASTER_DEGREE); previousStudentCurricularPlans.remove(studentCurricularPlan); for (StudentCurricularPlan previousStudentCurricularPlan : previousStudentCurricularPlans) { if (previousStudentCurricularPlan.getDegreeCurricularPlan().getDegree() .equals(studentCurricularPlan.getDegreeCurricularPlan().getDegree())) { firstTimeEnrolment = false; break; } } } else if (studentCurricularPlan.getSpecialization() != null && studentCurricularPlan .getSpecialization().equals(Specialization.STUDENT_CURRICULAR_PLAN_SPECIALIZATION)) { if (!studentCurricularPlan.getDegreeCurricularPlan().getFirstExecutionDegree().getExecutionYear() .equals(executionYear)) { continue; } } if (firstTimeEnrolment) { if (!studentCurricularPlan.getDegreeCurricularPlan().getFirstExecutionDegree().getExecutionYear() .equals(executionYear)) { firstTimeEnrolment = false; } } InfoStudentCurricularPlanWithFirstTimeEnrolment infoStudentCurricularPlan = InfoStudentCurricularPlanWithFirstTimeEnrolment .newInfoFromDomain(studentCurricularPlan); infoStudentCurricularPlan.setFirstTimeEnrolment(firstTimeEnrolment); infoStudentCurricularPlans.add(infoStudentCurricularPlan); } return infoStudentCurricularPlans; }
From source file:org.fenixedu.academic.service.services.gep.ListMasterDegreeStudents.java
@Atomic public static Collection run(String executionYearName) { final ExecutionYear executionYear = ExecutionYear.readExecutionYearByName(executionYearName); final Collection<InfoStudentCurricularPlanWithFirstTimeEnrolment> infoStudentCurricularPlans = new ArrayList(); final Collection<StudentCurricularPlan> studentCurricularPlans = new ArrayList(); final Collection<DegreeCurricularPlan> masterDegreeCurricularPlans = readByDegreeTypeAndState(); CollectionUtils.filter(masterDegreeCurricularPlans, new Predicate() { @Override//from w w w .j a v a 2 s.c o m public boolean evaluate(Object arg0) { DegreeCurricularPlan degreeCurricularPlan = (DegreeCurricularPlan) arg0; for (ExecutionDegree executionDegree : degreeCurricularPlan.getExecutionDegreesSet()) { if (executionDegree.getExecutionYear().equals(executionYear)) { return true; } } return false; } }); for (DegreeCurricularPlan degreeCurricularPlan : masterDegreeCurricularPlans) { studentCurricularPlans.addAll(degreeCurricularPlan.getStudentCurricularPlansSet()); } for (StudentCurricularPlan studentCurricularPlan : studentCurricularPlans) { if (!studentCurricularPlan.isActive()) { continue; } boolean firstTimeEnrolment = true; if (studentCurricularPlan.getSpecialization() != null && studentCurricularPlan.getSpecialization() .equals(Specialization.STUDENT_CURRICULAR_PLAN_MASTER_DEGREE)) { Collection<StudentCurricularPlan> previousStudentCurricularPlans = studentCurricularPlan .getRegistration().getStudentCurricularPlansBySpecialization( Specialization.STUDENT_CURRICULAR_PLAN_MASTER_DEGREE); previousStudentCurricularPlans.remove(studentCurricularPlan); for (StudentCurricularPlan previousStudentCurricularPlan : previousStudentCurricularPlans) { if (previousStudentCurricularPlan.getDegreeCurricularPlan().getDegree() .equals(studentCurricularPlan.getDegreeCurricularPlan().getDegree())) { firstTimeEnrolment = false; break; } } } else if (studentCurricularPlan.getSpecialization() != null && studentCurricularPlan .getSpecialization().equals(Specialization.STUDENT_CURRICULAR_PLAN_SPECIALIZATION)) { if (!studentCurricularPlan.getDegreeCurricularPlan().getFirstExecutionDegree().getExecutionYear() .equals(executionYear)) { continue; } } if (firstTimeEnrolment) { if (!studentCurricularPlan.getDegreeCurricularPlan().getFirstExecutionDegree().getExecutionYear() .equals(executionYear)) { firstTimeEnrolment = false; } } InfoStudentCurricularPlanWithFirstTimeEnrolment infoStudentCurricularPlan = InfoStudentCurricularPlanWithFirstTimeEnrolment .newInfoFromDomain(studentCurricularPlan); infoStudentCurricularPlan.setFirstTimeEnrolment(firstTimeEnrolment); infoStudentCurricularPlans.add(infoStudentCurricularPlan); } return infoStudentCurricularPlans; }
From source file:com.kylinolap.query.routing.QueryRouter.java
private static Collection<TblColRef> getDimensionColumns(OLAPContext olapContext) { Collection<TblColRef> dimensionColumns = new HashSet<TblColRef>(); dimensionColumns.addAll(olapContext.allColumns); for (TblColRef measureColumn : olapContext.metricsColumns) { dimensionColumns.remove(measureColumn); }/* w w w. j a v a 2 s. c o m*/ return dimensionColumns; }
From source file:com.hihframework.core.utils.CollectionUtils.java
/** * ?ID?,???.//from ww w. j a v a 2 s . c o m * http?????idhibernate??????? * ? * ???ID?,ID?ID??. * * @param collection * ?? * @param checkedIds * ? * @param idName * ID?? * @param clazz * ? */ public static <T, ID> void mergeByCheckedIds(Collection<T> collection, Collection<ID> checkedIds, String idName, Class<T> clazz) throws Exception { if (checkedIds == null) { collection.clear(); return; } Iterator<T> it = collection.iterator(); while (it.hasNext()) { T obj = it.next(); if (checkedIds.contains(PropertyUtils.getProperty(obj, idName))) { checkedIds.remove(PropertyUtils.getProperty(obj, idName)); } else { it.remove(); } } for (ID id : checkedIds) { T obj = clazz.newInstance(); PropertyUtils.setProperty(obj, idName, id); collection.add(obj); } }
From source file:gov.nih.nci.caintegrator.common.PermissibleValueUtil.java
private static void removeValue(Collection<PermissibleValue> abstractPermissibleValues, String removePermissibleDisplayValue) { PermissibleValue abstractPermissibleValue = getObject(abstractPermissibleValues, removePermissibleDisplayValue); if (abstractPermissibleValue == null) { return;//from w ww. ja v a 2s . co m } abstractPermissibleValues.remove(abstractPermissibleValue); }
From source file:com.oltpbenchmark.util.CollectionUtil.java
public static <T> T pop(Collection<T> items) { T t = CollectionUtil.first(items);//w w w. ja v a 2 s .c om if (t != null) { boolean ret = items.remove(t); assert (ret); } return (t); }
From source file:org.oscarehr.web.admin.ProviderPreferencesUIBean.java
public static void removeQuickLink(String name) { ProviderPreference providerPreference = getLoggedInProviderPreference(); Collection<ProviderPreference.QuickLink> quickLinks = providerPreference.getAppointmentScreenQuickLinks(); for (ProviderPreference.QuickLink quickLink : quickLinks) { if (name.equals(quickLink.getName())) { // it should be okay to modify the list while we're iterating through it, as long as we don't touch it after it's modified. quickLinks.remove(quickLink); break; }//from w w w . j av a 2 s .c o m } providerPreferenceDao.merge(providerPreference); }
From source file:org.ebayopensource.turmeric.eclipse.errorlibrary.properties.ui.utils.TurmericErrorLibraryUtils.java
/** * Removes the domain from props./*from ww w. j av a 2 s .com*/ * * @param project the project * @param domainName the domain name * @throws IOException Signals that an I/O exception has occurred. * @throws CoreException the core exception */ public static void removeDomainFromProps(IProject project, String domainName) throws IOException, CoreException { IFile file = TurmericErrorLibraryUtils.getDomainListPropsFile(project); if (file.isAccessible()) { String key = PropertiesSOAConstants.PROPS_LIST_OF_DOMAINS; OutputStream output = null; InputStream input = null; try { output = new ByteArrayOutputStream(); input = file.getContents(); Collection<String> domains = TurmericErrorLibraryUtils.getAllErrorDomains(project); if (domains.contains(domainName)) { domains.remove(domainName); } String domainListStr = StringUtils.join(domains, ","); PropertiesFileUtil.updatePropertyByKey(input, output, key, domainListStr); String contents = output.toString(); WorkspaceUtil.writeToFile(contents, file, null); } finally { IOUtils.closeQuietly(input); IOUtils.closeQuietly(output); } } }