org.apache.commons.lang3.Validate.inclusiveBetween()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中org.apache.commons.lang3.Validate.inclusiveBetween()方法的一些代码示例,展示了Validate.inclusiveBetween()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validate.inclusiveBetween()方法的具体详情如下:
包路径:org.apache.commons.lang3.Validate
类名称:Validate
方法名:inclusiveBetween

Validate.inclusiveBetween介绍

[英]Validate that the specified primitive value falls between the two inclusive values specified; otherwise, throws an exception.

Validate.inclusiveBetween(0.1, 2.1, 1.1);

[中]验证指定的原语值是否介于指定的两个包含值之间;否则,抛出一个异常

Validate.inclusiveBetween(0.1, 2.1, 1.1);

代码示例

代码示例来源:origin: Swagger2Markup/swagger2markup

/**
 * @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;
}

代码示例来源:origin: Swagger2Markup/swagger2markup

/**
 * @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;
}

代码示例来源:origin: Swagger2Markup/swagger2markup

/**
 * 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;
}

代码示例来源:origin: Swagger2Markup/swagger2markup

/**
 * 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;
}

代码示例来源:origin: Swagger2Markup/swagger2markup

/**
 * @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;
}

代码示例来源:origin: Swagger2Markup/swagger2markup

/**
 * @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;
}

代码示例来源:origin: org.apache.commons/commons-lang3

@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());
  }
}

代码示例来源:origin: org.apache.commons/commons-lang3

@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());
  }
}

代码示例来源:origin: org.apache.commons/commons-lang3

@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());
  }
}

代码示例来源:origin: org.apache.commons/commons-lang3

@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());
  }
}

代码示例来源:origin: org.apache.commons/commons-lang3

@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());
  }
}

代码示例来源:origin: org.apache.commons/commons-lang3

@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());
  }
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * 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);
}

代码示例来源:origin: org.apache.commons/commons-lang3

Validate.inclusiveBetween(0, Long.MAX_VALUE, durationMillis, "durationMillis must not be negative");

代码示例来源:origin: jamesagnew/hapi-fhir

/**
 * 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;
}

代码示例来源:origin: jamesagnew/hapi-fhir

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());

代码示例来源:origin: org.qcri.rheem/rheem-basic

@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());
}

代码示例来源:origin: org.qcri.rheem/rheem-basic

@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));
}

代码示例来源:origin: org.qcri.rheem/rheem-basic

@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]));
}

代码示例来源:origin: org.qcri.rheem/rheem-basic

@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)));
  }
}

相关文章