List of usage examples for java.util Collection contains
boolean contains(Object o);
From source file:CountedSet.java
public boolean retainAll(Collection c) { boolean changed = false; for (Iterator ki = cset.keySet().iterator(); ki.hasNext();) { Object key = ki.next();/* w ww .j a v a 2 s . c o m*/ if (!c.contains(key)) { cset.remove(key); changed = true; } } return changed; }
From source file:org.brekka.pegasus.core.services.impl.MemberServiceImpl.java
@Override public boolean hasAccess(final GrantedAuthority authority) { SecurityContext context = SecurityContextHolder.getContext(); Authentication authentication = context.getAuthentication(); Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities(); return authorities.contains(authority); }
From source file:de.flapdoodle.embed.process.store.ExtractedArtifactStore.java
private List<FileSet.Entry> getMissingEntries(FileSet fileSet, Collection<FileSet.Entry> existingEntries) { List<FileSet.Entry> missingEntries = new ArrayList<FileSet.Entry>(); for (FileSet.Entry entry : fileSet.entries()) { if (!existingEntries.contains(entry)) { missingEntries.add(entry);//from w w w .j a va 2 s . c o m } } return missingEntries; }
From source file:net.sourceforge.fenixedu.domain.CurricularCourseEquivalence.java
public boolean isSatisfied(final Registration registration) { boolean result = true; final Collection<CurricularCourse> curricularCoursesApprovedByEnrolment = registration .getCurricularCoursesApprovedByEnrolment(); for (final CurricularCourse oldCurricularCourse : getOldCurricularCoursesSet()) { result &= curricularCoursesApprovedByEnrolment.contains(oldCurricularCourse); }//from w w w. j a v a 2s. c om return result; }
From source file:de.unidue.inf.is.ezdl.dlcore.analysis.stopwords.DefaultStopwordFilter.java
@Override public List<String> filter(List<String> terms, Locale locale) { Collection<String> stopwordSet = stopwords.get(locale); if (stopwordSet == null) { throw new IllegalArgumentException("no stopword list for " + locale + " found."); }//from w w w . ja v a 2s. com List<String> result = new ArrayList<String>(); for (String term : terms) { if (!stopwordSet.contains(term.toLowerCase())) { result.add(term); } } return result; }
From source file:org.openlmis.fulfillment.service.referencedata.ProgramReferenceDataServiceTest.java
@Test public void shouldFindProgramsByIds() { // given//w w w. j ava2 s . co m UUID id = UUID.randomUUID(); UUID id2 = UUID.randomUUID(); List<UUID> ids = Arrays.asList(id, id2); ProgramDto program = generateInstance(); program.setId(id); ProgramDto anotherProgram = generateInstance(); anotherProgram.setId(id2); Map<String, Object> payload = new HashMap<>(); payload.put("id", ids); ResponseEntity response = mock(ResponseEntity.class); // when when(response.getBody()).thenReturn(new ProgramDto[] { program, anotherProgram }); when(restTemplate.exchange(any(URI.class), eq(HttpMethod.GET), any(HttpEntity.class), eq(service.getArrayResultClass()))).thenReturn(response); Collection<ProgramDto> programs = service.findByIds(ids); // then verify(restTemplate).exchange(uriCaptor.capture(), eq(HttpMethod.GET), entityCaptor.capture(), eq(service.getArrayResultClass())); assertTrue(programs.contains(program)); assertTrue(programs.contains(anotherProgram)); String actualUrl = uriCaptor.getValue().toString(); assertTrue(actualUrl.startsWith(service.getServiceUrl() + service.getUrl())); assertTrue(actualUrl.contains(id.toString())); assertTrue(actualUrl.contains(id2.toString())); assertAuthHeader(entityCaptor.getValue()); }
From source file:org.openlmis.fulfillment.service.referencedata.FacilityReferenceDataServiceTest.java
@Test public void shouldFindFacilitiesByIds() { // given//from www .ja v a 2s .c om UUID id = UUID.randomUUID(); UUID id2 = UUID.randomUUID(); List<UUID> ids = Arrays.asList(id, id2); FacilityDto facility = generateInstance(); facility.setId(id); FacilityDto anotherFacility = generateInstance(); anotherFacility.setId(id2); Map<String, Object> payload = new HashMap<>(); payload.put("id", ids); ResponseEntity response = mock(ResponseEntity.class); // when when(response.getBody()).thenReturn(new FacilityDto[] { facility, anotherFacility }); when(restTemplate.exchange(any(URI.class), eq(HttpMethod.GET), any(HttpEntity.class), eq(service.getArrayResultClass()))).thenReturn(response); Collection<FacilityDto> facilities = service.findByIds(ids); // then verify(restTemplate).exchange(uriCaptor.capture(), eq(HttpMethod.GET), entityCaptor.capture(), eq(service.getArrayResultClass())); assertTrue(facilities.contains(facility)); assertTrue(facilities.contains(anotherFacility)); String actualUrl = uriCaptor.getValue().toString(); assertTrue(actualUrl.startsWith(service.getServiceUrl() + service.getUrl())); assertTrue(actualUrl.contains(id.toString())); assertTrue(actualUrl.contains(id2.toString())); assertAuthHeader(entityCaptor.getValue()); }
From source file:SortedMultiSet.java
public boolean retainAll(final Collection<?> c) { int j = 0;/*w w w . ja v a2 s.c o m*/ for (int i = 0; i < size; i++) { if (c.contains(field[i])) { field[j++] = field[i]; } } if (j == size) { return false; } for (; j < size; j++) { field[j] = null; } return true; }
From source file:de.dhke.projects.cutil.collections.map.MapKeySetEntrySet.java
@Override public boolean retainAll(Collection<?> c) { boolean removed = false; Iterator<Entry<K, V>> iter = iterator(); while (iter.hasNext()) { final Entry<K, V> entry = iter.next(); if (!c.contains(entry)) { removed = true;/* w ww. j a va 2 s .c om*/ iter.remove(); } } return removed; }
From source file:de.dhke.projects.cutil.collections.map.MapKeySetEntrySet.java
@Override public boolean removeAll(Collection<?> c) { boolean removed = false; Iterator<Entry<K, V>> iter = iterator(); while (iter.hasNext()) { final Entry<K, V> entry = iter.next(); if (c.contains(entry)) { removed = true;//from w ww . ja va 2s . c o m iter.remove(); } } return removed; }