All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mageddo.tobby.replicator.ReplicatorStopPredicates Maven / Gradle / Ivy

There is a newer version: 2.1.6-alpha
Show newest version
package com.mageddo.tobby.replicator;

import java.time.Duration;
import java.util.function.Predicate;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ReplicatorStopPredicates {

  public static Predicate notProcessedAtLeastOneHundredRecords() {
    return (it) -> it.getWaveProcessed() < 100;
  }

  public static Predicate tookLessThanOneSecond() {
    return (it) -> it.getWaveDuration()
        .compareTo(Duration.ofSeconds(1)) <= 0;
  }

  public static Predicate exitWhenReplicatingFasterThanProducing() {
    return notProcessedAtLeastOneHundredRecords().and(tookLessThanOneSecond());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy