java.util.function.BiConsumer Java Examples

The following examples show how to use java.util.function.BiConsumer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ThreadLocalRandomTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void testDoubleBadOriginBound(BiConsumer<Double, Double> bi) {
        executeAndCatchIAE(() -> bi.accept(17.0, 2.0));
        executeAndCatchIAE(() -> bi.accept(0.0, 0.0));
        executeAndCatchIAE(() -> bi.accept(Double.NaN, FINITE));
        executeAndCatchIAE(() -> bi.accept(FINITE, Double.NaN));
        executeAndCatchIAE(() -> bi.accept(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY));

        // Returns NaN
//        executeAndCatchIAE(() -> bi.accept(Double.NEGATIVE_INFINITY, FINITE));
//        executeAndCatchIAE(() -> bi.accept(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));

        executeAndCatchIAE(() -> bi.accept(FINITE, Double.NEGATIVE_INFINITY));

        // Returns Double.MAX_VALUE
//        executeAndCatchIAE(() -> bi.accept(FINITE, Double.POSITIVE_INFINITY));

        executeAndCatchIAE(() -> bi.accept(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY));
        executeAndCatchIAE(() -> bi.accept(Double.POSITIVE_INFINITY, FINITE));
        executeAndCatchIAE(() -> bi.accept(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY));
    }
 
Example #2
Source File: SoftKeyHashMap.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void forEach(final BiConsumer<? super K, ? super V> action) {
    Objects.requireNonNull(action);
    final int expectedModCount = modCount;

    final Entry<K, V>[] tab = getTable();
    for (Entry<K, V> entry : tab) {
        while (entry != null) {
            final Object key = entry.get();
            if (key != null) {
                action.accept((K) SoftKeyHashMap.unmaskNull(key), entry.value);
            }
            entry = entry.next;

            if (expectedModCount != modCount) {
                throw new ConcurrentModificationException();
            }
        }
    }
}
 
Example #3
Source File: IdentityHashMap.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void forEach(BiConsumer<? super K, ? super V> action) {
    Objects.requireNonNull(action);
    int expectedModCount = modCount;

    Object[] t = table;
    for (int index = 0; index < t.length; index += 2) {
        Object k = t[index];
        if (k != null) {
            action.accept((K) unmaskNull(k), (V) t[index + 1]);
        }

        if (modCount != expectedModCount) {
            throw new ConcurrentModificationException();
        }
    }
}
 
Example #4
Source File: HashMap.java    From aion with MIT License 6 votes vote down vote up
@Override
public void forEach(BiConsumer<? super K, ? super V> action) {
    Node<K, V>[] tab;
    if (action == null) {
        throw new NullPointerException();
    }
    if (size > 0 && (tab = table) != null) {
        int mc = modCount;
        for (Node<K, V> e : tab) {
            for (; e != null; e = e.next) {
                action.accept(e.key, e.value);
            }
        }
        if (modCount != mc) {
            throw new ConcurrentModificationException();
        }
    }
}
 
Example #5
Source File: Collector.java    From steady with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a new {@code Collector} described by the given {@code supplier},
 * {@code accumulator}, {@code combiner}, and {@code finisher} functions.
 *
 * @param supplier The supplier function for the new collector
 * @param accumulator The accumulator function for the new collector
 * @param combiner The combiner function for the new collector
 * @param finisher The finisher function for the new collector
 * @param characteristics The collector characteristics for the new
 *                        collector
 * @param <T> The type of input elements for the new collector
 * @param <A> The intermediate accumulation type of the new collector
 * @param <R> The final result type of the new collector
 * @throws NullPointerException if any argument is null
 * @return the new {@code Collector}
 */
public static<T, A, R> Collector<T, A, R> of(Supplier<A> supplier,
                                             BiConsumer<A, T> accumulator,
                                             BinaryOperator<A> combiner,
                                             Function<A, R> finisher,
                                             Characteristics... characteristics) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    Objects.requireNonNull(finisher);
    Objects.requireNonNull(characteristics);
    Set<Characteristics> cs = Collectors.CH_NOID;
    if (characteristics.length > 0) {
        cs = EnumSet.noneOf(Characteristics.class);
        Collections.addAll(cs, characteristics);
        cs = Collections.unmodifiableSet(cs);
    }
    return new Collectors.CollectorImpl<>(supplier, accumulator, combiner, finisher, cs);
}
 
