Refine search
private ClusterException(Collection<? extends Throwable> exceptions) { super( exceptions.size() + " exceptions were thrown. The first exception is listed as a cause.", exceptions.iterator().next()); ArrayList<Throwable> temp = new ArrayList<>(); temp.addAll(exceptions); this.exceptions = Collections.unmodifiableCollection(temp); }
@Override public void onNext(T t) { synchronized (this) { U b = buffer; if (b != null) { b.add(t); } } }
public static boolean dependsOn(WindowNode parent, WindowNode child) { return parent.getPartitionBy().stream().anyMatch(child.getCreatedSymbols()::contains) || (parent.getOrderingScheme().isPresent() && parent.getOrderingScheme().get().getOrderBy().stream().anyMatch(child.getCreatedSymbols()::contains)) || parent.getWindowFunctions().values().stream() .map(WindowNode.Function::getFunctionCall) .map(SymbolsExtractor::extractUnique) .flatMap(Collection::stream) .anyMatch(child.getCreatedSymbols()::contains); } }
private void assertCollectionSize(Collection<?> collection, int size) { assertEquals(size, collection.size()); if (size > 0) { assertFalse(collection.isEmpty()); } else { assertTrue(collection.isEmpty()); } assertEquals(size, Iterables.size(collection)); assertEquals(size, Iterators.size(collection.iterator())); } }
public void testPermutationSetEmpty() { Collection<List<Integer>> permutationSet = Collections2.permutations(Collections.<Integer>emptyList()); assertEquals(1, permutationSet.size()); assertTrue(permutationSet.contains(Collections.<Integer>emptyList())); Iterator<List<Integer>> permutations = permutationSet.iterator(); assertNextPermutation(Collections.<Integer>emptyList(), permutations); assertNoMorePermutations(permutations); }
private static int getNumberOfSlotsPerTaskManager(final String host, final int port) throws Exception { final TaskManagersInfo taskManagersInfo = restClient.sendRequest( host, port, TaskManagersHeaders.getInstance()).get(); return taskManagersInfo.getTaskManagerInfos() .stream() .map(TaskManagerInfo::getNumberSlots) .findFirst() .orElse(0); }
public void forEach( BiConsumer<String,URI> consumer ) { entries.stream().collect( Collectors.groupingBy( e -> e.key ) ) .forEach( ( key, list ) -> list.stream() .max( Comparator.comparing( e -> e.precedence ) ) .ifPresent( e -> consumer.accept( key, e.uri ) ) ); }
@CollectionSize.Require(absent = CollectionSize.ZERO) @CollectionFeature.Require(ALLOWS_NULL_VALUES) public void testEquals_containingNull() { Collection<E> elements = getSampleElements(getNumElements() - 1); elements.add(null); collection = getSubjectGenerator().create(elements.toArray()); assertTrue( "A Set should equal any other Set containing the same elements," + " even if some elements are null.", getSet().equals(MinimalSet.from(elements))); }
@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION}) @CollectionSize.Require(absent = ZERO) public void testAddConcurrentWithIteration() { try { Iterator<E> iterator = collection.iterator(); assertTrue(collection.add(e3())); iterator.next(); fail("Expected ConcurrentModificationException"); } catch (ConcurrentModificationException expected) { // success } }
public void testUnhashableMixedValues() { SampleElements<UnhashableObject> unhashables = new Unhashables(); Multimap<Integer, Object> multimap = ImmutableMultimap.<Integer, Object>of( 0, unhashables.e0(), 2, "hey you", 0, unhashables.e1()); assertEquals(2, multimap.get(0).size()); assertTrue(multimap.get(0).contains(unhashables.e0())); assertTrue(multimap.get(0).contains(unhashables.e1())); assertTrue(multimap.get(2).contains("hey you")); }
/** An implementation of {@link Multiset#addAll}. */ static <E> boolean addAllImpl(Multiset<E> self, Collection<? extends E> elements) { checkNotNull(self); checkNotNull(elements); if (elements instanceof Multiset) { return addAllImpl(self, cast(elements)); } else if (elements.isEmpty()) { return false; } else { return Iterators.addAll(self, elements.iterator()); } }