/** * @param position the current position * @param docBuilder the MarkupDocBuilder */ public Context(Position position, MarkupDocBuilder docBuilder) { super(docBuilder); Validate.inclusiveBetween(Position.DOCUMENT_BEFORE, Position.DOCUMENT_AFTER, position); this.position = position; }
/** * @param position the current position * @param docBuilder the MarkupDocBuilder */ public Context(Position position, MarkupDocBuilder docBuilder) { super(docBuilder); Validate.inclusiveBetween(Position.DOCUMENT_BEFORE, Position.DOCUMENT_AFTER, position); this.position = position; }
/** * Context for positions DOCUMENT_* * * @param position the current position * @param docBuilder the MarkupDocBuilder */ public Context(Position position, MarkupDocBuilder docBuilder) { super(docBuilder); Validate.inclusiveBetween(Position.DOCUMENT_BEFORE, Position.DOCUMENT_AFTER, position); this.position = position; }
/** * Context for all other positions * * @param position the current position * @param docBuilder the MarkupDocBuilder * @param operation the current path operation */ public Context(Position position, MarkupDocBuilder docBuilder, PathOperation operation) { super(docBuilder); Validate.inclusiveBetween(Position.OPERATION_BEFORE, Position.OPERATION_SECURITY_AFTER, position); Validate.notNull(operation); this.position = position; this.operation = operation; }
/** * @param position the current position * @param docBuilder the MarkupDocBuilder * @param securitySchemeName the name of the current securityScheme * @param securityScheme the current security scheme securityScheme */ public Context(Position position, MarkupDocBuilder docBuilder, String securitySchemeName, SecuritySchemeDefinition securityScheme) { super(docBuilder); Validate.inclusiveBetween(Position.SECURITY_SCHEME_BEFORE, Position.SECURITY_SCHEME_AFTER, position); Validate.notNull(securitySchemeName); Validate.notNull(securityScheme); this.position = position; this.securitySchemeName = securitySchemeName; this.securityScheme = securityScheme; }
/** * @param position the current position * @param docBuilder the MarkupDocBuilder * @param definitionName the name of the current definition * @param model the current Model of the definition */ public Context(Position position, MarkupDocBuilder docBuilder, String definitionName, Model model) { super(docBuilder); Validate.inclusiveBetween(Position.DEFINITION_BEFORE, Position.DEFINITION_AFTER, position); Validate.notNull(definitionName); Validate.notNull(model); this.position = position; this.definitionName = definitionName; this.model = model; }
@Test public void testInclusiveBetweenLong_withMessage() { Validate.inclusiveBetween(0, 2, 1, "Error"); Validate.inclusiveBetween(0, 2, 2, "Error"); try { Validate.inclusiveBetween(0, 5, 6, "Error"); fail("Expecting IllegalArgumentException"); } catch (final IllegalArgumentException e) { assertEquals("Error", e.getMessage()); } }
@Test public void testInclusiveBetweenDouble() { Validate.inclusiveBetween(0.1, 2.1, 1.1); Validate.inclusiveBetween(0.1, 2.1, 2.1); try { Validate.inclusiveBetween(0.1, 5.1, 6.1); fail("Expecting IllegalArgumentException"); } catch (final IllegalArgumentException e) { assertEquals("The value 6.1 is not in the specified inclusive range of 0.1 to 5.1", e.getMessage()); } }
@Test public void testInclusiveBetweenDouble_withMessage() { Validate.inclusiveBetween(0.1, 2.1, 1.1, "Error"); Validate.inclusiveBetween(0.1, 2.1, 2.1, "Error"); try { Validate.inclusiveBetween(0.1, 5.1, 6.1, "Error"); fail("Expecting IllegalArgumentException"); } catch (final IllegalArgumentException e) { assertEquals("Error", e.getMessage()); } }
@Test public void testInclusiveBetweenLong() { Validate.inclusiveBetween(0, 2, 1); Validate.inclusiveBetween(0, 2, 2); try { Validate.inclusiveBetween(0, 5, 6); fail("Expecting IllegalArgumentException"); } catch (final IllegalArgumentException e) { assertEquals("The value 6 is not in the specified inclusive range of 0 to 5", e.getMessage()); } }
@Test public void testInclusiveBetween() { Validate.inclusiveBetween("a", "c", "b"); try { Validate.inclusiveBetween("0", "5", "6"); fail("Expecting IllegalArgumentException"); } catch (final IllegalArgumentException e) { assertEquals("The value 6 is not in the specified inclusive range of 0 to 5", e.getMessage()); } }
@Test public void testInclusiveBetween_withMessage() { Validate.inclusiveBetween("a", "c", "b", "Error"); try { Validate.inclusiveBetween("0", "5", "6", "Error"); fail("Expecting IllegalArgumentException"); } catch (final IllegalArgumentException e) { assertEquals("Error", e.getMessage()); } }
/** * Creates a new instance of {@link TimedSemaphore} and initializes it with * an executor service, the given time period, and the limit. The executor * service will be used for creating a periodic task for monitoring the time * period. It can be <b>null</b>, then a default service will be created. * * @param service the executor service * @param timePeriod the time period * @param timeUnit the unit for the period * @param limit the limit for the semaphore * @throws IllegalArgumentException if the period is less or equals 0 */ public TimedSemaphore(final ScheduledExecutorService service, final long timePeriod, final TimeUnit timeUnit, final int limit) { Validate.inclusiveBetween(1, Long.MAX_VALUE, timePeriod, "Time period must be greater than 0!"); period = timePeriod; unit = timeUnit; if (service != null) { executorService = service; ownExecutor = false; } else { final ScheduledThreadPoolExecutor s = new ScheduledThreadPoolExecutor( THREAD_POOL_SIZE); s.setContinueExistingPeriodicTasksAfterShutdownPolicy(false); s.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); executorService = s; ownExecutor = true; } setLimit(limit); }
Validate.inclusiveBetween(0, Long.MAX_VALUE, durationMillis, "durationMillis must not be negative");
/** * Unlike with normal search queries, $everything queries have their _includes loaded by the main search thread and these included results * are added to the normal search results instead of being added on as extras in a page. This means that they will not appear multiple times * as the search results are paged over. * <p> * In order to recursively load _includes, we process the original results in batches of this size. Adjust with caution, increasing this * value may improve performance but may also cause memory issues. * </p> * <p> * The default value is 50 * </p> */ public void setEverythingIncludesFetchPageSize(int theEverythingIncludesFetchPageSize) { Validate.inclusiveBetween(1, Integer.MAX_VALUE, theEverythingIncludesFetchPageSize); myEverythingIncludesFetchPageSize = theEverythingIncludesFetchPageSize; }
Integer max = myDaoConfig.getMaximumSearchResultCountInTransaction(); if (max != null) { Validate.inclusiveBetween(1, Integer.MAX_VALUE, max.intValue(), "Maximum search result count in transaction ust be a positive integer"); theParams.setLoadSynchronousUpTo(myDaoConfig.getMaximumSearchResultCountInTransaction());
@Override public Optional<org.qcri.rheem.core.optimizer.cardinality.CardinalityEstimator> createCardinalityEstimator( final int outputIndex, final Configuration configuration) { Validate.inclusiveBetween(0, this.getNumOutputs() - 1, outputIndex); return Optional.of(new TextFileSource.CardinalityEstimator()); }
@Override public Optional<org.qcri.rheem.core.optimizer.cardinality.CardinalityEstimator> createCardinalityEstimator( final int outputIndex, final Configuration configuration) { Validate.inclusiveBetween(0, this.getNumOutputs() - 1, outputIndex); return Optional.of(new FlatMapOperator.CardinalityEstimator(configuration)); }
@Override public Optional<CardinalityEstimator> createCardinalityEstimator( final int outputIndex, final Configuration configuration) { Validate.inclusiveBetween(0, this.getNumOutputs() - 1, outputIndex); return Optional.of(new DefaultCardinalityEstimator(1d, 2, this.isSupportingBroadcastInputs(), inputCards -> inputCards[0] + inputCards[1])); }
@Override public Optional<CardinalityEstimator> createCardinalityEstimator( final int outputIndex, final Configuration configuration) { Validate.inclusiveBetween(0, this.getNumOutputs() - 1, outputIndex); // TODO: Come up with a dynamic estimator. // Assume with a confidence of 0.7 that 70% of the data quanta are pairwise distinct. return Optional.of(new DefaultCardinalityEstimator(0.7d, 1, this.isSupportingBroadcastInputs(), inputCards -> (long) (inputCards[0] * 0.7d))); } }