Example #6
Source File: Collector.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a new {@code Collector} described by the given {@code supplier},
 * {@code accumulator}, {@code combiner}, and {@code finisher} functions.
 *
 * @param supplier The supplier function for the new collector
 * @param accumulator The accumulator function for the new collector
 * @param combiner The combiner function for the new collector
 * @param finisher The finisher function for the new collector
 * @param characteristics The collector characteristics for the new
 *                        collector
 * @param <T> The type of input elements for the new collector
 * @param <A> The intermediate accumulation type of the new collector
 * @param <R> The final result type of the new collector
 * @throws NullPointerException if any argument is null
 * @return the new {@code Collector}
 */
public static<T, A, R> Collector<T, A, R> of(Supplier<A> supplier,
                                             BiConsumer<A, T> accumulator,
                                             BinaryOperator<A> combiner,
                                             Function<A, R> finisher,
                                             Characteristics... characteristics) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    Objects.requireNonNull(finisher);
    Objects.requireNonNull(characteristics);
    Set<Characteristics> cs = Collectors.CH_NOID;
    if (characteristics.length > 0) {
        cs = EnumSet.noneOf(Characteristics.class);
        Collections.addAll(cs, characteristics);
        cs = Collections.unmodifiableSet(cs);
    }
    return new Collectors.CollectorImpl<>(supplier, accumulator, combiner, finisher, cs);
}
 
Example #7
Source File: MainTest.java    From gatk with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Process each {@code CommandLineProgram}-derived class given a list of packages.
 * @param packageList list of packages to search
 * @param clpClassProcessor function to process each CommandLineProgram class found in {@code packageList} (note
 *                          that the {@code CommandLineProgramProperties} argument may be null)
 */
public static void processAllCommandLinePrograms(
        final List<String> packageList,
        final BiConsumer<Class<?>, CommandLineProgramProperties> clpClassProcessor) {
    final ClassFinder classFinder = new ClassFinder();
    packageList.forEach(pkg -> classFinder.find(pkg, CommandLineProgram.class));

    for (final Class<?> clazz : classFinder.getClasses()) {
        // No interfaces, synthetic, primitive, local, or abstract classes.
        if (!clazz.isInterface() && !clazz.isSynthetic() && !clazz.isPrimitive() && !clazz.isLocalClass()
                && !Modifier.isAbstract(clazz.getModifiers())
                && !clazz.isAnonymousClass() // skip anonymous (test) classes since they don't have annotations
                && clazz != PicardCommandLineProgramExecutor.class) {
            final CommandLineProgramProperties clpProperties = Main.getProgramProperty(clazz);
            clpClassProcessor.accept(clazz, clpProperties);
        }
    }
}
 
Example #8
Source File: StampedLockTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Read locks can be very deeply nested
 */
public void testDeeplyNestedReadLocks() {
    final StampedLock lock = new StampedLock();
    final int depth = 300;
    final long[] stamps = new long[depth];
    final List<Function<StampedLock, Long>> readLockers = readLockers();
    final List<BiConsumer<StampedLock, Long>> readUnlockers = readUnlockers();
    for (int i = 0; i < depth; i++) {
        Function<StampedLock, Long> readLocker
            = readLockers.get(i % readLockers.size());
        long stamp = readLocker.apply(lock);
        assertEquals(i + 1, lock.getReadLockCount());
        assertTrue(lock.isReadLocked());
        stamps[i] = stamp;
    }
    for (int i = 0; i < depth; i++) {
        BiConsumer<StampedLock, Long> readUnlocker
            = readUnlockers.get(i % readUnlockers.size());
        assertEquals(depth - i, lock.getReadLockCount());
        assertTrue(lock.isReadLocked());
        readUnlocker.accept(lock, stamps[depth - 1 - i]);
    }
    assertUnlocked(lock);
}
 
