se.jguru.nazgul.core.algorithms.api.Validate.isTrue()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(77)

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

Validate.isTrue介绍

[英]Validates that the supplied condition is true, and throws an IllegalArgumentException otherwise.
[中]验证提供的条件是否为真,否则将抛出IllegalArgumentException。

代码示例

代码示例来源:origin: se.jguru.nazgul.test.persistence/nazgul-core-persistence-test

private void addParameter(final SortedMap<Integer, String> target, final int index, final String value) {

    if (index >= 0) {

      // Check sanity
      Validate.isTrue(!target.containsKey(index),
          "Key [" + index + "] already present in target map [" + target + "]");

      // Add the value.
      target.put(index, value);
    }
  }
}

代码示例来源:origin: se.jguru.nazgul.core.reflection.api/nazgul-core-reflection-api

Validate.isTrue(char1 < BASELENGTH, ERROR_PREFIX
    + "Each byte must be < " + BASELENGTH + " [Got: " + char1 + "].");
Validate.isTrue(char2 < BASELENGTH, ERROR_PREFIX
    + "Each byte must be < " + BASELENGTH + " [Got: " + char2 + "].");

代码示例来源:origin: se.jguru.nazgul.core.xmlbinding.spi.jaxb/nazgul-core-xmlbinding-spi-jaxb

/**
 * Adds a mapping between the supplied namespace and the given xmlSchemaSnippet.
 *
 * @param namespace        The non-null namespace which should be mapped.
 * @param xmlSchemaSnippet The non-empty xml Schema snippet which should be mapped.
 */
public void addNamespace2SchemaEntry(@NotNull final String namespace,
                   @NotNull @Size(min = 1) final String xmlSchemaSnippet) {
  // Check sanity
  Validate.notNull(namespace, "namespace");
  Validate.notEmpty(xmlSchemaSnippet, "xmlSchemaSnippet");
  Validate.isTrue(!namespace2SchemaSnippetMap.containsKey(namespace),
      "Cannot overwrite namespace [" + namespace + "]. Known namespaces: "
          + namespace2SchemaSnippetMap.keySet()
          .stream()
          .reduce((l, r) -> l + ", " + r)
          .orElse("<none>"));
  // Add the mapping.
  namespace2SchemaSnippetMap.put(namespace, xmlSchemaSnippet);
}

代码示例来源:origin: se.jguru.nazgul.core.xmlbinding.spi.jaxb/nazgul-core-xmlbinding-spi-jaxb

/**
 * {@inheritDoc}
 */
@Override
public <OriginalType, TransportType> Class<OriginalType> getOriginalType(
    @NotNull final Class<TransportType> transportType) throws IllegalArgumentException {
  // Check sanity
  Validate.notNull(transportType, "transportType");
  Validate.isTrue(transportType != JaxbAnnotatedNull.class,
      "Cannot acquire OriginalType for JaxbAnnotatedNull argument.");
  // If the transportType is neither a Primitive nor annotated with XmlType ... complain.
  boolean incorrectType = !transportType.isPrimitive()
      && !SELF_CONVERTIBLE.contains(transportType)
      && !transportType.isAnnotationPresent(XmlType.class);
  if (incorrectType) {
    throw new IllegalArgumentException("Supplied transportType [" + transportType.getName()
        + "] is not annotated with XmlType.");
  }
  // Find something in our registry?
  for (Class<?> current : registry.getPossibleConversions(transportType)) {
    // Is this a non-transport type?
    if (!current.isAnnotationPresent(XmlType.class)) {
      return (Class<OriginalType>) current;
    }
  }
  // None found.
  return null;
}

相关文章

微信公众号

最新文章

更多