@Override public boolean containsAll(Collection<?> collection) { return this.delegate.containsAll(collection); }
@Override public boolean containsAll(Collection<?> collection) { return this.delegate.containsAll(collection); }
@Override public boolean containsAll(Collection<?> collection) { return this.delegate.containsAll(collection); }
@Override public boolean covers(TrackingToken other) { Assert.isTrue(other instanceof GapAwareTrackingToken, () -> "Incompatible token type provided."); GapAwareTrackingToken otherToken = (GapAwareTrackingToken) other; return otherToken.index <= this.index && !this.gaps.contains(otherToken.index) && otherToken.gaps.containsAll(this.gaps.headSet(otherToken.index)); }
public void testContainsAll_notSortedSet() { SortedSet<String> set = of("a", "b", "f"); assertTrue(set.containsAll(Collections.emptyList())); assertTrue(set.containsAll(asList("b"))); assertTrue(set.containsAll(asList("b", "b"))); assertTrue(set.containsAll(asList("b", "f"))); assertTrue(set.containsAll(asList("b", "f", "a"))); assertFalse(set.containsAll(asList("d"))); assertFalse(set.containsAll(asList("z"))); assertFalse(set.containsAll(asList("b", "d"))); assertFalse(set.containsAll(asList("f", "d", "a"))); }
public void testContainsAll_sameComparator() { SortedSet<String> set = of("a", "b", "f"); assertTrue(set.containsAll(Sets.newTreeSet())); assertTrue(set.containsAll(Sets.newTreeSet(asList("b")))); assertTrue(set.containsAll(Sets.newTreeSet(asList("a", "f")))); assertTrue(set.containsAll(Sets.newTreeSet(asList("a", "b", "f")))); assertFalse(set.containsAll(Sets.newTreeSet(asList("d")))); assertFalse(set.containsAll(Sets.newTreeSet(asList("z")))); assertFalse(set.containsAll(Sets.newTreeSet(asList("b", "d")))); assertFalse(set.containsAll(Sets.newTreeSet(asList("f", "d", "a")))); }
@SuppressWarnings("CollectionIncompatibleType") // testing incompatible types public void testContainsAll_sameComparator_StringVsInt() { SortedSet<String> set = of("a", "b", "f"); SortedSet<Integer> unexpected = Sets.newTreeSet(Ordering.natural()); unexpected.addAll(asList(1, 2, 3)); assertFalse(set.containsAll(unexpected)); }
public void testContainsAll_differentComparator() { Comparator<Comparable<?>> comparator = Collections.reverseOrder(); SortedSet<String> set = new ImmutableSortedSet.Builder<String>(comparator).add("a", "b", "f").build(); assertTrue(set.containsAll(Sets.newTreeSet())); assertTrue(set.containsAll(Sets.newTreeSet(asList("b")))); assertTrue(set.containsAll(Sets.newTreeSet(asList("a", "f")))); assertTrue(set.containsAll(Sets.newTreeSet(asList("a", "b", "f")))); assertFalse(set.containsAll(Sets.newTreeSet(asList("d")))); assertFalse(set.containsAll(Sets.newTreeSet(asList("z")))); assertFalse(set.containsAll(Sets.newTreeSet(asList("b", "d")))); assertFalse(set.containsAll(Sets.newTreeSet(asList("f", "d", "a")))); }
@SuppressWarnings("unchecked") // list cannot be properly parameterized as it breaks other tests @Test public void setCollectionPropertyWithArrayValue() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); Collection<String> coll = new HashSet<>(); coll.add("coll1"); accessor.setPropertyValue("collection", coll.toArray()); List<String> set = new LinkedList<>(); set.add("set1"); accessor.setPropertyValue("set", set.toArray()); List<String> sortedSet = new ArrayList<>(); sortedSet.add("sortedSet1"); accessor.setPropertyValue("sortedSet", sortedSet.toArray()); Set<String> list = new HashSet<>(); list.add("list1"); accessor.setPropertyValue("list", list.toArray()); assertEquals(1, target.getCollection().size()); assertTrue(target.getCollection().containsAll(coll)); assertEquals(1, target.getSet().size()); assertTrue(target.getSet().containsAll(set)); assertEquals(1, target.getSortedSet().size()); assertTrue(target.getSortedSet().containsAll(sortedSet)); assertEquals(1, target.getList().size()); assertTrue(target.getList().containsAll(list)); }
@SuppressWarnings("unchecked") // list cannot be properly parameterized as it breaks other tests @Test public void setCollectionPropertyWithIntegerValue() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); Collection<Integer> coll = new HashSet<>(); coll.add(0); accessor.setPropertyValue("collection", new Integer(0)); List<Integer> set = new LinkedList<>(); set.add(1); accessor.setPropertyValue("set", new Integer(1)); List<Integer> sortedSet = new ArrayList<>(); sortedSet.add(2); accessor.setPropertyValue("sortedSet", new Integer(2)); Set<Integer> list = new HashSet<>(); list.add(3); accessor.setPropertyValue("list", new Integer(3)); assertEquals(1, target.getCollection().size()); assertTrue(target.getCollection().containsAll(coll)); assertEquals(1, target.getSet().size()); assertTrue(target.getSet().containsAll(set)); assertEquals(1, target.getSortedSet().size()); assertTrue(target.getSortedSet().containsAll(sortedSet)); assertEquals(1, target.getList().size()); assertTrue(target.getList().containsAll(list)); }
@SuppressWarnings("unchecked") // list cannot be properly parameterized as it breaks other tests @Test public void setCollectionPropertyWithStringValue() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); List<String> set = new LinkedList<>(); set.add("set1"); accessor.setPropertyValue("set", "set1"); List<String> sortedSet = new ArrayList<>(); sortedSet.add("sortedSet1"); accessor.setPropertyValue("sortedSet", "sortedSet1"); Set<String> list = new HashSet<>(); list.add("list1"); accessor.setPropertyValue("list", "list1"); assertEquals(1, target.getSet().size()); assertTrue(target.getSet().containsAll(set)); assertEquals(1, target.getSortedSet().size()); assertTrue(target.getSortedSet().containsAll(sortedSet)); assertEquals(1, target.getList().size()); assertTrue(target.getList().containsAll(list)); }
@SuppressWarnings("unchecked") // list cannot be properly parameterized as it breaks other tests @Test public void setCollectionPropertyNonMatchingType() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); Collection<String> coll = new ArrayList<>(); coll.add("coll1"); accessor.setPropertyValue("collection", coll); List<String> set = new LinkedList<>(); set.add("set1"); accessor.setPropertyValue("set", set); List<String> sortedSet = new ArrayList<>(); sortedSet.add("sortedSet1"); accessor.setPropertyValue("sortedSet", sortedSet); Set<String> list = new HashSet<>(); list.add("list1"); accessor.setPropertyValue("list", list); assertEquals(1, target.getCollection().size()); assertTrue(target.getCollection().containsAll(coll)); assertEquals(1, target.getSet().size()); assertTrue(target.getSet().containsAll(set)); assertEquals(1, target.getSortedSet().size()); assertTrue(target.getSortedSet().containsAll(sortedSet)); assertEquals(1, target.getList().size()); assertTrue(target.getList().containsAll(list)); }
@SuppressWarnings("unchecked") // list cannot be properly parameterized as it breaks other tests @Test public void setCollectionPropertyWithIntArrayValue() { IndexedTestBean target = new IndexedTestBean(); AbstractPropertyAccessor accessor = createAccessor(target); Collection<Integer> coll = new HashSet<>(); coll.add(0); accessor.setPropertyValue("collection", new int[] {0}); List<Integer> set = new LinkedList<>(); set.add(1); accessor.setPropertyValue("set", new int[] {1}); List<Integer> sortedSet = new ArrayList<>(); sortedSet.add(2); accessor.setPropertyValue("sortedSet", new int[] {2}); Set<Integer> list = new HashSet<>(); list.add(3); accessor.setPropertyValue("list", new int[] {3}); assertEquals(1, target.getCollection().size()); assertTrue(target.getCollection().containsAll(coll)); assertEquals(1, target.getSet().size()); assertTrue(target.getSet().containsAll(set)); assertEquals(1, target.getSortedSet().size()); assertTrue(target.getSortedSet().containsAll(sortedSet)); assertEquals(1, target.getList().size()); assertTrue(target.getList().containsAll(list)); }
@Test public void sortedSetViewTest(){ SortedSet<Integer> list = of(1,2,3).sortedSetView(); assertThat(list.size(),equalTo(3)); assertThat(list,equalTo(new java.util.TreeSet<>(Arrays.asList(1,2,3)))); assertThat(list.contains(2),equalTo(true)); assertThat(list.containsAll(Arrays.asList(2,3)),equalTo(true)); assertThat(list.containsAll(Arrays.asList(2,3,4)),equalTo(false)); } }
@Override public boolean containsAll(Collection<?> collection) { return this.delegate.containsAll(collection); }
@Override public boolean containsAll(Collection<?> collection) { return this.delegate.containsAll(collection); }
@Override public boolean containsAll(Collection<?> collection) { return this.delegate.containsAll(collection); }
/** * Test if this Rights set contains all of the Rights contained in another * set. * * @param list The source Rights set for the test. * * @return true if all of the Rights in the source set exist in the target set. */ public boolean contains(Rights list) { return rights.containsAll(list.rights); }
@Override public boolean covers(TrackingToken other) { Assert.isTrue(other instanceof GapAwareTrackingToken, () -> "Incompatible token type provided."); GapAwareTrackingToken otherToken = (GapAwareTrackingToken) other; return otherToken.index <= this.index && !this.gaps.contains(otherToken.index) && otherToken.gaps.containsAll(this.gaps.headSet(otherToken.index)); }
@Override public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof Map)) return false; Map<?, ?> m = (Map<?, ?>) o; if (m.size() != size()) return false; return entrySet().containsAll(m.entrySet()); }