Example #9
Source File: Pojofy.java    From vertxui with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param <A>
 *            the input type class
 * @param inputType
 *            the input type
 * @param handler
 *            the callback
 * @return the webserver handler for this ajax call.
 */
public static <A> Handler<RoutingContext> ajax(Class<A> inputType, BiConsumer<A, RoutingContext> handler) {
	return context -> {

		// Internet Explorer 11 caches ajax calls
		context.response().putHeader("Cache-control", "none");
		context.response().putHeader("Pragma", "none");
		context.response().putHeader("Expires", "0");
		context.response().putHeader("Content-Type", "application/json; charset=" + VertxUI.charset);

		context.request().bodyHandler(body -> {
			context.response().end();
			handler.accept(in(inputType, body.toString()), context);
		});
	};
}
 
Example #10
Source File: StaticUiSpecGenerator.java    From component-runtime with Apache License 2.0 6 votes vote down vote up
private void visitConfigurationRoute(final UiSpecService<Object> service, final Jsonb jsonb, final Route route,
        final BiConsumer<String, String> onFile) throws IOException {
    final String configId = route.getId().substring("component_server_configuration_details_en_".length());
    // todo: resolve the parent since we have it in the route instead of using that hack
    final String id = new String(Base64.getDecoder().decode(configId), StandardCharsets.UTF_8);
    final String family = id.split("#")[1];
    try (final InputStream stream = new ByteArrayInputStream(route.getContent())) {
        try {
            final ConfigTypeNodes nodes = jsonb.fromJson(stream, ConfigTypeNodes.class);
            final Ui ui = service
                    .convert(family, "en", nodes.getNodes().values().iterator().next(), null)
                    .toCompletableFuture()
                    .get();
            onFile.accept("configuration/" + configId, jsonb.toJson(ui));
        } catch (final InterruptedException | ExecutionException e) {
            throw new IllegalStateException(e);
        }
    }
}
 
Example #11
Source File: Timeouts.java    From tascalate-concurrent with Apache License 2.0 5 votes vote down vote up
static <T, E extends Throwable> BiConsumer<T, E> configureDelay(Promise<? extends T> self, CompletableFuture<Try<? super T>> delayed, Duration duration, boolean delayOnError) {
    return (result, error) -> {
        if (error == null || (delayOnError && !self.isCancelled())) {
            Promise<?> timeout = delay(duration);
            delayed.whenComplete( (r, e) -> timeout.cancel(true) );
            timeout.whenComplete( (r, e) -> delayed.complete(Try.nothing()) );
        } else {
            // when error and should not delay on error
            delayed.complete(Try.nothing());
        }
    };
}
 
Example #12
Source File: HashMap.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void forEach(BiConsumer<? super K, ? super V> action) {
    Node<K,V>[] tab;
    if (action == null)
        throw new NullPointerException();
    if (size > 0 && (tab = table) != null) {
        int mc = modCount;
        for (int i = 0; i < tab.length; ++i) {
            for (Node<K,V> e = tab[i]; e != null; e = e.next)
                action.accept(e.key, e.value);
        }
        if (modCount != mc)
            throw new ConcurrentModificationException();
    }
}
 
Example #13
Source File: Network.java    From cate with MIT License 5 votes vote down vote up
/**
 * @param context context this network manages.
 * @param controller the controller to push events back to.
 * @param directory the data directory to store the wallet and SPV chain in.
 * @param networkExecutor executor for tasks belonging to this network.
 * Must exist after the lifecycle of network (so that service status listeners
 * can be attached to it).
 */
public Network(final Context context, final MainController controller,
        final File directory, final Executor networkExecutor,
        final BiConsumer<Network, Wallet> registerWalletHook) {
    super(context, directory, "cate_" + context.getParams().getId());
    this.controller = controller;
    this.networkExecutor = networkExecutor;
    autoStop = false;
    blockingStartup = true;
    this.registerWalletHook = registerWalletHook;

    monetaryFormatter = context.getParams().getMonetaryFormat();
    addListener(new Service.Listener() {
        @Override
        public void running() {
            estimatedBalance.set(monetaryFormatter.format(wallet().getBalance(Wallet.BalanceType.ESTIMATED)).toString());
            try {
                blocks.set(store().getChainHead().getHeight());
            } catch (BlockStoreException ex) {
                logger.error("Error getting current chain head while starting wallet "
                        + params.getId(), ex);
            }
            encrypted.set(wallet().isEncrypted());
        }

        @Override
        public void failed(Service.State from, Throwable failure) {
            controller.onNetworkFailed(Network.this, from, failure);
        }
    }, networkExecutor);
}
 
