RangeBased(final int startIndex, final int count) { isTrueArgument("startIndex", startIndex >= 0); isTrueArgument("count", count > 0); this.startIndex = startIndex; this.count = count; }
ExponentiallyWeightedMovingAverage(final double alpha) { isTrueArgument("alpha >= 0.0 and <= 1.0", alpha >= 0.0 && alpha <= 1.0); this.alpha = alpha; }
ReadTimeoutHandler(final long readTimeout) { isTrueArgument("readTimeout must be greater than zero.", readTimeout > 0); this.readTimeout = readTimeout; }
/** * Sets the connection timeout. * * @param connectTimeout the connection timeout, in milliseconds, which must be > 0 * @throws IllegalArgumentException if {@code connectTimeout <= 0} * @return {@code this} * @see com.mongodb.MongoClientOptions#getConnectTimeout() */ public Builder connectTimeout(final int connectTimeout) { isTrueArgument("connectTimeout must be >= 0", connectTimeout >= 0); this.connectTimeout = connectTimeout; return this; }
/** * Sets the 2dsphere index version number. * * @param sphereVersion the 2dsphere index version number. * @return this */ public IndexRequest sphereVersion(final Integer sphereVersion) { if (sphereVersion != null) { isTrueArgument("sphereIndexVersion must be 1, 2 or 3", VALID_SPHERE_INDEX_VERSIONS.contains(sphereVersion)); } this.sphereVersion = sphereVersion; return this; }
/** * Set the text index version number. * * @param textVersion the text index version number. * @return this */ public IndexRequest textVersion(final Integer textVersion) { if (textVersion != null) { isTrueArgument("textVersion must be 1, 2 or 3", VALID_TEXT_INDEX_VERSIONS.contains(textVersion)); } this.textVersion = textVersion; return this; }
/** * Construct an instance. * * @param values the non-null values */ public Position(final List<Double> values) { notNull("values", values); isTrueArgument("value contains only non-null elements", !values.contains(null)); isTrueArgument("value must contain at least two elements", values.size() >= 2); this.values = Collections.unmodifiableList(values); }
/** * Creates a new instance * @param path the path of the MongoD unix domain socket. */ public UnixServerAddress(final String path) { super(notNull("The path cannot be null", path)); isTrueArgument("The path must end in .sock", path.endsWith(".sock")); }
AggregateOperationImpl<T> maxAwaitTime(final long maxAwaitTime, final TimeUnit timeUnit) { notNull("timeUnit", timeUnit); isTrueArgument("maxAwaitTime >= 0", maxAwaitTime >= 0); this.maxAwaitTimeMS = TimeUnit.MILLISECONDS.convert(maxAwaitTime, timeUnit); return this; }
AggregateOperationImpl<T> maxTime(final long maxTime, final TimeUnit timeUnit) { notNull("timeUnit", timeUnit); isTrueArgument("maxTime >= 0", maxTime >= 0); this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit); return this; }
@Override public GridFSDownloadStream batchSize(final int batchSize) { isTrueArgument("batchSize cannot be negative", batchSize >= 0); this.batchSize = batchSize; discardCursor(); return this; }
/** * Sets the maximum execution time on the server for this operation. * * @param maxTime the max time * @param timeUnit the time unit, which may not be null * @return this */ public FindOperation<T> maxTime(final long maxTime, final TimeUnit timeUnit) { notNull("timeUnit", timeUnit); isTrueArgument("maxTime >= 0", maxTime >= 0); this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit); return this; }
DefaultAuthenticator(final MongoCredentialWithCache credential) { super(credential); isTrueArgument("unspecified authentication mechanism", credential.getAuthenticationMechanism() == null); }
/** * Check the validity of the given collection name. A valid collection name is non-null and non-empty. The server may impose * additional restrictions on collection names. * * @param collectionName the collection name * @throws IllegalArgumentException if the collection name is invalid * @since 3.4 * @mongodb.driver.manual reference/limits/#naming-restrictions Naming Restrictions */ public static void checkCollectionNameValidity(final String collectionName) { notNull("collectionName", collectionName); isTrueArgument("collectionName is not empty", !collectionName.isEmpty()); }
/** * Construct an instance with the given coordinates and coordinate reference system. * * @param coordinateReferenceSystem the coordinate reference system * @param coordinates the coordinates */ public MultiPoint(@Nullable final CoordinateReferenceSystem coordinateReferenceSystem, final List<Position> coordinates) { super(coordinateReferenceSystem); notNull("coordinates", coordinates); isTrueArgument("coordinates contains only non-null positions", !coordinates.contains(null)); this.coordinates = Collections.unmodifiableList(coordinates); }
TaggableReadPreference(final List<TagSet> tagSetList, @Nullable final Long maxStaleness, final TimeUnit timeUnit) { notNull("tagSetList", tagSetList); isTrueArgument("maxStaleness is null or >= 0", maxStaleness == null || maxStaleness >= 0); this.maxStalenessMS = maxStaleness == null ? null : MILLISECONDS.convert(maxStaleness, timeUnit); this.tagSetList.addAll(tagSetList); }
/** * Construct an instance. * * @param coordinateReferenceSystem the coordinate reference system * @param coordinates the coordinates */ public MultiPolygon(@Nullable final CoordinateReferenceSystem coordinateReferenceSystem, final List<PolygonCoordinates> coordinates) { super(coordinateReferenceSystem); notNull("coordinates", coordinates); isTrueArgument("coordinates has no null elements", !coordinates.contains(null)); this.coordinates = Collections.unmodifiableList(coordinates); }
AggregateOperationImpl<T> hint(final BsonValue hint) { isTrueArgument("BsonString or BsonDocument", hint == null || hint.isDocument() || hint.isString()); this.hint = hint; return this; }
/** * Construct an instance. * * @param connectionId the non-null connectionId * @param elapsedTimeNanos the non-negative elapsed time in nanoseconds * @param throwable the non-null exception that caused the failure */ public ServerHeartbeatFailedEvent(final ConnectionId connectionId, final long elapsedTimeNanos, final Throwable throwable) { this.connectionId = notNull("connectionId", connectionId); isTrueArgument("elapsed time is not negative", elapsedTimeNanos >= 0); this.elapsedTimeNanos = elapsedTimeNanos; this.throwable = notNull("throwable", throwable); }
/** * Sets the hint for which index to use. A null value means no hint is set. * * @param hint the hint * @return this * @since 3.6 * @mongodb.server.release 3.6 */ public AggregateExplainOperation hint(final BsonValue hint) { isTrueArgument("BsonString or BsonDocument", hint == null || hint.isDocument() || hint.isString()); this.hint = hint; return this; }