Java Code Examples for com.github.davidmoten.guavamini.Preconditions#checkArgument()
The following examples show how to use
com.github.davidmoten.guavamini.Preconditions#checkArgument() .
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: FlowableStateMachine.java From rxjava2-extras with Apache License 2.0 | 6 votes |
public FlowableStateMachine(Flowable<In> source, // Callable<? extends State> initialState, // Function3<? super State, ? super In, ? super Emitter<Out>, ? extends State> transition, // BiConsumer<? super State, ? super Emitter<Out>> completionAction, // Consumer3<? super State, ? super Throwable, ? super Emitter<Out>> errorAction, // BackpressureStrategy backpressureStrategy, // int requestBatchSize) { Preconditions.checkNotNull(initialState); Preconditions.checkNotNull(transition); Preconditions.checkNotNull(backpressureStrategy); Preconditions.checkArgument(requestBatchSize > 0, "initialRequest must be greater than zero"); this.source = source; this.initialState = initialState; this.transition = transition; this.completionAction = completionAction; this.errorAction = errorAction; this.backpressureStrategy = backpressureStrategy; this.requestBatchSize = requestBatchSize; }
Example 2
Source File: FlowableOnBackpressureBufferToFile.java From rxjava2-extras with Apache License 2.0 | 5 votes |
public FlowableOnBackpressureBufferToFile(Flowable<T> source, Observable<T> source2, Options options, Serializer<T> serializer) { // only one source should be defined Preconditions.checkArgument((source != null) ^ (source2 != null)); this.source = source; this.source2 = source2; this.options = options; this.serializer = serializer; }
Example 3
Source File: FlowableMaxRequest.java From rxjava2-extras with Apache License 2.0 | 5 votes |
public FlowableMaxRequest(Flowable<T> source, long[] maxRequests) { Preconditions.checkArgument(maxRequests.length > 0, "maxRequests length must be greater than 0"); for (int i = 0; i < maxRequests.length; i++) { Preconditions.checkArgument(maxRequests[i] > 0, "maxRequests items must be greater than zero"); } this.source = source; this.maxRequests = maxRequests; }
Example 4
Source File: NonBlockingConnectionPool.java From rxjava2-jdbc with Apache License 2.0 | 5 votes |
/** * Sets the provider of {@link Connection} objects to be used by the pool. * * @param cp * connection provider * @return this */ public Builder<T> connectionProvider(ConnectionProvider cp) { Preconditions.checkArgument(!(cp instanceof SingletonConnectionProvider), // "connection provider should not return a singleton connection because " // + "a pool needs control over the creation and closing of connections. " // + "Use ConnectionProvider.from(url,...) instead."); this.cp = cp; return this; }
Example 5
Source File: FlowableMinRequest.java From rxjava2-extras with Apache License 2.0 | 5 votes |
public FlowableMinRequest(Flowable<T> source, int[] minRequests) { Preconditions.checkArgument(minRequests.length > 0, "minRequests length must be > 0"); for (int i = 0; i < minRequests.length; i++) { Preconditions.checkArgument(minRequests[i] > 0, "each item in minRequests must be > 0"); } this.source = source; this.minRequest = minRequests; }
Example 6
Source File: FlowableRepeatingTransform.java From rxjava2-extras with Apache License 2.0 | 5 votes |
public FlowableRepeatingTransform(Flowable<T> source, Function<? super Flowable<T>, ? extends Flowable<T>> transform, int maxChained, long maxIterations, Function<Observable<T>, Observable<?>> tester) { Preconditions.checkArgument(maxChained > 0, "maxChained must be > 0"); Preconditions.checkArgument(maxIterations > 0, "maxIterations must be > 0"); Preconditions.checkNotNull(transform, "transform must not be null"); Preconditions.checkNotNull(tester, "tester must not be null"); this.source = source; this.transform = transform; this.maxChained = maxChained; this.maxIterations = maxIterations; this.tester = tester; }
Example 7
Source File: Processor.java From state-machine with Apache License 2.0 | 5 votes |
public Processor<Id> build() { Preconditions.checkArgument(behaviourFactory != null || !behaviours.isEmpty(), "one of behaviourFactory or multiple calls to behaviour must be made (behaviour must be specified)"); Preconditions.checkArgument(behaviourFactory == null || behaviours.isEmpty(), "cannot specify both behaviourFactory and behaviour"); if (!behaviours.isEmpty()) { behaviourFactory = cls -> behaviours.get(cls); } return new Processor<Id>(behaviourFactory, processingScheduler, signalScheduler, signals, entityTransform, preGroupBy, mapFactory, preTransitionAction, postTransitionAction); }
Example 8
Source File: ImmutableBeanGenerator.java From state-machine with Apache License 2.0 | 5 votes |
private static void writeClassDeclaration(PrintStream s, ClassOrInterfaceDeclaration c) { s.format("\npublic%s class %s", c.isFinal() ? " final" : "", c.getName()); if (c.getImplementedTypes() != null && !c.getImplementedTypes().isEmpty()) { s.format(" implements"); for (ClassOrInterfaceType iface : c.getImplementedTypes()) { s.append(" " + iface); } } s.append(" {\n"); Preconditions.checkArgument(c.getExtendedTypes().size() == 0); }
Example 9
Source File: Persistence.java From state-machine with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void schedule(NumberedSignal<?, ?> sig) { Preconditions.checkArgument(sig.signal.time().isPresent()); long now = clock.now(); long delayMs = Math.max(0, sig.signal.time().get() - now); executor.schedule(() -> offer((NumberedSignal<?, String>) sig), delayMs, TimeUnit.MILLISECONDS); }
Example 10
Source File: SelectBuilder.java From rxjava2-jdbc with Apache License 2.0 | 5 votes |
@Override public SelectBuilder dependsOn(@Nonnull Flowable<?> flowable) { Preconditions.checkArgument(dependsOn == null, "can only set dependsOn once"); Preconditions.checkNotNull(flowable); dependsOn = flowable; return this; }
Example 11
Source File: MemberSingle.java From rxjava2-jdbc with Apache License 2.0 | 5 votes |
Observers(MemberSingleObserver<T>[] observers, boolean[] active, int activeCount, int index, int requested) { Preconditions.checkArgument(observers.length > 0 || index == 0, "index must be -1 for zero length array"); Preconditions.checkArgument(observers.length == active.length); this.observers = observers; this.index = index; this.active = active; this.activeCount = activeCount; this.requested = requested; }
Example 12
Source File: Transformers.java From rxjava2-extras with Apache License 2.0 | 5 votes |
public static <T> Function<Flowable<T>, Flowable<T>> repeat( final Function<? super Flowable<T>, ? extends Flowable<T>> transform, final int maxChained, final long maxIterations, final Function<Observable<T>, Observable<?>> tester) { Preconditions.checkArgument(maxChained > 0, "maxChained must be > 0"); Preconditions.checkArgument(maxIterations > 0, "maxIterations must be > 0"); Preconditions.checkNotNull(transform, "transform must not be null"); Preconditions.checkNotNull(tester, "tester must not be null"); return new Function<Flowable<T>, Flowable<T>>() { @Override public Flowable<T> apply(Flowable<T> source) { return new FlowableRepeatingTransform<T>(source, transform, maxChained, maxIterations, tester); } }; }
Example 13
Source File: SelectBuilder.java From rxjava2-jdbc with Apache License 2.0 | 4 votes |
public SelectBuilder queryTimeoutSec(int timeoutSec) { Preconditions.checkArgument(timeoutSec >= 0); this.queryTimeoutSec = timeoutSec; return this; }
Example 14
Source File: Persistence.java From state-machine with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public <T> Builder rangeMetricFactory(Class<T> cls, Function<? super T, Optional<IntProperty>> rangeMetric) { Preconditions.checkArgument(rangeMetricFactory == null); rangeMetrics.put((Class<?>) cls, (Function<Object, Optional<IntProperty>>) rangeMetric); return this; }
Example 15
Source File: NonBlockingPool.java From rxjava2-jdbc with Apache License 2.0 | 4 votes |
public Builder<T> idleTimeBeforeHealthCheck(long duration, TimeUnit unit) { Preconditions.checkArgument(duration >= 0); this.idleTimeBeforeHealthCheckMs = unit.toMillis(duration); return this; }
Example 16
Source File: Withdrawal.java From state-machine with Apache License 2.0 | 4 votes |
public Withdrawal(BigDecimal amount) { super(amount.negate()); Preconditions.checkArgument(amount.signum() == 1, "amount must be greater than zero"); }
Example 17
Source File: Pages.java From rxjava2-extras with Apache License 2.0 | 4 votes |
public Pages(Callable<File> fileFactory, int pageSize) { Preconditions.checkArgument(pageSize >= 4); Preconditions.checkArgument(pageSize % 4 == 0); this.fileFactory = fileFactory; this.pageSize = pageSize; }
Example 18
Source File: CallableBuilder.java From rxjava2-jdbc with Apache License 2.0 | 4 votes |
public Completable input(Flowable<?> f) { Preconditions.checkArgument(inStream == null, "you can only specify in flowable once, current=" + inStream); this.inStream = f; return build(); }
Example 19
Source File: NonBlockingConnectionPool.java From rxjava2-jdbc with Apache License 2.0 | 2 votes |
/** * Sets a listener for connection success and failure. Success and failure * events are reported serially to the listener. If the consumer throws it will * be reported to {@code RxJavaPlugins.onError}. This consumer should not block * otherwise it will block the connection pool itself. * * @param c * listener for connection events * @return this */ public Builder<T> connectionListener(Consumer<? super Optional<Throwable>> c) { Preconditions.checkArgument(c != null, "listener can only be set once"); this.c = c; return this; }
Example 20
Source File: UpdateBuilder.java From rxjava2-jdbc with Apache License 2.0 | 2 votes |
/** * Returns a builder used to specify how to process the generated keys * {@link ResultSet}. Not all jdbc drivers support this functionality and * some have limitations in their support (h2 for instance only returns the * last generated key when multiple inserts happen in the one statement). * * @return a builder used to specify how to process the generated keys * ResultSet */ public ReturnGeneratedKeysBuilder returnGeneratedKeys() { Preconditions.checkArgument(batchSize == 1, "Cannot return generated keys if batchSize > 1"); return new ReturnGeneratedKeysBuilder(this); }