Example #14
Source File: ResourceBlockHeaderManager.java    From WeCross with Apache License 2.0 5 votes vote down vote up
public void setBlockHeaderStorage(BlockHeaderStorage blockHeaderStorage) {
    this.blockHeaderStorage = blockHeaderStorage;
    if (blockHeaderStorage != null) {
        this.blockHeaderStorage.registerOnBlockHeader(
                new BiConsumer<Long, byte[]>() {
                    @Override
                    public void accept(Long blockNumber, byte[] blockHeader) {
                        onBlockHeader(blockNumber.longValue(), blockHeader);
                    }
                });
    }
}
 
Example #15
Source File: LazyStream.java    From cyclops with Apache License 2.0 5 votes vote down vote up
default <R> R collect(final Supplier<R> supplier, final BiConsumer<R, ? super U> accumulator, final BiConsumer<R, R> combiner) {
    return (R) this.run((Collector) Collector.of(supplier, accumulator, (a, b) -> {
        combiner.accept(a, b);
        return a;
    }));

}
 
Example #16
Source File: RedissonObject.java    From redisson with Apache License 2.0 5 votes vote down vote up
protected final <T extends ObjectListener> RFuture<Integer> addListenerAsync(String name, T listener, BiConsumer<T, String> consumer) {
    RPatternTopic topic = new RedissonPatternTopic(StringCodec.INSTANCE, commandExecutor, name);
    return topic.addListenerAsync(String.class, (pattern, channel, msg) -> {
        if (msg.equals(getName())) {
            consumer.accept(listener, msg);
        }
    });
}
 
Example #17
Source File: PentahoOrcInputFormat.java    From pentaho-hadoop-shims with Apache License 2.0 5 votes vote down vote up
public PentahoOrcInputFormat( NamedCluster namedCluster ) {
  if ( namedCluster == null ) {
    conf = new Configuration();
  } else {
    conf = inClassloader( () -> {
      Configuration confProxy = new ConfigurationProxy();
      confProxy.addResource( "hive-site.xml" );
      BiConsumer<InputStream, String> consumer = ( is, filename ) -> confProxy.addResource( is, filename );
      ShimConfigsLoader.addConfigsAsResources( namedCluster, consumer );
      return confProxy;
    } );
  }
}
 
Example #18
Source File: TracingMethodMessageHandlerAdapter.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
void wrapMethodMessageHandler(Message<?> message, MessageHandler messageHandler,
		BiConsumer<Span, Message<?>> messageSpanTagger) {
	MessageConsumerRequest request = new MessageConsumerRequest(message, this.getter);
	TraceContextOrSamplingFlags extracted = extractAndClearHeaders(request);

	Span consumerSpan = tracer.nextSpan(extracted);
	Span listenerSpan = tracer.newChild(consumerSpan.context());

	if (!consumerSpan.isNoop()) {
		consumerSpan.name("next-message").kind(CONSUMER);
		if (messageSpanTagger != null) {
			messageSpanTagger.accept(consumerSpan, message);
		}

		// incur timestamp overhead only once
		long timestamp = tracing.clock(consumerSpan.context())
				.currentTimeMicroseconds();
		consumerSpan.start(timestamp);
		long consumerFinish = timestamp + 1L; // save a clock reading
		consumerSpan.finish(consumerFinish);

		// not using scoped span as we want to start with a pre-configured time
		listenerSpan.name("on-message").start(consumerFinish);
	}

	try (Tracer.SpanInScope ws = tracer.withSpanInScope(listenerSpan)) {
		messageHandler.handleMessage(message);
	}
	catch (Throwable t) {
		listenerSpan.error(t);
		throw t;
	}
	finally {
		listenerSpan.finish();
	}
}
 
Example #19
Source File: SerializationTest.java    From joyrpc with Apache License 2.0 5 votes vote down vote up
protected void serializeAndDeserialize(final Serialization serialization, final Object target,
                                       final UnsafeByteArrayOutputStream baos,
                                       final BiConsumer<Object, Object> consumer) {
    Serializer serializer = serialization.getSerializer();
    serializer.serialize(baos, target);
    UnsafeByteArrayInputStream bais = new UnsafeByteArrayInputStream(baos.toByteArray());
    Object data = serializer.deserialize(bais, target.getClass());
    if (consumer == null) {
        Assert.assertEquals(serialization.getContentType(), data, target);
    } else {
        consumer.accept(data, target);
    }
}
 
Example #20
Source File: CompletableFuture.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private CompletableFuture<T> uniWhenCompleteStage(
    Executor e, BiConsumer<? super T, ? super Throwable> f) {
    if (f == null) throw new NullPointerException();
    CompletableFuture<T> d = new CompletableFuture<T>();
    if (e != null || !d.uniWhenComplete(this, f, null)) {
        UniWhenComplete<T> c = new UniWhenComplete<T>(e, d, this, f);
        push(c);
        c.tryFire(SYNC);
    }
    return d;
}
 
Example #21
Source File: JarFileSource.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void eachClass(BiConsumer<String, ClassLoader> consumer) {
    FileSystemFinder finder = new FileSystemFinder(jarRootPath, ClassSource::pathIsClassFile);

    for (Path path : finder) {
        consumer.accept(ClassSource.makeClassName(jarRootPath.relativize(path).normalize()), classLoader);
    }
}
 
Example #22
Source File: ProofListIndexProxyIntegrationTest.java    From exonum-java-binding with Apache License 2.0 5 votes vote down vote up
private static void runTestWithView(Function<Cleaner, Access> viewFactory,
                                    BiConsumer<Access, ProofListIndexProxy<String>> listTest) {
  IndicesTests.runTestWithView(
      viewFactory,
      LIST_NAME,
      ((address, access, serializer) -> access.getProofList(address, serializer)),
      listTest
  );
}
 
Example #23
Source File: ExecutionFlow.java    From spring-boot-akka-event-sourcing-starter with Apache License 2.0 5 votes vote down vote up
public ExecutionFlowBuilder<C, E, S> onReadOnlyCommand(Class<? extends C> command, BiConsumer<C, ReadOnlyFlowContext> handler) {

			onCommand(command, (cmd, flowContext, state) -> {
				handler.accept(cmd, flowContext);
				return flowContext.done();
			});
			return this;
		}
 
Example #24
Source File: InfinispanClusteredAsyncMapTest.java    From vertx-infinispan with Apache License 2.0 5 votes vote down vote up
private <T> void testReadStream(
  Function<InfinispanAsyncMap<JsonObject, Buffer>, ReadStream<T>> streamFactory,
  BiConsumer<Map<JsonObject, Buffer>, List<T>> assertions
) {
  Map<JsonObject, Buffer> map = genJsonToBuffer(100);
  loadData(map, (vertx, asyncMap) -> {
    List<T> items = new ArrayList<>();
    ReadStream<T> stream = streamFactory.apply(InfinispanAsyncMap.unwrap(asyncMap));
    AtomicInteger idx = new AtomicInteger();
    long pause = 500;
    long start = System.nanoTime();
    stream.endHandler(end -> {
      assertions.accept(map, items);
      long duration = NANOSECONDS.toMillis(System.nanoTime() - start);
      assertTrue(duration >= 3 * pause);
      testComplete();
    }).exceptionHandler(t -> {
      fail(t);
    }).handler(item -> {
      items.add(item);
      int j = idx.getAndIncrement();
      if (j == 3 || j == 16 || j == 38) {
        stream.pause();
        int emitted = items.size();
        vertx.setTimer(pause, tid -> {
          assertTrue("Items emitted during pause", emitted == items.size());
          stream.resume();
        });
      }
    });
  });
  await();
}
 
Example #25
Source File: TestDistributedInstanceManager.java    From bboxdb with Apache License 2.0 5 votes vote down vote up
/**
 * Test add event generation
 * @throws InterruptedException 
 * @throws ZookeeperException
 */
@Test(timeout=30000)
public void testAddEvent() throws InterruptedException {
	final BBoxDBInstanceManager distributedInstanceManager = BBoxDBInstanceManager.getInstance();
	
	final BBoxDBInstance instance1 = new BBoxDBInstance("node4:5050");
	final BBoxDBInstance instance2 = new BBoxDBInstance("node5:5050");

	final ZookeeperClient zookeeperClient1 = getNewZookeeperClient(instance1);
	BBoxDBInstanceManager.getInstance().startMembershipObserver(zookeeperClient1);
	Thread.sleep(5000);
	
	final CountDownLatch changedLatch = new CountDownLatch(1);

	distributedInstanceManager.registerListener(new BiConsumer<DistributedInstanceEvent, BBoxDBInstance>() {
		
		@Override
		public void accept(final DistributedInstanceEvent event, final BBoxDBInstance instance) {
			if(event == DistributedInstanceEvent.ADD) {
				if(instance.socketAddressEquals(instance2)) {
					changedLatch.countDown();
				}
			} else {
				// Unexpected event
				System.out.println("Got unexpeceted event: " + event);
				Assert.assertTrue(false);
			}				
		}
	});
	
	final ZookeeperClient zookeeperClient2 = getNewZookeeperClient(instance2);
	
	changedLatch.await();
	
	distributedInstanceManager.removeAllListener();
	
	zookeeperClient1.shutdown();
	zookeeperClient2.shutdown();
}
 
Example #26
Source File: MonoPeekTerminal.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
MonoPeekTerminal(Mono<? extends T> source,
		@Nullable Consumer<? super T> onSuccessCall,
		@Nullable Consumer<? super Throwable> onErrorCall,
		@Nullable BiConsumer<? super T, Throwable> onAfterTerminateCall) {
	super(source);
	this.onAfterTerminateCall = onAfterTerminateCall;
	this.onSuccessCall = onSuccessCall;
	this.onErrorCall = onErrorCall;
}
 
Example #27
Source File: SearchPane.java    From Recaf with MIT License 5 votes vote down vote up
private Input(ColumnPane root, String key, String desc, Supplier<E> create,
			  Function<E, R> mapper, BiConsumer<E, R> setter) {
	this.editor = create.get();
	this.mapper = mapper;
	this.setter = setter;
	this.key = key;
	SubLabeled labeled = new SubLabeled(translate(key), translate(desc));
	root.add(labeled, editor);
}
 
Example #28
Source File: Collectors.java    From desugar_jdk_libs with GNU General Public License v2.0 5 votes vote down vote up
CollectorImpl(Supplier<A> supplier,
              BiConsumer<A, T> accumulator,
              BinaryOperator<A> combiner,
              Function<A,R> finisher,
              Set<Characteristics> characteristics) {
    this.supplier = supplier;
    this.accumulator = accumulator;
    this.combiner = combiner;
    this.finisher = finisher;
    this.characteristics = characteristics;
}
 
Example #29
Source File: MockKube.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
private MockedCrd(CustomResourceDefinition crd,
                  Class<T> crClass, Class<L> crListClass, Class<D> crDoneableClass,
                  Function<T, S> getStatus,
                  BiConsumer<T, S> setStatus) {
    this.crd = crd;
    this.crClass = crClass;
    this.crListClass = crListClass;
    this.crDoneableClass = crDoneableClass;
    this.getStatus = getStatus;
    this.setStatus = setStatus;
    instances = db(emptySet(), crClass, crDoneableClass);
}
 
Example #30
Source File: MoreCollectors.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
public static <T, A, R> Collector<T, ?, R> collector(Supplier<A> supplier,
                                                     BiConsumer<A, T> accumulator,
                                                     BiConsumer<A, A> combiner,
                                                     Function<A, R> finisher) {
    BinaryOperator<A> binaryOperator = Functions.mergeLeft(combiner);
    return Collector.of(supplier, accumulator, binaryOperator, finisher);
}